diff --git a/README.md b/README.md index 5fac8b63..7d0a6ec0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Arcturus Morningstar is as a fork of Arcturus Emulator by TheGeneral. Arcturus M [![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=KREWS&logoColor=fff)](https://discord.gg/BzfFsTp) ## Download ## -[![image](https://img.shields.io/badge/STABLE%20RELEASES-3.0.0-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases) +[![image](https://img.shields.io/badge/STABLE%20RELEASES-3.5.1-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases) [![image](https://img.shields.io/badge/DEVELOPER%20PREVIEW-4.0.0-red.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/jobs) * diff --git a/pom.xml b/pom.xml index bdc3afb9..d55e42fb 100644 --- a/pom.xml +++ b/pom.xml @@ -34,8 +34,8 @@ maven-compiler-plugin 3.8.1 - 1.8 - 1.8 + 18 + 18 @@ -92,21 +92,21 @@ io.netty netty-all - 4.1.49.Final + 4.1.86.Final com.google.code.gson gson - 2.8.6 + 2.8.9 mysql mysql-connector-java - 8.0.22 + 8.0.28 runtime @@ -143,14 +143,14 @@ org.jsoup jsoup - 1.13.1 + 1.15.3 compile ch.qos.logback logback-classic - 1.2.3 + 1.2.9 compile @@ -165,5 +165,12 @@ joda-time 2.10.6 + + + org.projectlombok + lombok + 1.18.24 + provided + \ No newline at end of file diff --git a/sqlupdates/Update 3_5_0 to 3_5_2.sql b/sqlupdates/Update 3_5_0 to 3_5_2.sql new file mode 100644 index 00000000..4a5d607b --- /dev/null +++ b/sqlupdates/Update 3_5_0 to 3_5_2.sql @@ -0,0 +1,2 @@ +-- Trade Currency Setting +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('redeem.currency.trade', '1'); diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 47e5b507..7e59f956 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -17,6 +17,7 @@ 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 lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,6 +30,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Matcher; import java.util.regex.Pattern; +@Slf4j public final class Emulator { public static final int MAJOR = 4; @@ -45,14 +47,17 @@ public final class Emulator { private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); private static final String OS_NAME = (System.getProperty("os.name") != null ? System.getProperty("os.name") : "Unknown"); private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown"); + private static final String logo = - "\n" + - "███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" + - "████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗\n" + - "██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" + - "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" + - "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" + - "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n"; + """ + + ███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗\s + ████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗ + ██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝ + ██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗ + ██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║ + ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ + """; @@ -64,7 +69,6 @@ public final class Emulator { private static GameServer gameServer; private static RCONServer rconServer; private static CameraClient cameraClient; - private static Logging logging; private static Database database; private static DatabaseLogger databaseLogger; private static ThreadPooling threading; @@ -90,7 +94,7 @@ public final class Emulator { scanner.nextLine(); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) { try { // Check if running on Windows and not in IntelliJ. // If so, we need to reconfigure the console appender and enable Jansi for colors. @@ -107,7 +111,6 @@ public final class Emulator { setBuild(); Emulator.stopped = false; ConsoleCommand.load(); - Emulator.logging = new Logging(); System.out.println(logo); @@ -116,11 +119,11 @@ public final class Emulator { System.out.println(); promptEnterKey(); } - LOGGER.info("eek. Has it really been a year?"); - LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); - LOGGER.info("Version: {}", version); - LOGGER.info("Build: {}", build); - LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community"); + log.info("eek. Has it really been a year?"); + log.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); + log.info("Version: {}", version); + log.info("Build: {}", build); + log.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community"); long startTime = System.nanoTime(); @@ -153,16 +156,16 @@ public final class Emulator { Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - LOGGER.info("Arcturus Morningstar has successfully loaded."); - LOGGER.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2); - LOGGER.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024)); + log.info("Arcturus Morningstar has successfully loaded."); + log.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2); + log.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024)); Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode"); if (debugging) { 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."); + log.debug("Debugging enabled."); } Emulator.getPluginManager().fireEvent(new EmulatorLoadedEvent()); @@ -170,7 +173,7 @@ public final class Emulator { Emulator.timeStarted = getIntUnixTimestamp(); if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) { - LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to ({}) to possibly increase performance.", + log.warn("Emulator settings runtime.threads ({}) can be increased to ({}) to possibly increase performance.", Emulator.getConfig().getInt("runtime.threads"), Runtime.getRuntime().availableProcessors() * 2); } @@ -193,7 +196,7 @@ public final class Emulator { System.out.println("Waiting for command: "); } catch (Exception e) { if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { - LOGGER.error("Error while reading command", e); + log.error("Error while reading command", e); } } } @@ -234,7 +237,7 @@ public final class Emulator { Emulator.isShuttingDown = true; Emulator.isReady = false; - LOGGER.info("Stopping Arcturus Morningstar {}", version); + log.info("Stopping Arcturus Morningstar {}", version); try { if (Emulator.getPluginManager() != null) @@ -285,7 +288,7 @@ public final class Emulator { } catch (Exception ignored) { } - LOGGER.info("Stopped Arcturus Morningstar {}", version); + log.info("Stopped Arcturus Morningstar {}", version); if (Emulator.database != null) { Emulator.getDatabase().dispose(); @@ -332,13 +335,6 @@ public final class Emulator { return rconServer; } - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public static Logging getLogging() { - return logging; - } public static ThreadPooling getThreading() { return threading; @@ -384,7 +380,7 @@ public final class Emulator { int totalSeconds = 0; Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("second", 1); map.put("minute", 60); map.put("hour", 3600); @@ -406,13 +402,12 @@ public final class Emulator { } public static Date modifyDate(Date date, String timeString) { - int totalSeconds = 0; Calendar c = Calendar.getInstance(); c.setTime(date); Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("second", Calendar.SECOND); map.put("minute", Calendar.MINUTE); map.put("hour", Calendar.HOUR); @@ -437,7 +432,7 @@ public final class Emulator { String res = ""; Date aux = stringToDate("1970-01-01 00:00:00"); if(aux == null) return null; - + Timestamp aux1 = dateToTimeStamp(aux); Timestamp aux2 = dateToTimeStamp(date); long difference = aux2.getTime() - aux1.getTime(); @@ -451,7 +446,7 @@ public final class Emulator { try { res = format.parse(date); } catch (Exception e) { - LOGGER.error("Error parsing date", e); + log.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 4d2a87a5..7897ddbe 100644 --- a/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -7,8 +7,7 @@ import com.eu.habbo.messages.incoming.friends.HabboSearchEvent; import com.eu.habbo.messages.incoming.navigator.RoomTextSearchEvent; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import com.eu.habbo.threading.runnables.AchievementUpdater; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,10 +15,9 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Map; +@Slf4j public class CleanerThread implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(CleanerThread.class); - private static final int DELAY = 10000; private static final int RELOAD_HALL_OF_FAME = 1800; private static final int RELOAD_NEWS_LIST = 3600; @@ -128,10 +126,10 @@ public class CleanerThread implements Runnable { statement.execute("DELETE FROM users_effects WHERE total <= 0"); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - LOGGER.info("Database -> Cleaned!"); + log.info("Database -> Cleaned!"); } public void refillDailyRespects() { @@ -140,13 +138,13 @@ public class CleanerThread implements Runnable { statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets")); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } if (Emulator.isReady) { for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) { - habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect"); - habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets"); + habbo.getHabboStats().setRespectPointsToGive(Emulator.getConfig().getInt("hotel.daily.respect")); + habbo.getHabboStats().setPetRespectPointsToGive(Emulator.getConfig().getInt("hotel.daily.respect.pets")); habbo.getClient().sendResponse(new UserObjectComposer(habbo)); } } @@ -162,7 +160,7 @@ public class CleanerThread implements Runnable { habbo.clearCaches(); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 1dfb2847..41040efa 100644 --- a/src/main/java/com/eu/habbo/core/CommandLog.java +++ b/src/main/java/com/eu/habbo/core/CommandLog.java @@ -2,10 +2,12 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; +import lombok.AllArgsConstructor; import java.sql.PreparedStatement; import java.sql.SQLException; +@AllArgsConstructor public class CommandLog implements DatabaseLoggable { private static final String INSERT_QUERY = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)"; @@ -16,13 +18,6 @@ public class CommandLog implements DatabaseLoggable { private final String params; private final boolean succes; - public CommandLog(int userId, Command command, String params, boolean succes) { - this.userId = userId; - this.command = command; - this.params = params; - this.succes = succes; - } - @Override public String getQuery() { return CommandLog.INSERT_QUERY; diff --git a/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/src/main/java/com/eu/habbo/core/ConfigurationManager.java index 19b442fe..85b5a00f 100644 --- a/src/main/java/com/eu/habbo/core/ConfigurationManager.java +++ b/src/main/java/com/eu/habbo/core/ConfigurationManager.java @@ -3,21 +3,18 @@ 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 lombok.extern.slf4j.Slf4j; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.sql.*; import java.util.Map; import java.util.Properties; +@Slf4j public class ConfigurationManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class); - private final Properties properties; private final String configurationPath; public boolean loaded = false; @@ -47,11 +44,11 @@ public class ConfigurationManager { if (!useEnvVarsForDbConnection) { try { File f = new File(this.configurationPath); - input = new FileInputStream(f); + input = Files.newInputStream(f.toPath()); this.properties.load(input); } catch (IOException ex) { - LOGGER.error("Failed to load config file.", ex); + log.error("Failed to load config file.", ex); ex.printStackTrace(); } finally { if (input != null) { @@ -92,7 +89,7 @@ public class ConfigurationManager { String envValue = System.getenv(entry.getValue()); if (envValue == null || envValue.length() == 0) { - LOGGER.info("Cannot find environment-value for variable `" + entry.getValue() + "`"); + log.info("Cannot find environment-value for variable `" + entry.getValue() + "`"); } else { this.properties.setProperty(entry.getKey(), envValue); } @@ -104,7 +101,7 @@ public class ConfigurationManager { } this.isLoading = false; - LOGGER.info("Configuration Manager -> Loaded!"); + log.info("Configuration Manager -> Loaded!"); if (Emulator.getPluginManager() != null) { Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent()); @@ -112,7 +109,7 @@ public class ConfigurationManager { } public void loadFromDatabase() { - LOGGER.info("Loading configuration from database..."); + log.info("Loading configuration from database..."); long millis = System.currentTimeMillis(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) { @@ -124,10 +121,10 @@ public class ConfigurationManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - LOGGER.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void saveToDatabase() { @@ -138,7 +135,7 @@ public class ConfigurationManager { statement.executeUpdate(); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -153,7 +150,7 @@ public class ConfigurationManager { return defaultValue; if (!this.properties.containsKey(key)) { - LOGGER.error("Config key not found {}", key); + log.error("Config key not found {}", key); } return this.properties.getProperty(key, defaultValue); } @@ -169,7 +166,7 @@ public class ConfigurationManager { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - LOGGER.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key)); + log.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key)); } return defaultValue; } @@ -185,15 +182,11 @@ public class ConfigurationManager { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - LOGGER.error("Failed to parse key {} with value '{}' to type integer.", key, this.getValue(key)); + log.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; @@ -201,7 +194,7 @@ public class ConfigurationManager { try { return Double.parseDouble(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - LOGGER.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key)); + log.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key)); } return defaultValue; @@ -220,7 +213,7 @@ public class ConfigurationManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.update(key, value); diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java index db5e74fb..2fe24faa 100644 --- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java @@ -2,14 +2,13 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.Map; +@Slf4j public class CreditsScheduler extends Scheduler { - private static final Logger LOGGER = LoggerFactory.getLogger(CreditsScheduler.class); public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; @@ -52,10 +51,10 @@ public class CreditsScheduler extends Scheduler { if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) continue; - habbo.giveCredits((int)(habbo.getHabboInfo().getRank().getCreditsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); + habbo.giveCredits((int) (habbo.getHabboInfo().getRank().getCreditsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 index 28fbe7cd..24c73acd 100644 --- a/src/main/java/com/eu/habbo/core/CryptoConfig.java +++ b/src/main/java/com/eu/habbo/core/CryptoConfig.java @@ -1,5 +1,10 @@ package com.eu.habbo.core; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public class CryptoConfig { private final boolean enabled; @@ -7,27 +12,4 @@ public class CryptoConfig { 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/DatabaseLogger.java b/src/main/java/com/eu/habbo/core/DatabaseLogger.java index 2f8806a9..81b1cbe0 100644 --- a/src/main/java/com/eu/habbo/core/DatabaseLogger.java +++ b/src/main/java/com/eu/habbo/core/DatabaseLogger.java @@ -1,18 +1,15 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.concurrent.ConcurrentLinkedQueue; +@Slf4j public class DatabaseLogger { - - private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseLogger.class); - private final ConcurrentLinkedQueue loggables = new ConcurrentLinkedQueue<>(); public void store(DatabaseLoggable loggable) { @@ -39,7 +36,7 @@ public class DatabaseLogger { } } catch (SQLException e) { - LOGGER.error("Exception caught while saving loggables to database.", e); + log.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 f0d62072..aa2a5c6a 100644 --- a/src/main/java/com/eu/habbo/core/ErrorLog.java +++ b/src/main/java/com/eu/habbo/core/ErrorLog.java @@ -1,8 +1,7 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.io.PrintWriter; @@ -10,9 +9,9 @@ import java.io.StringWriter; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class ErrorLog implements DatabaseLoggable { - private static final Logger LOGGER = LoggerFactory.getLogger(ErrorLog.class); private static final String QUERY = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)"; public final String version; @@ -38,7 +37,7 @@ public class ErrorLog implements DatabaseLoggable { pw.close(); sw.close(); } catch (IOException e1) { - LOGGER.error("Exception caught", e1); + log.error("Exception caught", e1); } } diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java index 58350a95..8a816274 100644 --- a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java @@ -2,15 +2,12 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.Map; +@Slf4j public class GotwPointsScheduler extends Scheduler { - - private static final Logger LOGGER = LoggerFactory.getLogger(GotwPointsScheduler.class); - public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; public static String GOTW_POINTS_NAME; @@ -68,7 +65,7 @@ public class GotwPointsScheduler extends Scheduler { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java deleted file mode 100644 index b1384a42..00000000 --- a/src/main/java/com/eu/habbo/core/Logging.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.eu.habbo.core; - -import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.SQLException; - -public class Logging { - - private static final Logger LOGGER = LoggerFactory.getLogger("LegacyLogger"); - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logStart(Object line) { - LOGGER.info("[LOADING] {}", line); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logShutdownLine(Object line) { - LOGGER.info("[SHUTDOWN] {}", line); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logUserLine(Object line) { - LOGGER.info("[USER] {}", line); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logDebugLine(Object line) { - LOGGER.debug("[DEBUG] {}", line); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logPacketLine(Object line) { - if (Emulator.getConfig().getBoolean("debug.show.packets")) { - LOGGER.debug("[PACKET] {}", line); - } - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logUndefinedPacketLine(Object line) { - if (Emulator.getConfig().getBoolean("debug.show.packets.undefined")) { - LOGGER.debug("[PACKET] [UNDEFINED] {}", line); - } - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logErrorLine(Object line) { - LOGGER.error("[ERROR] {}", line); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logSQLException(SQLException e) { - LOGGER.error("[ERROR] SQLException", e); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void logPacketError(Object e) { - LOGGER.error("[ERROR] PacketError {}", e); - } - - /** - * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. - */ - @Deprecated - public void handleException(Exception e) { - LOGGER.error("[ERROR] Exception", e); - } - -} diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java index 2b0bddd5..993ac885 100644 --- a/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java @@ -2,15 +2,12 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.Map; +@Slf4j public class PixelScheduler extends Scheduler { - - private static final Logger LOGGER = LoggerFactory.getLogger(PixelScheduler.class); - public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; public static double HC_MODIFIER; @@ -52,7 +49,7 @@ public class PixelScheduler extends Scheduler { habbo.givePixels((int)(habbo.getHabboInfo().getRank().getPixelsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 ca863cb8..8f74569d 100644 --- a/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java @@ -2,14 +2,13 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.Map; +@Slf4j public class PointsScheduler extends Scheduler { - private static final Logger LOGGER = LoggerFactory.getLogger(PointsScheduler.class); public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; @@ -55,7 +54,7 @@ public class PointsScheduler extends Scheduler { habbo.givePoints((int)(habbo.getHabboInfo().getRank().getDiamondsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 40eaff54..515334d5 100644 --- a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java +++ b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java @@ -4,19 +4,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomUserPetComposer extends MessageComposer { private final int petType; private final int race; private final String color; private final Habbo habbo; - public RoomUserPetComposer(int petType, int race, String color, Habbo habbo) { - this.petType = petType; - this.race = race; - this.color = color; - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/core/TextsManager.java b/src/main/java/com/eu/habbo/core/TextsManager.java index 523740db..7981678f 100644 --- a/src/main/java/com/eu/habbo/core/TextsManager.java +++ b/src/main/java/com/eu/habbo/core/TextsManager.java @@ -1,16 +1,13 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.Properties; +@Slf4j public class TextsManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(TextsManager.class); - private final Properties texts; public TextsManager() { @@ -21,9 +18,9 @@ public class TextsManager { try { this.reload(); - LOGGER.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -37,7 +34,7 @@ public class TextsManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -47,7 +44,7 @@ public class TextsManager { public String getValue(String key, String defaultValue) { if (!this.texts.containsKey(key)) { - LOGGER.error("Text key not found: {}", key); + log.error("Text key not found: {}", key); } return this.texts.getProperty(key, defaultValue); } @@ -60,7 +57,7 @@ public class TextsManager { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return defaultValue; } @@ -73,7 +70,7 @@ public class TextsManager { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (NumberFormatException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return defaultValue; } @@ -91,7 +88,7 @@ public class TextsManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 ea103623..96cb775d 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java @@ -1,11 +1,10 @@ package com.eu.habbo.core.consolecommands; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public abstract class ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleCommand.class); private static final THashMap commands = new THashMap<>(); public final String key; @@ -45,14 +44,14 @@ public abstract class ConsoleCommand { command.handle(message); return true; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } else { - LOGGER.info("Unknown Console Command " + message[0]); - LOGGER.info("Commands Available (" + commands.size() + "): "); + log.info("Unknown Console Command " + message[0]); + log.info("Commands Available (" + commands.size() + "): "); for (ConsoleCommand c : commands.values()) { - LOGGER.info(c.key + " - " + c.usage); + log.info(c.key + " - " + c.usage); } } } diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java index db7c22bf..211e8f82 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java @@ -2,13 +2,12 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.concurrent.TimeUnit; +@Slf4j public class ConsoleInfoCommand extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleInfoCommand.class); public ConsoleInfoCommand() { super("info", "Show current statistics."); @@ -22,21 +21,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); - LOGGER.info("Emulator version: " + Emulator.version); - LOGGER.info("Emulator build: " + Emulator.build); + log.info("Emulator version: " + Emulator.version); + log.info("Emulator build: " + Emulator.build); - LOGGER.info(""); + log.info(""); - 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"); + log.info("Hotel Statistics"); + log.info("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount()); + log.info("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size()); + log.info("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items."); + log.info("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items."); + log.info(""); + log.info("Server Statistics"); + log.info("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!")); + log.info("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB"); + log.info("- CPU Cores: " + Emulator.getRuntime().availableProcessors()); + log.info("- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB"); } } \ 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 587130d1..f1c31a95 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java @@ -1,11 +1,10 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.networking.camera.CameraClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ConsoleReconnectCameraCommand extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleReconnectCameraCommand.class); public ConsoleReconnectCameraCommand() { super("camera", "Attempt to reconnect to the camera server."); @@ -13,7 +12,7 @@ public class ConsoleReconnectCameraCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { - LOGGER.info("Connecting to the camera..."); + log.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 cd02b90c..374109c4 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java @@ -3,11 +3,10 @@ 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; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ConsoleTestCommand extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleTestCommand.class); public ConsoleTestCommand() { super("test", "This is just a test."); @@ -16,7 +15,7 @@ public class ConsoleTestCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { if (Emulator.debugging) { - LOGGER.info("This is a test command for live debugging."); + log.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 e8487a92..14400e12 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java @@ -1,11 +1,10 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ShowInteractionsCommand extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ShowInteractionsCommand.class); public ShowInteractionsCommand() { super("interactions", "Show a list of available furniture interactions."); @@ -14,7 +13,7 @@ public class ShowInteractionsCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) { - LOGGER.info(interaction); + log.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 821d2f1f..4da7f13f 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java @@ -1,11 +1,10 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ShowRCONCommands extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ShowRCONCommands.class); public ShowRCONCommands() { super("rconcommands", "Show a list of all RCON commands"); @@ -14,7 +13,7 @@ public class ShowRCONCommands extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String command : Emulator.getRconServer().getCommands()) { - LOGGER.info(command); + log.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 index 64378af5..761cae5b 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java @@ -1,11 +1,10 @@ package com.eu.habbo.core.consolecommands; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ThankyouArcturusCommand extends ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ThankyouArcturusCommand.class); public ThankyouArcturusCommand() { super("thankyou", "A thankyou message."); @@ -13,31 +12,31 @@ public class ThankyouArcturusCommand extends ConsoleCommand { @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."); + log.info("Arcturus Morningstar is an opensource community fork of Arcturus Emulator by TheGeneral"); + log.info("Thankyou to the following people who have helped with it's development:"); + log.info("TheGeneral - For Creating Arcturus."); + log.info("Capheus - Decompilation"); + log.info("Beny - Lead Developer"); + log.info("Alejandro - Lead Developer"); + log.info("Harmonic - Developer"); + log.info("ArpyAge - Developer"); + log.info("Mike - Developer"); + log.info("Skeletor - Developer"); + log.info("zGrav - Developer"); + log.info("Swirny - Developer"); + log.info("Quadral - Developer"); + log.info("Dome - Developer"); + log.info("Necmi - Developer"); + log.info("Oliver - Support"); + log.info("Rasmus - Support"); + log.info("Layne - Support"); + log.info("Bill - Support"); + log.info("Harmony - Support"); + log.info("Ridge - Catalogue"); + log.info("Tenshie - Catalogue"); + log.info("Wulles - Catalogue"); + log.info("Gizmo - Catalogue"); + log.info("TheJava - Motivation"); + log.info("The Entire Krews.org Community."); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java index f9db196d..50790239 100644 --- a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java +++ b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java @@ -83,7 +83,7 @@ public class HabboDiffieHellman { this.DHPrime = decryptBigInteger(signedPrime); this.DHGenerator = decryptBigInteger(signedGenerator); - if (this.DHPrime == null || this.DHGenerator == null) { + if (this.DHPrime == null) { throw new HabboCryptoException("DHPrime or DHGenerator was null."); } diff --git a/src/main/java/com/eu/habbo/database/Database.java b/src/main/java/com/eu/habbo/database/Database.java index 00be0fee..f6067ade 100644 --- a/src/main/java/com/eu/habbo/database/Database.java +++ b/src/main/java/com/eu/habbo/database/Database.java @@ -5,8 +5,7 @@ import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariDataSource; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,10 +14,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +@Slf4j public class Database { - - private static final Logger LOGGER = LoggerFactory.getLogger(Database.class); - private HikariDataSource dataSource; private DatabasePool databasePool; @@ -30,21 +27,21 @@ public class Database { try { this.databasePool = new DatabasePool(); if (!this.databasePool.getStoragePooling(config)) { - LOGGER.info("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down..."); + log.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; - LOGGER.error("Failed to connect to your database.", e); + log.error("Failed to connect to your database.", e); } finally { if (SQLException) { Emulator.prepareShutdown(); } } - LOGGER.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis); + log.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis); } public void dispose() { @@ -64,7 +61,7 @@ public class Database { } public static PreparedStatement preparedStatementWithParams(Connection connection, String query, THashMap queryParams) throws SQLException { - THashMap params = new THashMap(); + THashMap params = new THashMap<>(); THashSet quotedParams = new THashSet<>(); for(String key : queryParams.keySet()) { diff --git a/src/main/java/com/eu/habbo/database/DatabasePool.java b/src/main/java/com/eu/habbo/database/DatabasePool.java index 9a33ba29..399134d1 100644 --- a/src/main/java/com/eu/habbo/database/DatabasePool.java +++ b/src/main/java/com/eu/habbo/database/DatabasePool.java @@ -3,11 +3,8 @@ package com.eu.habbo.database; import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; class DatabasePool { - private final Logger log = LoggerFactory.getLogger(DatabasePool.class); private HikariDataSource database; public boolean getStoragePooling(ConfigurationManager config) { diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index ba201e53..f79bbf98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -1,7 +1,10 @@ package com.eu.habbo.habbohotel; import com.eu.habbo.Emulator; -import com.eu.habbo.core.*; +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.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.campaign.CalendarManager; @@ -23,18 +26,17 @@ import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionScheduler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@Getter public class GameEnvironment { - - private static final Logger LOGGER = LoggerFactory.getLogger(GameEnvironment.class); - - public CreditsScheduler creditsScheduler; - public PixelScheduler pixelScheduler; - public PointsScheduler pointsScheduler; - public GotwPointsScheduler gotwPointsScheduler; - public SubscriptionScheduler subscriptionScheduler; + private CreditsScheduler creditsScheduler; + private PixelScheduler pixelScheduler; + private PointsScheduler pointsScheduler; + private GotwPointsScheduler gotwPointsScheduler; + private SubscriptionScheduler subscriptionScheduler; private HabboManager habboManager; private NavigatorManager navigatorManager; @@ -58,7 +60,7 @@ public class GameEnvironment { private CalendarManager calendarManager; public void load() throws Exception { - LOGGER.info("GameEnvironment -> Loading..."); + log.info("GameEnvironment -> Loading..."); this.permissionsManager = new PermissionsManager(); this.habboManager = new HabboManager(); @@ -100,7 +102,7 @@ public class GameEnvironment { this.subscriptionScheduler = new SubscriptionScheduler(); Emulator.getThreading().run(this.subscriptionScheduler); - LOGGER.info("GameEnvironment -> Loaded!"); + log.info("GameEnvironment -> Loaded!"); } public void dispose() { @@ -118,98 +120,7 @@ public class GameEnvironment { this.hotelViewManager.dispose(); this.subscriptionManager.dispose(); this.calendarManager.dispose(); - LOGGER.info("GameEnvironment -> Disposed!"); + log.info("GameEnvironment -> Disposed!"); } - public HabboManager getHabboManager() { - return this.habboManager; - } - - public NavigatorManager getNavigatorManager() { - return this.navigatorManager; - } - - public GuildManager getGuildManager() { - return this.guildManager; - } - - public ItemManager getItemManager() { - return this.itemManager; - } - - public CatalogManager getCatalogManager() { - return this.catalogManager; - } - - public HotelViewManager getHotelViewManager() { - return this.hotelViewManager; - } - - public RoomManager getRoomManager() { - return this.roomManager; - } - - public CommandHandler getCommandHandler() { - return this.commandHandler; - } - - public PermissionsManager getPermissionsManager() { - return this.permissionsManager; - } - - public BotManager getBotManager() { - return this.botManager; - } - - public ModToolManager getModToolManager() { - return this.modToolManager; - } - - public ModToolSanctions getModToolSanctions() { - return this.modToolSanctions; - } - - public PetManager getPetManager() { - return this.petManager; - } - - public AchievementManager getAchievementManager() { - return this.achievementManager; - } - - public GuideManager getGuideManager() { - return this.guideManager; - } - - public WordFilter getWordFilter() { - return this.wordFilter; - } - - public CraftingManager getCraftingManager() { - return this.craftingManager; - } - - public PollManager getPollManager() { - return this.pollManager; - } - - public CreditsScheduler getCreditsScheduler() { - return this.creditsScheduler; - } - - public PixelScheduler getPixelScheduler() { - return this.pixelScheduler; - } - - public PointsScheduler getPointsScheduler() { return this.pointsScheduler; - } - - public GotwPointsScheduler getGotwPointsScheduler() { return this.gotwPointsScheduler; - } - - public SubscriptionManager getSubscriptionManager() { - return this.subscriptionManager; - } - - public CalendarManager getCalendarManager() { return this.calendarManager; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java b/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java index dcf34c16..1e16f29b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java @@ -32,7 +32,7 @@ public class Achievement { public void addLevel(AchievementLevel level) { synchronized (this.levels) { - this.levels.put(level.level, level); + this.levels.put(level.getLevel(), level); } } @@ -41,9 +41,9 @@ public class Achievement { AchievementLevel l = null; if (progress > 0) { for (AchievementLevel level : this.levels.values()) { - if (progress >= level.progress) { + if (progress >= level.getProgress()) { if (l != null) { - if (l.level > level.level) { + if (l.getLevel() > level.getLevel()) { continue; } } @@ -60,7 +60,7 @@ public class Achievement { AchievementLevel l = null; for (AchievementLevel level : this.levels.values()) { - if (level.level == (currentLevel + 1)) + if (level.getLevel() == (currentLevel + 1)) return level; } diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java index 28868aa7..53213677 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java @@ -1,23 +1,20 @@ package com.eu.habbo.habbohotel.achievements; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@Getter public class AchievementLevel { - public final int level; + private final int level; + private final int rewardAmount; + private final int rewardType; + private final int points; - public final int rewardAmount; - - - public final int rewardType; - - - public final int points; - - - public final int progress; + private final int progress; public AchievementLevel(ResultSet set) throws SQLException { this.level = set.getInt("level"); 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 75a0ca63..001585cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.achievements.AchievementComposer; import com.eu.habbo.messages.outgoing.achievements.AchievementUnlockedComposer; import com.eu.habbo.messages.outgoing.achievements.talenttrack.TalentLevelUpComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import com.eu.habbo.messages.outgoing.users.UserBadgesComposer; @@ -18,16 +18,14 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.LinkedHashMap; import java.util.Map; +@Slf4j public class AchievementManager { - private static final Logger LOGGER = LoggerFactory.getLogger(AchievementManager.class); - public static boolean TALENTTRACK_ENABLED = false; private final THashMap achievements; @@ -59,7 +57,7 @@ public class AchievementManager { statement.setInt(4, amount); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -97,7 +95,7 @@ public class AchievementManager { AchievementLevel oldLevel = achievement.getLevelForProgress(currentProgress); - if (oldLevel != null && (oldLevel.level == achievement.levels.size() && currentProgress >= oldLevel.progress)) //Maximum achievement gotten. + if (oldLevel != null && (oldLevel.getLevel() == achievement.levels.size() && currentProgress >= oldLevel.getProgress())) //Maximum achievement gotten. return; habbo.getHabboStats().setProgress(achievement, currentProgress + amount); @@ -109,7 +107,7 @@ public class AchievementManager { if (Emulator.getGameEnvironment().getAchievementManager().talentTrackLevels.containsKey(type)) { for (Map.Entry entry : Emulator.getGameEnvironment().getAchievementManager().talentTrackLevels.get(type).entrySet()) { if (entry.getValue().achievements.containsKey(achievement)) { - Emulator.getGameEnvironment().getAchievementManager().handleTalentTrackAchievement(habbo, type, achievement); + Emulator.getGameEnvironment().getAchievementManager().handleTalentTrackAchievement(habbo, type); break; } } @@ -118,7 +116,7 @@ public class AchievementManager { } if (newLevel == null || - (oldLevel != null && (oldLevel.level == newLevel.level && newLevel.level < achievement.levels.size()))) { + (oldLevel != null && (oldLevel.getLevel() == newLevel.getLevel() && newLevel.getLevel() < achievement.levels.size()))) { habbo.getClient().sendResponse(new AchievementComposer(habbo, achievement)); } else { if (Emulator.getPluginManager().isRegistered(UserAchievementLeveledEvent.class, true)) { @@ -139,14 +137,14 @@ public class AchievementManager { if (oldLevel != null) { try { - badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase()); + badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.getLevel()).toLowerCase()); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return; } } - String newBadgCode = "ACH_" + achievement.name + newLevel.level; + String newBadgCode = "ACH_" + achievement.name + newLevel.getLevel(); if (badge != null) { badge.setCode(newBadgCode); @@ -173,10 +171,10 @@ public class AchievementManager { habbo.getClient().sendResponse(new UnseenItemsComposer(badge.getId(), UnseenItemsComposer.AddHabboItemCategory.BADGE)); - habbo.getHabboStats().addAchievementScore(newLevel.points); + habbo.getHabboStats().addAchievementScore(newLevel.getPoints()); - if (newLevel.rewardAmount > 0) { - habbo.givePoints(newLevel.rewardType, newLevel.rewardAmount); + if (newLevel.getRewardAmount() > 0) { + habbo.givePoints(newLevel.getRewardType(), newLevel.getRewardAmount()); } if (habbo.getHabboInfo().getCurrentRoom() != null) { @@ -197,9 +195,9 @@ public class AchievementManager { if (level == null) return false; - AchievementLevel nextLevel = achievement.levels.get(level.level + 1); + AchievementLevel nextLevel = achievement.levels.get(level.getLevel() + 1); - return nextLevel == null && currentProgress >= level.progress; + return nextLevel == null && currentProgress >= level.getProgress(); } public static void createUserEntry(Habbo habbo, Achievement achievement) { @@ -209,7 +207,7 @@ public class AchievementManager { statement.setInt(3, 1); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -223,7 +221,7 @@ public class AchievementManager { } statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -237,7 +235,7 @@ public class AchievementManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return 0; @@ -260,9 +258,9 @@ public class AchievementManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } @@ -282,13 +280,13 @@ public class AchievementManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - LOGGER.error("Achievement Manager -> Failed to load!"); + log.error("Caught SQL exception", e); + log.error("Achievement Manager -> Failed to load!"); return; } } - LOGGER.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public Achievement getAchievement(String name) { @@ -343,7 +341,7 @@ public class AchievementManager { return level; } - public void handleTalentTrackAchievement(Habbo habbo, TalentTrackType type, Achievement achievement) { + public void handleTalentTrackAchievement(Habbo habbo, TalentTrackType type) { TalentTrackLevel currentLevel = this.calculateTalenTrackLevel(habbo, type); if (currentLevel != null) { @@ -375,7 +373,8 @@ public class AchievementManager { if (level.perks != null && level.perks.length > 0) { for (String perk : level.perks) { if (perk.equalsIgnoreCase("TRADE")) { - habbo.getHabboStats().perkTrade = true; + habbo.getHabboStats().setPerkTrade(true); + break; } } } 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 e491523f..1a8739ad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java @@ -5,15 +5,13 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class TalentTrackLevel { - private static final Logger LOGGER = LoggerFactory.getLogger(TalentTrackLevel.class); - public TalentTrackType type; public int level; public TObjectIntMap achievements; @@ -34,23 +32,23 @@ public class TalentTrackLevel { if (achievements[i].isEmpty() || achievementLevels[i].isEmpty()) continue; - Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(Integer.valueOf(achievements[i])); + Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(Integer.parseInt(achievements[i])); if (achievement != null) { - this.achievements.put(achievement, Integer.valueOf(achievementLevels[i])); + this.achievements.put(achievement, Integer.parseInt(achievementLevels[i])); } else { - LOGGER.error("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type); + log.error("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type); } } } for (String s : set.getString("reward_furni").split(",")) { - Item item = Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(s)); + Item item = Emulator.getGameEnvironment().getItemManager().getItem(Integer.parseInt(s)); if (item != null) { this.items.add(item); } else { - LOGGER.error("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); + log.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 5cc1f9ea..fbda5ee7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -12,8 +12,7 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -22,9 +21,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +@Slf4j public class Bot implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class); - public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); @@ -164,7 +162,7 @@ public class Bot implements Runnable { statement.execute(); this.needsUpdate = false; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 869dc872..1c9951f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -7,26 +7,22 @@ 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.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer; -import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; +import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; 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 lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; import java.sql.*; import java.util.Map; - - - +@Slf4j public class BotManager { - private static final Logger LOGGER = LoggerFactory.getLogger(BotManager.class); final private static THashMap> botDefenitions = new THashMap<>(); public static int MINIMUM_CHAT_SPEED = 7; @@ -44,7 +40,7 @@ public class BotManager { this.reload(); - LOGGER.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addBotDefinition(String type, Class botClazz) throws Exception { @@ -59,10 +55,10 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); + log.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); return false; } catch (Exception e) { - LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + log.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); return false; } } @@ -89,12 +85,12 @@ public class BotManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return bot; @@ -114,10 +110,10 @@ public class BotManager { return; } - if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY)) + if (room.hasHabbosAt(location.getX(), location.getY()) || (!location.isWalkable() && location.getState() != RoomTileState.SIT && location.getState() != RoomTileState.LAY)) return; - if (room.hasBotsAt(location.x, location.y)) { + if (room.hasBotsAt(location.getX(), location.getY())) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); return; } @@ -144,19 +140,19 @@ public class BotManager { habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); bot.onPlace(habbo, room); - HabboItem topItem = room.getTopItemAt(location.x, location.y); + HabboItem topItem = room.getTopItemAt(location.getX(), location.getY()); if (topItem != null) { try { topItem.onWalkOn(bot.getRoomUnit(), room, null); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } bot.cycle(false); } else { - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); } } } @@ -208,25 +204,23 @@ public class BotManager { if (botClazz != null) return botClazz.getDeclaredConstructor(ResultSet.class).newInstance(set); else - LOGGER.error("Unknown Bot Type: " + type); + log.error("Unknown Bot Type: " + type); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; } - public boolean deleteBot(Bot bot) { + public void deleteBot(Bot bot) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM bots WHERE id = ? LIMIT 1")) { statement.setInt(1, bot.getId()); - return statement.execute(); + statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - - return false; } public void dispose() { @@ -236,9 +230,9 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); + log.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); } catch (Exception e) { - LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + log.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 b5acb9f2..84d979ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -10,8 +10,7 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.ResultSet; @@ -22,8 +21,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; +@Slf4j public class ButlerBot extends Bot { - private static final Logger LOGGER = LoggerFactory.getLogger(ButlerBot.class); public static THashMap, Integer> serveItems = new THashMap<>(); public ButlerBot(ResultSet set) throws SQLException { @@ -48,7 +47,7 @@ public class ButlerBot extends Bot { serveItems.put(ks, set.getInt("item")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -94,13 +93,13 @@ public class ButlerBot extends Bot { tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0)); tasks.add(() -> { - if(this.getRoom() != null) { + if (this.getRoom() != null) { String botMessage = Emulator.getTexts() .getValue("bots.butler.given") .replace("%key%", key) .replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()); - if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{ botMessage })) { + if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{botMessage})) { bot.talk(botMessage); } } @@ -124,7 +123,7 @@ public class ButlerBot extends Bot { Emulator.getThreading().run(failedReached.get(0), 1000); } } else { - if(this.getRoom() != null) { + if (this.getRoom() != null) { this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId); String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()); 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 bf160161..130ff3b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java @@ -39,9 +39,9 @@ public class VisitorBot extends Bot { StringBuilder list = new StringBuilder(); for (ModToolRoomVisit visit : this.visits) { list.append("\r"); - list.append(visit.roomName).append(" "); + list.append(visit.getRoomName()).append(" "); list.append(Emulator.getTexts().getValue("generic.time.at")).append(" "); - list.append(DATE_FORMAT.format(new Date((visit.timestamp * 1000L)))); + list.append(DATE_FORMAT.format(new Date((visit.getTimestamp() * 1000L)))); } visitMessage = visitMessage.replace("%list%", list.toString()); diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java index cf0beded..025db31e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.events.calendar.CampaignCalendarDoorOpenedMessageComposer; import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.time.temporal.ChronoUnit; @@ -14,8 +13,9 @@ import java.util.Date; import java.util.*; + +@Slf4j public class CalendarManager { - private static final Logger LOGGER = LoggerFactory.getLogger(CalendarManager.class); private static final Map calendarCampaigns = new THashMap<>(); public static double HC_MODIFIER; @@ -23,7 +23,7 @@ public class CalendarManager { public CalendarManager() { long millis = System.currentTimeMillis(); this.reload(); - LOGGER.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); + log.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); } public void dispose() { @@ -39,7 +39,7 @@ public class CalendarManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return false; } @@ -53,7 +53,7 @@ public class CalendarManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return false; } @@ -84,7 +84,7 @@ public class CalendarManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } calendarCampaigns.put(campaign.getId(), campaign); @@ -97,7 +97,7 @@ public class CalendarManager { statement.setInt(1, campaign.getId()); return statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -113,7 +113,7 @@ public class CalendarManager { public void claimCalendarReward(Habbo habbo, String campaignName, int day, boolean force) { CalendarCampaign campaign = calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null); - if (campaign == null || campaign.getRewards().isEmpty() || (habbo.getHabboStats().calendarRewardsClaimed.stream().anyMatch(claimed -> claimed.getCampaignId() == campaign.getId() && claimed.getDay() == day))) + if (campaign == null || campaign.getRewards().isEmpty() || (habbo.getHabboStats().getCalendarRewardsClaimed().stream().anyMatch(claimed -> claimed.getCampaignId() == campaign.getId() && claimed.getDay() == day))) return; List rewards = new ArrayList<>(campaign.getRewards().values()); @@ -125,7 +125,7 @@ public class CalendarManager { if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) { return; } - habbo.getHabboStats().calendarRewardsClaimed.add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis()))); + habbo.getHabboStats().getCalendarRewardsClaimed().add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis()))); habbo.getClient().sendResponse(new CampaignCalendarDoorOpenedMessageComposer(true, object, habbo)); object.give(habbo); @@ -137,7 +137,7 @@ public class CalendarManager { statement.setInt(5, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardClaimed.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardClaimed.java index 96f0c0d9..e136d339 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardClaimed.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardClaimed.java @@ -1,50 +1,26 @@ package com.eu.habbo.habbohotel.campaign; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +@Getter +@AllArgsConstructor public class CalendarRewardClaimed { - private final int user_id; - private final int campaign; + private final int userId; + private final int campaignId; private final int day; - private final int reward_id; + private final int rewardId; private final Timestamp timestamp; public CalendarRewardClaimed(ResultSet set) throws SQLException { - this.user_id = set.getInt("user_id"); - this.campaign = set.getInt("campaign_id"); + this.userId = set.getInt("user_id"); + this.campaignId = set.getInt("campaign_id"); this.day = set.getInt("day"); - this.reward_id = set.getInt("reward_id"); + this.rewardId = set.getInt("reward_id"); this.timestamp = new Timestamp(set.getInt("timestamp") * 1000L); } - - public CalendarRewardClaimed(int user_id, int campaign, int day, int reward_id, Timestamp timestamp) { - this.user_id = user_id; - this.campaign = campaign; - this.day = day; - this.reward_id = reward_id; - this.timestamp = timestamp; - } - - public int getUserId() { - return this.user_id; - } - - public int getCampaignId() { - return this.campaign; - } - - public int getDay() { - return this.day; - } - - public int getRewardId() { - return this.reward_id; - } - - public Timestamp getTimestamp() { - return this.timestamp; - } - } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java index 90f92e6b..d8b74fa3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java @@ -5,17 +5,17 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter public class CalendarRewardObject { - private static final Logger LOGGER = LoggerFactory.getLogger(CalendarRewardObject.class); - private final int id; private final String productName; private final String customImage; @@ -25,8 +25,8 @@ public class CalendarRewardObject { private final int pointsType; private final String badge; private final int itemId; - private final String subscription_type; - private final int subscription_days; + private final String subscriptionType; + private final int subscriptionDays; public CalendarRewardObject(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -38,8 +38,8 @@ public class CalendarRewardObject { this.pointsType = set.getInt("points_type"); this.badge = set.getString("badge"); this.itemId = set.getInt("item_id"); - this.subscription_type = set.getString("subscription_type"); - this.subscription_days = set.getInt("subscription_days"); + this.subscriptionType = set.getString("subscription_type"); + this.subscriptionDays = set.getInt("subscription_days"); } public void give(Habbo habbo) { @@ -48,7 +48,7 @@ public class CalendarRewardObject { } if (this.pixels > 0) { - habbo.givePixels((int)(this.pixels * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0))); + habbo.givePixels((int) (this.pixels * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0))); } if (this.points > 0) { @@ -59,11 +59,11 @@ public class CalendarRewardObject { habbo.addBadge(this.badge); } - if(this.subscription_type != null && !this.subscription_type.isEmpty()) { - if ("HABBO_CLUB".equals(this.subscription_type)) { - habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, this.subscription_days * 86400); + if (this.subscriptionType != null && !this.subscriptionType.isEmpty()) { + if ("HABBO_CLUB".equals(this.subscriptionType)) { + habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, this.subscriptionDays * 86400); } else { - habbo.getHabboStats().createSubscription(this.subscription_type, this.subscription_days * 86400); + habbo.getHabboStats().createSubscription(this.subscriptionType, this.subscriptionDays * 86400); } } @@ -84,44 +84,6 @@ public class CalendarRewardObject { } } - public int getId() { - return this.id; - } - - public String getCustomImage() { - return this.customImage; - } - - public int getCredits() { - return this.credits; - } - - public int getPixels() { - return this.pixels; - } - public int getPoints() { - return this.points; - } - - public int getPointsType() { - return this.pointsType; - } - - public String getProductName() { - return productName; - } - - public String getSubscriptionType() { - return subscription_type; - } - - public int getSubscriptionDays() { - return subscription_days; - } - - public String getBadge() { - return this.badge; - } public Item getItem() { return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java index 30da0eb1..916ef68a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java @@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor public class CatalogFeaturedPage implements ISerialize { private final int slotId; private final String caption; @@ -13,16 +16,6 @@ public class CatalogFeaturedPage implements ISerialize { private final String pageName; private final int pageId; private final String productName; - public CatalogFeaturedPage(int slotId, String caption, String image, Type type, int expireTimestamp, String pageName, int pageId, String productName) { - this.slotId = slotId; - this.caption = caption; - this.image = image; - this.type = type; - this.expireTimestamp = expireTimestamp; - this.pageName = pageName; - this.pageId = pageId; - this.productName = productName; - } @Override public void serialize(ServerMessage message) { @@ -31,28 +24,20 @@ public class CatalogFeaturedPage implements ISerialize { message.appendString(this.image); message.appendInt(this.type.type); switch (this.type) { - case PAGE_NAME: - message.appendString(this.pageName); - break; - case PAGE_ID: - message.appendInt(this.pageId); - break; - case PRODUCT_NAME: - message.appendString(this.productName); - break; + case PAGE_NAME -> message.appendString(this.pageName); + case PAGE_ID -> message.appendInt(this.pageId); + case PRODUCT_NAME -> message.appendString(this.productName); } message.appendInt(Emulator.getIntUnixTimestamp() - this.expireTimestamp); } + @Getter + @AllArgsConstructor public enum Type { PAGE_NAME(0), PAGE_ID(1), PRODUCT_NAME(2); - public final int type; - - Type(int type) { - this.type = type; - } + private final int type; } } \ No newline at end of file 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 c8d015e6..d2557cf1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -3,12 +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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,41 +16,54 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +@Slf4j public class CatalogItem implements ISerialize, Runnable, Comparable { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogItem.class); + + @Getter int id; + @Getter int limitedStack; + @Getter + @Setter private int pageId; + @Getter + @Setter private String itemId; + @Getter private String name; + @Getter private int credits; + @Getter private int points; + @Getter private short pointsType; + @Getter private int amount; private boolean allowGift = false; private int limitedSells; - + @Getter private String extradata; - + @Getter private boolean clubOnly; private boolean haveOffer; - + @Getter private int offerId; private boolean needsUpdate; - + @Getter private int orderNumber; - + @Getter private HashMap bundle; + public CatalogItem(ResultSet set) throws SQLException { this.load(set); this.needsUpdate = false; @@ -105,49 +118,6 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0; - } - - private int getOrderNumber() { - return this.orderNumber; - } public synchronized void sellRare() { this.limitedSells++; @@ -214,7 +161,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0) { @@ -236,9 +183,6 @@ public class CatalogItem implements ISerialize, Runnable, Comparable getBundle() { - return this.bundle; - } public void loadBundle() { int intItemId; @@ -261,17 +205,17 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0; + } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java index 1cf3e3ef..18ce8684 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,11 +14,12 @@ import java.util.Collections; import java.util.LinkedList; import java.util.concurrent.LinkedBlockingQueue; +@Slf4j public class CatalogLimitedConfiguration implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogLimitedConfiguration.class); - private final int itemId; private LinkedBlockingQueue limitedNumbers; + @Getter + @Setter private int totalSet; private final Object lock = new Object(); @@ -61,7 +63,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(5, item.getLimitedSells()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -80,7 +82,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.totalSet += amount; @@ -100,13 +102,6 @@ public class CatalogLimitedConfiguration implements Runnable { return this.limitedNumbers.size(); } - public int getTotalSet() { - return this.totalSet; - } - - public void setTotalSet(int totalSet) { - this.totalSet = totalSet; - } @Override public void run() { @@ -116,7 +111,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(3, this.itemId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 b3aaee97..4a0d542e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -18,12 +18,12 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.catalog.*; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; -import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.modtool.IssueCloseNotificationMessageComposer; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; @@ -37,19 +37,16 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.*; import java.util.stream.Collectors; +@Slf4j public class CatalogManager { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogManager.class); - public static final THashMap> pageDefinitions = new THashMap<>(); public static int catalogItemAmount; public static int PURCHASE_COOLDOWN = 1; @@ -86,7 +83,7 @@ public class CatalogManager { this.ecotronItem = Emulator.getGameEnvironment().getItemManager().getItem("ecotron_box"); - LOGGER.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -258,7 +255,7 @@ public class CatalogManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } for (Map.Entry> set : limiteds.entrySet()) { @@ -278,7 +275,7 @@ public class CatalogManager { Class pageClazz = pageDefinitions.get(set.getString("page_layout")); if (pageClazz == null) { - LOGGER.info("Unknown Page Layout: " + set.getString("page_layout")); + log.info("Unknown Page Layout: " + set.getString("page_layout")); continue; } @@ -286,12 +283,12 @@ public class CatalogManager { CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set); pages.put(page.getId(), page); } catch (Exception e) { - LOGGER.error("Failed to load layout: {}", set.getString("page_layout")); + log.error("Failed to load layout: {}", set.getString("page_layout")); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } pages.forEachValue((object) -> { @@ -303,7 +300,7 @@ public class CatalogManager { } } else { if (object.parentId != -2) { - LOGGER.info("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); + log.info("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); } } return true; @@ -311,7 +308,7 @@ public class CatalogManager { this.catalogPages.putAll(pages); - LOGGER.info("Loaded " + this.catalogPages.size() + " Catalog Pages!"); + log.info("Loaded " + this.catalogPages.size() + " Catalog Pages!"); } @@ -332,7 +329,7 @@ public class CatalogManager { )); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -379,7 +376,7 @@ public class CatalogManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } for (CatalogPage page : this.catalogPages.valueCollection()) { @@ -404,7 +401,7 @@ public class CatalogManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -420,7 +417,7 @@ public class CatalogManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -435,7 +432,7 @@ public class CatalogManager { this.vouchers.add(new Voucher(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -455,11 +452,11 @@ public class CatalogManager { this.prizes.get(set.getInt("rarity")).add(item); } else { - LOGGER.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id")); + log.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id")); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -474,17 +471,12 @@ public class CatalogManager { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM gift_wrappers ORDER BY sprite_id DESC")) { while (set.next()) { switch (set.getString("type")) { - case "wrapper": - this.giftWrappers.put(set.getInt("sprite_id"), set.getInt("item_id")); - break; - - case "gift": - this.giftFurnis.put(set.getInt("sprite_id"), set.getInt("item_id")); - break; + case "wrapper" -> this.giftWrappers.put(set.getInt("sprite_id"), set.getInt("item_id")); + case "gift" -> this.giftFurnis.put(set.getInt("sprite_id"), set.getInt("item_id")); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -499,14 +491,14 @@ public class CatalogManager { this.clothing.put(set.getInt("id"), new ClothItem(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } public ClothItem getClothing(String name) { for (ClothItem item : this.clothing.values()) { - if (item.name.equalsIgnoreCase(name)) { + if (item.getName().equalsIgnoreCase(name)) { return item; } } @@ -517,7 +509,7 @@ public class CatalogManager { public Voucher getVoucher(String code) { synchronized (this.vouchers) { for (Voucher voucher : this.vouchers) { - if (voucher.code.equals(code)) { + if (voucher.getCode().equals(code)) { return voucher; } } @@ -548,18 +540,18 @@ public class CatalogManager { voucher.addHistoryEntry(habbo.getHabboInfo().getId()); - if (voucher.points > 0) { - client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); - client.sendResponse(new HabboActivityPointNotificationMessageComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType)); + if (voucher.getPoints() > 0) { + client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.getPointsType(), voucher.getPoints()); + client.sendResponse(new HabboActivityPointNotificationMessageComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.getPointsType()), voucher.getPoints(), voucher.getPointsType())); } - if (voucher.credits > 0) { - client.getHabbo().getHabboInfo().addCredits(voucher.credits); + if (voucher.getCredits() > 0) { + client.getHabbo().getHabboInfo().addCredits(voucher.getCredits()); client.sendResponse(new CreditBalanceComposer(client.getHabbo())); } - if (voucher.catalogItemId > 0) { - CatalogItem item = this.getCatalogItem(voucher.catalogItemId); + if (voucher.getCatalogItemId() > 0) { + CatalogItem item = this.getCatalogItem(voucher.getCatalogItemId()); if (item != null) { this.purchaseItem(null, item, client.getHabbo(), 1, "", true); } @@ -570,7 +562,7 @@ public class CatalogManager { public boolean deleteVoucher(Voucher voucher) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM vouchers WHERE code = ?")) { - statement.setString(1, voucher.code); + statement.setString(1, voucher.getCode()); synchronized (this.vouchers) { this.vouchers.remove(voucher); @@ -578,7 +570,7 @@ public class CatalogManager { return statement.executeUpdate() >= 1; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -609,13 +601,10 @@ public class CatalogManager { public CatalogItem getCatalogItem(int id) { final CatalogItem[] item = {null}; synchronized (this.catalogPages) { - this.catalogPages.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogPage object) { - item[0] = object.getCatalogItem(id); + this.catalogPages.forEachValue(object -> { + item[0] = object.getCatalogItem(id); - return item[0] == null; - } + return item[0] == null; }); } @@ -626,24 +615,17 @@ public class CatalogManager { public List getCatalogPages(int parentId, final Habbo habbo) { final List pages = new ArrayList<>(); - this.catalogPages.get(parentId).childPages.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogPage object) { + this.catalogPages.get(parentId).childPages.forEachValue(object -> { - boolean isVisiblePage = object.visible; - boolean hasRightRank = object.getRank() <= habbo.getHabboInfo().getRank().getId(); + boolean isVisiblePage = object.visible; + boolean hasRightRank = object.getRank() <= habbo.getHabboInfo().getRank().getId(); - boolean clubRightsOkay = true; + boolean clubRightsOkay = !object.isClubOnly() || habbo.getHabboInfo().getHabboStats().hasActiveClub(); - if(object.isClubOnly() && !habbo.getHabboInfo().getHabboStats().hasActiveClub()) { - clubRightsOkay = false; - } - - if (isVisiblePage && hasRightRank && clubRightsOkay) { - pages.add(object); - } - return true; + if (isVisiblePage && hasRightRank && clubRightsOkay) { + pages.add(object); } + return true; }); Collections.sort(pages); @@ -702,7 +684,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 { - LOGGER.error("No rewards specified for rarity level {}", level); + log.error("No rewards specified for rarity level {}", level); } return null; @@ -734,10 +716,10 @@ public class CatalogManager { try { catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } else { - LOGGER.error("Unknown page layout: {}", page.getString("page_layout")); + log.error("Unknown page layout: {}", page.getString("page_layout")); } } } @@ -745,7 +727,7 @@ public class CatalogManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } if (catalogPage != null) { @@ -804,19 +786,19 @@ public class CatalogManager { } } - LOGGER.info("Catalog Manager -> Disposed!"); + log.info("Catalog Manager -> Disposed!"); } public void purchaseItem(CatalogPage page, CatalogItem item, Habbo habbo, int amount, String extradata, boolean free) { - Item cBaseItem = null; + Item cBaseItem = null; - if (item == null || habbo.getHabboStats().isPurchasingFurniture) { + if (item == null || habbo.getHabboStats().isPurchasingFurniture()) { habbo.getClient().sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose()); return; } - habbo.getHabboStats().isPurchasingFurniture = true; + habbo.getHabboStats().setPurchasingFurniture(true); try { if (item.isClubOnly() && !habbo.getClient().getHabbo().getHabboStats().hasActiveClub()) { @@ -873,7 +855,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); - LOGGER.info(message); + log.info(message); habbo.getClient().sendResponse(new PurchaseNotAllowedMessageComposer(PurchaseNotAllowedMessageComposer.ILLEGAL)); return; } @@ -958,7 +940,7 @@ public class CatalogManager { try { pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient()); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); habbo.getClient().sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); } @@ -996,7 +978,7 @@ public class CatalogManager { if (extradata.length() > Emulator.getConfig().getInt("hotel.trophies.length.max", 300)) { extradata = extradata.substring(0, Emulator.getConfig().getInt("hotel.trophies.length.max", 300)); } - + extradata = habbo.getClient().getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + Emulator.getGameEnvironment().getWordFilter().filter(extradata.replace(((char) 9) + "", ""), habbo); } @@ -1017,7 +999,7 @@ public class CatalogManager { try { guildId = Integer.parseInt(extradata); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); habbo.getClient().sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -1034,7 +1016,7 @@ public class CatalogManager { itemsList.add(habboItem); if (baseItem.getName().equals("guild_forum")) { - guild.setForum(true); + guild.setHasForum(true); guild.needsUpdate = true; guild.run(); } @@ -1111,7 +1093,7 @@ public class CatalogManager { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); + habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys)); unseenItems.get(UnseenItemsComposer.AddHabboItemCategory.BADGE).add(badge.getId()); } habbo.getClient().getHabbo().getHabboStats().addPurchase(purchasedEvent.catalogItem); @@ -1123,11 +1105,11 @@ public class CatalogManager { THashSet itemIds = new THashSet<>(); - for(HabboItem ix : purchasedEvent.itemsList) { + for (HabboItem ix : purchasedEvent.itemsList) { itemIds.add(ix.getId() + ""); } - if(!free) { + if (!free) { Emulator.getThreading().run(new CatalogPurchaseLogEntry( Emulator.getIntUnixTimestamp(), purchasedEvent.habbo.getHabboInfo().getId(), @@ -1136,17 +1118,17 @@ public class CatalogManager { purchasedEvent.catalogItem != null ? purchasedEvent.catalogItem.getName() : "", purchasedEvent.totalCredits, purchasedEvent.totalPoints, - item != null ? item.getPointsType() : 0, + item.getPointsType(), amount )); } } catch (Exception e) { - LOGGER.error("Exception caught", e); + log.error("Exception caught", e); habbo.getClient().sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); } } finally { - habbo.getHabboStats().isPurchasingFurniture = false; + habbo.getHabboStats().setPurchasingFurniture(false); } } 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 b161c201..39ec532f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -7,38 +7,63 @@ 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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +@Slf4j public abstract class CatalogPage implements Comparable, ISerialize { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPage.class); + @Getter protected final TIntArrayList offerIds = new TIntArrayList(); + @Getter protected final THashMap childPages = new THashMap<>(); + @Getter private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + @Getter private final ArrayList included = new ArrayList<>(); + @Getter protected int id; + @Getter protected int parentId; + @Getter + @Setter protected int rank; + @Getter protected String caption; + @Getter protected String pageName; + @Getter protected int iconColor; + @Getter protected int iconImage; + @Getter protected int orderNum; + @Getter protected boolean visible; + @Getter protected boolean enabled; + @Getter protected boolean clubOnly; + @Getter protected String layout; + @Getter protected String headerImage; + @Getter protected String teaserImage; + @Getter protected String specialImage; + @Getter protected String textOne; + @Getter protected String textTwo; + @Getter protected String textDetails; + @Getter protected String textTeaser; public CatalogPage() { @@ -71,99 +96,15 @@ public abstract class CatalogPage implements Comparable, ISerialize if (!set.getString("includes").isEmpty()) { for (String id : set.getString("includes").split(";")) { try { - this.included.add(Integer.valueOf(id)); + this.included.add(Integer.parseInt(id)); } catch (Exception e) { - LOGGER.error("Caught exception", e); - LOGGER.error("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); + log.error("Caught exception", e); + log.error("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); } } } } - public int getId() { - return this.id; - } - - public int getParentId() { - return this.parentId; - } - - public int getRank() { - return this.rank; - } - - public void setRank(int rank) { - this.rank = rank; - } - - public String getCaption() { - return this.caption; - } - - public String getPageName() { - return this.pageName; - } - - public int getIconColor() { - return this.iconColor; - } - - public int getIconImage() { - return this.iconImage; - } - - public int getOrderNum() { - return this.orderNum; - } - - public boolean isVisible() { - return this.visible; - } - - public boolean isEnabled() { - return this.enabled; - } - - public boolean isClubOnly() { - return this.clubOnly; - } - - public String getLayout() { - return this.layout; - } - - public String getHeaderImage() { - return this.headerImage; - } - - public String getTeaserImage() { - return this.teaserImage; - } - - public String getSpecialImage() { - return this.specialImage; - } - - public String getTextOne() { - return this.textOne; - } - - public String getTextTwo() { - return this.textTwo; - } - - public String getTextDetails() { - return this.textDetails; - } - - public String getTextTeaser() { - return this.textTeaser; - } - - public TIntArrayList getOfferIds() { - return this.offerIds; - } - public void addOfferId(int offerId) { this.offerIds.add(offerId); } @@ -172,22 +113,10 @@ public abstract class CatalogPage implements Comparable, ISerialize this.catalogItems.put(item.getId(), item); } - public TIntObjectMap getCatalogItems() { - return this.catalogItems; - } - public CatalogItem getCatalogItem(int id) { return this.catalogItems.get(id); } - public ArrayList getIncluded() { - return this.included; - } - - public THashMap getChildPages() { - return this.childPages; - } - public void addChildPage(CatalogPage page) { this.childPages.put(page.getId(), page); @@ -196,7 +125,6 @@ public abstract class CatalogPage implements Comparable, ISerialize } } - @SuppressWarnings("NullableProblems") @Override public int compareTo(CatalogPage page) { return this.getOrderNum() - page.getOrderNum(); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPurchaseLogEntry.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPurchaseLogEntry.java index 5f6febd7..2326c1ce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPurchaseLogEntry.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPurchaseLogEntry.java @@ -2,15 +2,16 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.core.DatabaseLoggable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor public class CatalogPurchaseLogEntry implements Runnable, DatabaseLoggable { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPurchaseLogEntry.class); private static final String QUERY = "INSERT INTO `logs_shop_purchases` (timestamp, user_id, catalog_item_id, item_ids, catalog_name, cost_credits, cost_points, points_type, amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private final int timestamp; @@ -23,18 +24,6 @@ public class CatalogPurchaseLogEntry implements Runnable, DatabaseLoggable { private final int pointsType; private final int amount; - public CatalogPurchaseLogEntry(int timestamp, int userId, int catalogItemId, String itemIds, String catalogName, int costCredits, int costPoints, int pointsType, int amount) { - this.timestamp = timestamp; - this.userId = userId; - this.catalogItemId = catalogItemId; - this.itemIds = itemIds; - this.catalogName = catalogName; - this.costCredits = costCredits; - this.costPoints = costPoints; - this.pointsType = pointsType; - this.amount = amount; - } - @Override public String getQuery() { return QUERY; diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java b/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java index c99f81d4..58104cd6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java @@ -1,26 +1,32 @@ package com.eu.habbo.habbohotel.catalog; +import lombok.Getter; +import lombok.Setter; + import java.sql.ResultSet; import java.sql.SQLException; public class ClothItem { - public int id; - - - public String name; - - - public int[] setId; + @Setter + @Getter + private int id; + @Getter + @Setter + private String name; + @Getter + @Setter + private int[] setId; public ClothItem(ResultSet set) throws SQLException { - this.id = set.getInt("id"); - this.name = set.getString("name"); + this.setId(set.getInt("id")); + this.setName(set.getString("name")); String[] parts = set.getString("setid").split(","); - this.setId = new int[parts.length]; - for (int i = 0; i < this.setId.length; i++) { - this.setId[i] = Integer.valueOf(parts[i]); + this.setSetId(new int[parts.length]); + for (int i = 0; i < this.getSetId().length; i++) { + this.getSetId()[i] = Integer.parseInt(parts[i]); } } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java index b7654416..8d65844e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,27 +12,21 @@ import java.util.TimeZone; public class ClubOffer implements ISerialize { + @Getter private final int id; - - + @Getter private final String name; - - + @Getter private final int days; - - + @Getter private final int credits; - - + @Getter private final int points; - - + @Getter private final int pointsType; - - + @Getter private final boolean vip; - - + @Getter private final boolean deal; public ClubOffer(ResultSet set) throws SQLException { @@ -45,38 +40,6 @@ public class ClubOffer implements ISerialize { this.deal = set.getString("deal").equals("1"); } - public int getId() { - return this.id; - } - - public String getName() { - return this.name; - } - - public int getDays() { - return this.days; - } - - public int getCredits() { - return this.credits; - } - - public int getPoints() { - return this.points; - } - - public int getPointsType() { - return this.pointsType; - } - - public boolean isVip() { - return this.vip; - } - - public boolean isDeal() { - return this.deal; - } - @Override public void serialize(ServerMessage message) { serialize(message, Emulator.getIntUnixTimestamp()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java index 3766c16a..c1f20844 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java @@ -4,6 +4,7 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.messages.ServerMessage; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,18 +12,31 @@ import java.sql.SQLException; public class TargetOffer { public static int ACTIVE_TARGET_OFFER_ID = 0; + @Getter private final int id; + @Getter private final int catalogItem; + @Getter private final String identifier; + @Getter private final int priceInCredits; + @Getter private final int priceInActivityPoints; + @Getter private final int activityPointsType; + @Getter private final int purchaseLimit; + @Getter private final int expirationTime; + @Getter private final String title; + @Getter private final String description; + @Getter private final String imageUrl; + @Getter private final String icon; + @Getter private final String[] vars; public TargetOffer(ResultSet set) throws SQLException { @@ -62,55 +76,4 @@ public class TargetOffer { } } - public int getId() { - return this.id; - } - - public String getIdentifier() { - return this.identifier; - } - - public int getPriceInCredits() { - return this.priceInCredits; - } - - public int getPriceInActivityPoints() { - return this.priceInActivityPoints; - } - - public int getActivityPointsType() { - return this.activityPointsType; - } - - public int getPurchaseLimit() { - return this.purchaseLimit; - } - - public int getExpirationTime() { - return this.expirationTime; - } - - public String getTitle() { - return this.title; - } - - public String getDescription() { - return this.description; - } - - public String getImageUrl() { - return this.imageUrl; - } - - public String getIcon() { - return this.icon; - } - - public String[] getVars() { - return this.vars; - } - - public int getCatalogItem() { - return this.catalogItem; - } } \ No newline at end of file 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 468e2a2b..2a0b2f59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -11,17 +11,23 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +@Slf4j public class Voucher { - private static final Logger LOGGER = LoggerFactory.getLogger(Voucher.class); - public final int id; - public final String code; - public final int credits; - public final int points; - public final int pointsType; - public final int catalogItemId; - public final int amount; - public final int limit; + + private final int id; + @Getter + private final String code; + @Getter + private final int credits; + @Getter + private final int points; + @Getter + private final int pointsType; + @Getter + private final int catalogItemId; + private final int amount; + private final int limit; private final List history = new ArrayList<>(); public Voucher(ResultSet set) throws SQLException { @@ -46,7 +52,7 @@ public class Voucher { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -69,7 +75,8 @@ public class Voucher { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java index 300c7c8f..9e69ccc1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java @@ -1,11 +1,18 @@ package com.eu.habbo.habbohotel.catalog; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@AllArgsConstructor public class VoucherHistoryEntry { + @Getter private final int voucherId; + @Getter private final int userId; + @Getter private final int timestamp; public VoucherHistoryEntry(ResultSet set) throws SQLException { @@ -14,21 +21,4 @@ public class VoucherHistoryEntry { this.timestamp = set.getInt("timestamp"); } - public VoucherHistoryEntry(int voucherId, int userId, int timestamp) { - this.voucherId = voucherId; - this.userId = userId; - this.timestamp = timestamp; - } - - public int getVoucherId() { - return voucherId; - } - - public int getUserId() { - return userId; - } - - public int getTimestamp() { - return timestamp; - } } 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 d41ebead..de366cad 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 @@ -8,23 +8,20 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; 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 lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.Map; +@Slf4j public class RoomBundleLayout extends SingleBundle { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleLayout.class); - - public int roomId; - public Room room; + private final int roomId; + private Room room; private int lastUpdate = 0; private boolean loaded = false; @@ -48,7 +45,7 @@ public class RoomBundleLayout extends SingleBundle { if (this.room != null) this.room.preventUnloading = true; } else { - LOGGER.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); + log.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); } } @@ -58,15 +55,12 @@ public class RoomBundleLayout extends SingleBundle { final CatalogItem[] item = {null}; - super.getCatalogItems().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogItem object) { - if (object == null) - return true; + super.getCatalogItems().forEachValue(object -> { + if (object == null) + return true; - item[0] = object; - return false; - } + item[0] = object; + return false; }); if (this.room.isPreLoaded()) { @@ -96,7 +90,7 @@ public class RoomBundleLayout extends SingleBundle { } if (!item[0].getExtradata().isEmpty()) { - items.put(Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(item[0].getExtradata())), 1); + items.put(Emulator.getGameEnvironment().getItemManager().getItem(Integer.parseInt(item[0].getExtradata())), 1); } StringBuilder data = new StringBuilder(); @@ -190,7 +184,7 @@ public class RoomBundleLayout extends SingleBundle { statement.setInt(3, this.room.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -224,7 +218,7 @@ public class RoomBundleLayout extends SingleBundle { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId); @@ -241,7 +235,7 @@ public class RoomBundleLayout extends SingleBundle { keys.put("image", "${image.library.url}/notifications/room_bundle_" + this.getId() + ".png"); if (habbo != null) { - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.PURCHASING_ROOM.key, keys)); + habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.PURCHASING_ROOM.getKey(), keys)); } } } 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 e4ac30e1..31850d93 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 @@ -8,16 +8,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.catalog.marketplace.GetMarketplaceOffersEvent; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceBuyOfferResultComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceCancelOfferResultComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -27,8 +26,8 @@ import java.util.ArrayList; import java.util.List; +@Slf4j public class MarketPlace { - private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlace.class); //Configuration. Loaded from database & updated accordingly. public static boolean MARKETPLACE_ENABLED = true; @@ -47,7 +46,7 @@ public class MarketPlace { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return offers; @@ -105,7 +104,7 @@ public class MarketPlace { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); habbo.getClient().sendResponse(new MarketplaceCancelOfferResultComposer(offer, false)); } } @@ -169,7 +168,7 @@ public class MarketPlace { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return offers; @@ -199,7 +198,7 @@ public class MarketPlace { message.appendInt(1); message.appendInt(itemId); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -214,7 +213,7 @@ public class MarketPlace { number = set.getInt("number"); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return number; @@ -232,7 +231,7 @@ public class MarketPlace { avg = set.getInt("avg"); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return calculateCommision(avg); @@ -279,7 +278,7 @@ public class MarketPlace { client.getHabbo().getInventory().getItemsComponent().addItem(item); if (MARKETPLACE_CURRENCY == 0) { - client.getHabbo().getHabboInfo().addCredits(-event.price); + client.getHabbo().giveCredits(-event.price); } else { client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price); } @@ -300,22 +299,23 @@ public class MarketPlace { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public static void sendErrorMessage(GameClient client, int baseItemId, int offerId) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT marketplace_items.*, COUNT( * ) AS count\n" + - "FROM marketplace_items\n" + - "INNER JOIN items ON marketplace_items.item_id = items.id\n" + - "INNER JOIN items_base ON items.item_id = items_base.id\n" + - "WHERE items_base.sprite_id = ( \n" + - "SELECT items_base.sprite_id\n" + - "FROM items_base\n" + - "WHERE items_base.id = ? LIMIT 1)\n" + - "ORDER BY price ASC\n" + - "LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { + """ + FROM marketplace_items + INNER JOIN items ON marketplace_items.item_id = items.id + INNER JOIN items_base ON items.item_id = items_base.id + WHERE items_base.sprite_id = ( + SELECT items_base.sprite_id + FROM items_base + WHERE items_base.id = ? LIMIT 1) + ORDER BY price ASC + LIMIT 1""", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, baseItemId); try (ResultSet countSet = statement.executeQuery()) { countSet.last(); @@ -327,7 +327,7 @@ public class MarketPlace { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -373,7 +373,7 @@ public class MarketPlace { client.getHabbo().getInventory().removeMarketplaceOffer(offer); credits += offer.getPrice(); removeUser(offer); - offer.needsUpdate(true); + offer.setNeedsUpdate(true); Emulator.getThreading().run(offer); } } @@ -381,7 +381,7 @@ public class MarketPlace { offers.clear(); if (MARKETPLACE_CURRENCY == 0) { - client.getHabbo().getHabboInfo().addCredits(credits); + client.getHabbo().giveCredits(credits); } else { client.getHabbo().givePoints(MARKETPLACE_CURRENCY, credits); } @@ -394,7 +394,7 @@ public class MarketPlace { statement.setInt(2, offer.getOfferId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 196544e7..cada0040 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,25 +5,38 @@ 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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j public class MarketPlaceOffer implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlaceOffer.class); - - public int avarage; + public int average; public int count; + @Getter + @Setter private int offerId; - private Item baseItem; - private int itemId; + private final Item baseItem; + + private final int itemId; + + @Getter private int price; + @Getter private int limitedStack; + @Getter private int limitedNumber; + @Getter private int timestamp = Emulator.getIntUnixTimestamp(); + @Getter + @Setter private int soldTimestamp = 0; + @Getter + @Setter private MarketPlaceState state = MarketPlaceState.OPEN; + @Setter private boolean needsUpdate = false; public MarketPlaceOffer(ResultSet set, boolean privateOffer) throws SQLException { @@ -36,12 +49,12 @@ public class MarketPlaceOffer implements Runnable { this.itemId = set.getInt("item_id"); if (!set.getString("ltd_data").split(":")[1].equals("0")) { - this.limitedStack = Integer.valueOf(set.getString("ltd_data").split(":")[0]); - this.limitedNumber = Integer.valueOf(set.getString("ltd_data").split(":")[1]); + this.limitedStack = Integer.parseInt(set.getString("ltd_data").split(":")[0]); + this.limitedNumber = Integer.parseInt(set.getString("ltd_data").split(":")[1]); } if (!privateOffer) { - this.avarage = set.getInt("avg"); + this.average = set.getInt("avg"); this.count = set.getInt("number"); this.price = set.getInt("minPrice"); } @@ -70,7 +83,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -90,69 +103,10 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } - public int getOfferId() { - return this.offerId; - } - - public void setOfferId(int offerId) { - this.offerId = offerId; - } - - public int getItemId() { - return this.baseItem.getSpriteId(); - } - - public int getPrice() { - return this.price; - } - - public MarketPlaceState getState() { - return this.state; - } - - public void setState(MarketPlaceState state) { - this.state = state; - } - - public int getTimestamp() { - return this.timestamp; - } - - public int getSoldTimestamp() { - return this.soldTimestamp; - } - - public void setSoldTimestamp(int soldTimestamp) { - this.soldTimestamp = soldTimestamp; - } - - public int getLimitedStack() { - return this.limitedStack; - } - - public int getLimitedNumber() { - return this.limitedNumber; - } - - public int getSoldItemId() { - return this.itemId; - } - - public void needsUpdate(boolean value) { - this.needsUpdate = value; - } - - public int getType() { - if (this.limitedStack > 0) { - return 3; - } - - return this.baseItem.getType().equals(FurnitureType.WALL) ? 2 : 1; - } @Override public void run() { @@ -164,8 +118,25 @@ public class MarketPlaceOffer implements Runnable { statement.setInt(3, this.offerId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } + + public int getType() { + if (this.limitedStack > 0) { + return 3; + } + + return this.baseItem.getType().equals(FurnitureType.WALL) ? 2 : 1; + } + + public int getItemId() { + return this.baseItem.getSpriteId(); + } + + + public int getSoldItemId() { + return this.itemId; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceState.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceState.java index 3cd7386d..8c83006f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceState.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceState.java @@ -1,36 +1,27 @@ package com.eu.habbo.habbohotel.catalog.marketplace; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum MarketPlaceState { OPEN(1), - SOLD(2), - CLOSED(3); private final int state; - MarketPlaceState(int state) { - this.state = state; - } - public static MarketPlaceState getType(int type) { - switch (type) { - case 1: - return OPEN; - case 2: - return SOLD; - case 3: - return CLOSED; - } + return switch (type) { + case 1 -> OPEN; + case 2 -> SOLD; + case 3 -> CLOSED; + default -> CLOSED; + }; - return CLOSED; } - - public int getState() { - return this.state; - } - } 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 cddf2f2f..be689722 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -3,15 +3,14 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class AddYoutubePlaylistCommand extends Command { - private static final Logger LOGGER = LoggerFactory.getLogger(AddYoutubePlaylistCommand.class); public AddYoutubePlaylistCommand() { super("cmd_add_youtube_playlist", Emulator.getTexts().getValue("commands.keys.cmd_add_youtube_playlist").split(";")); @@ -53,7 +52,7 @@ public class AddYoutubePlaylistCommand extends Command { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java index 1328ed19..899b954b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -6,16 +6,15 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class BadgeCommand extends Command { - private static final Logger LOGGER = LoggerFactory.getLogger(BadgeCommand.class); public BadgeCommand() { super("cmd_badge", Emulator.getTexts().getValue("commands.keys.cmd_badge").split(";")); @@ -64,7 +63,6 @@ public class BadgeCommand extends Command { if (found) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); - return true; } else { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, ?, 0, ?)")) { statement.setInt(1, habboInfo.getId()); @@ -73,10 +71,10 @@ public class BadgeCommand extends Command { } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); - return true; } + return true; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java index b9946ffa..8b447a0f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java @@ -28,7 +28,7 @@ public class BanCommand extends Command { int banTime; try { - banTime = Integer.valueOf(params[2]); + banTime = Integer.parseInt(params[2]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.invalid_time"), RoomChatMessageBubbles.ALERT); return true; @@ -39,7 +39,7 @@ public class BanCommand extends Command { return true; } - if (params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) { + if (params[1].equalsIgnoreCase(gameClient.getHabbo().getHabboInfo().getUsername())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.ban_self"), RoomChatMessageBubbles.ALERT); return true; } @@ -73,7 +73,7 @@ public class BanCommand extends Command { } ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().ban(target.getId(), gameClient.getHabbo(), reason.toString(), banTime, ModToolBanType.ACCOUNT, -1).get(0); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ban.ban_issued").replace("%user%", target.getUsername()).replace("%time%", ban.expireDate - Emulator.getIntUnixTimestamp() + "").replace("%reason%", ban.reason), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ban.ban_issued").replace("%user%", target.getUsername()).replace("%time%", ban.getExpireDate() - Emulator.getIntUnixTimestamp() + "").replace("%reason%", ban.getReason()), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java index b2fc711c..f23691cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java @@ -12,8 +12,8 @@ public class BlockAlertCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { - gameClient.getHabbo().getHabboStats().blockStaffAlerts = !gameClient.getHabbo().getHabboStats().blockStaffAlerts; - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_blockalert").replace("%state%", (gameClient.getHabbo().getHabboStats().blockStaffAlerts ? Emulator.getTexts().getValue("generic.on") : Emulator.getTexts().getValue("generic.off"))), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().getHabboStats().setBlockStaffAlerts(!gameClient.getHabbo().getHabboStats().isBlockStaffAlerts()); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_blockalert").replace("%state%", (gameClient.getHabbo().getHabboStats().isBlockStaffAlerts() ? Emulator.getTexts().getValue("generic.on") : Emulator.getTexts().getValue("generic.off"))), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java index d1a06d2a..90a7dad0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java @@ -32,7 +32,7 @@ public class CalendarCommand extends Command { int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); if (daysBetween >= 0) { - gameClient.sendResponse(new CampaignCalendarDataMessageComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); + gameClient.sendResponse(new CampaignCalendarDataMessageComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().getCalendarRewardsClaimed(), campaign.getLockExpired())); gameClient.sendResponse(new InClientLinkMessageComposer("openView/calendar")); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java index da17cc8f..bed49403 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java @@ -15,7 +15,7 @@ public class ChangeNameCommand extends Command { // check if there are no params if (params.length < 2) { - gameClient.getHabbo().getHabboStats().allowNameChange = !gameClient.getHabbo().getHabboStats().allowNameChange; + gameClient.getHabbo().getHabboStats().setAllowNameChange(!gameClient.getHabbo().getHabboStats().isAllowNameChange()); gameClient.sendResponse(new UserObjectComposer(gameClient.getHabbo())); return true; } @@ -31,7 +31,7 @@ public class ChangeNameCommand extends Command { // this runs if params[1] is a valid habbo gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_changename.done").replace("%user%", params[1])); habbo.alert(Emulator.getTexts().getValue("commands.succes.cmd_changename.received")); - habbo.getHabboStats().allowNameChange = !habbo.getHabboStats().allowNameChange; + habbo.getHabboStats().setAllowNameChange(!habbo.getHabboStats().isAllowNameChange()); habbo.getClient().sendResponse(new UserObjectComposer(habbo)); return true; } 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 8d6a53b3..0e7ae5c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java @@ -17,7 +17,7 @@ public class ChatTypeCommand extends Command { if (params.length >= 2) { int chatColor; try { - chatColor = Integer.valueOf(params[1]); + chatColor = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.numbers"), RoomChatMessageBubbles.ALERT); return true; @@ -34,21 +34,20 @@ public class ChatTypeCommand extends Command { if (!gameClient.getHabbo().hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { - if (Integer.valueOf(s) == chatColor) { + if (Integer.parseInt(s) == chatColor) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.banned"), RoomChatMessageBubbles.ALERT); return true; } } } - gameClient.getHabbo().getHabboStats().chatColor = RoomChatMessageBubbles.getBubble(chatColor); + gameClient.getHabbo().getHabboStats().setChatColor(RoomChatMessageBubbles.getBubble(chatColor)); gameClient.sendResponse(new AccountPreferencesComposer(gameClient.getHabbo())); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_chatcolor.set").replace("%chat%", RoomChatMessageBubbles.values()[chatColor].name().replace("_", " ").toLowerCase()), RoomChatMessageBubbles.ALERT); - return true; } else { - gameClient.getHabbo().getHabboStats().chatColor = RoomChatMessageBubbles.NORMAL; + gameClient.getHabbo().getHabboStats().setChatColor(RoomChatMessageBubbles.NORMAL); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_chatcolor.reset"), RoomChatMessageBubbles.ALERT); - return true; } + return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/Command.java b/src/main/java/com/eu/habbo/habbohotel/commands/Command.java index 6c71c7a2..711bede9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/Command.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/Command.java @@ -1,19 +1,14 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.habbohotel.gameclients.GameClient; +import lombok.AllArgsConstructor; +@AllArgsConstructor public abstract class Command { public final String permission; - - public final String[] keys; - public Command(String permission, String[] keys) { - this.permission = permission; - this.keys = keys; - } - public abstract boolean handle(GameClient gameClient, String[] params) throws Exception; } \ No newline at end of file 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 9a0e54a4..bce43f15 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -16,30 +16,25 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; +@Slf4j public class CommandHandler { - - private static final Logger LOGGER = LoggerFactory.getLogger(CommandHandler.class); - private final static THashMap commands = new THashMap<>(5); - private static final Comparator ALPHABETICAL_ORDER = new Comparator() { - public int compare(Command c1, Command c2) { - int res = String.CASE_INSENSITIVE_ORDER.compare(c1.permission, c2.permission); - return (res != 0) ? res : c1.permission.compareTo(c2.permission); - } + private static final Comparator ALPHABETICAL_ORDER = (c1, c2) -> { + int res = String.CASE_INSENSITIVE_ORDER.compare(c1.permission, c2.permission); + return (res != 0) ? res : c1.permission.compareTo(c2.permission); }; public CommandHandler() { long millis = System.currentTimeMillis(); this.reloadCommands(); - LOGGER.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addCommand(Command command) { @@ -54,9 +49,9 @@ public class CommandHandler { try { //command.getConstructor().setAccessible(true); addCommand(command.newInstance()); - LOGGER.debug("Added command: {}", command.getName()); + log.debug("Added command: {}", command.getName()); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -71,7 +66,7 @@ public class CommandHandler { if (parts.length >= 1) { for (Command command : commands.values()) { for (String s : command.keys) { - if (s.toLowerCase().equals(parts[0].toLowerCase())) { + if (s.equalsIgnoreCase(parts[0])) { 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(Permission.ACC_PLACEFURNI) || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)))) { try { @@ -90,7 +85,7 @@ public class CommandHandler { succes = event.succes; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) { @@ -137,7 +132,7 @@ public class CommandHandler { s = new StringBuilder(s.substring(0, s.length() - 1)); for (PetCommand command : pet.getPetData().getPetCommands()) { - if (command.key.equalsIgnoreCase(s.toString())) { + if (command.getKey().equalsIgnoreCase(s.toString())) { if (pet instanceof RideablePet && ((RideablePet) pet).getRider() != null) { if (((RideablePet) pet).getRider().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) { ((RideablePet) pet).getRider().getHabboInfo().dismountPet(); @@ -145,7 +140,7 @@ public class CommandHandler { break; } - if (command.level <= pet.getLevel()) + if (command.getLevel() <= pet.getLevel()) pet.handleCommand(command, gameClient.getHabbo(), args); else pet.say(pet.getPetData().randomVocal(PetVocalsType.UNKNOWN_COMMAND)); @@ -307,7 +302,7 @@ public class CommandHandler { if (allowedCommands.contains(command)) continue; - if (permissions.contains(command.permission) && permissions.get(command.permission).setting != PermissionSetting.DISALLOWED) { + if (permissions.contains(command.permission) && permissions.get(command.permission).getSetting() != PermissionSetting.DISALLOWED) { allowedCommands.add(command); } } @@ -320,6 +315,6 @@ public class CommandHandler { public void dispose() { commands.clear(); - LOGGER.info("Command Handler -> Disposed!"); + log.info("Command Handler -> Disposed!"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java index d14bdb17..269ad245 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java @@ -35,7 +35,6 @@ public class ControlCommand extends Command { gameClient.getHabbo().getRoomUnit().getCacheable().put("control", target); target.getRoomUnit().getCacheable().put("controller", gameClient.getHabbo()); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.controlling").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } else { Object habbo = gameClient.getHabbo().getRoomUnit().getCacheable().get("control"); @@ -44,8 +43,8 @@ public class ControlCommand extends Command { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", ((Habbo) habbo).getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); } - return true; } + return true; } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java index 405dbfde..48399f27 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java @@ -24,20 +24,20 @@ public class CoordsCommand extends Command { Emulator.getTexts().getValue("generic.rotation.head") + ": " + gameClient.getHabbo().getRoomUnit().getHeadRotation() + "-" + gameClient.getHabbo().getRoomUnit().getHeadRotation().getValue() + "\r" + Emulator.getTexts().getValue("generic.rotation.body") + ": " + gameClient.getHabbo().getRoomUnit().getBodyRotation() + "-" + gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() + "\r" + Emulator.getTexts().getValue("generic.sitting") + ": " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" + - "Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).state.name() + "\r" + + "Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getState().name() + "\r" + "Tile Walkable: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).isWalkable() + "\r" + "Tile relative height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).relativeHeight() + "\r" + "Tile stack height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getStackHeight()); } else { - RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(Short.valueOf(params[1]), Short.valueOf(params[2])); + RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2])); if (tile != null) { gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" + - "x: " + tile.x + "\r" + - "y: " + tile.y + "\r" + - "z: " + tile.z + "\r" + - "Tile State: " + tile.state.name() + "\r" + + "x: " + tile.getX() + "\r" + + "y: " + tile.getY() + "\r" + + "z: " + tile.getZ() + "\r" + + "Tile State: " + tile.getState().name() + "\r" + "Tile Relative Height: " + tile.relativeHeight() + "\r" + "Tile Stack Height: " + tile.getStackHeight() + "\r" + "Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r"); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java index 867e7a95..82dd200e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java @@ -17,7 +17,7 @@ public class DisconnectCommand extends Command { return true; } - if (params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) { + if (params[1].equalsIgnoreCase(gameClient.getHabbo().getHabboInfo().getUsername())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.disconnect_self"), RoomChatMessageBubbles.ALERT); return true; } 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 dbe1ae2f..513c4cd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java @@ -6,8 +6,8 @@ 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.PetInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.PetInventoryComposer; import gnu.trove.map.hash.TIntObjectHashMap; public class EmptyPetsInventoryCommand extends Command { 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 cf69a1d1..b9a44e40 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java @@ -5,12 +5,10 @@ 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; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class EnableCommand extends Command { - private static final Logger LOGGER = LoggerFactory.getLogger(EnableCommand.class); - public EnableCommand() { super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";")); } @@ -43,7 +41,7 @@ public class EnableCommand extends Command { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java index 16b807fc..1c2e9eab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java @@ -37,8 +37,9 @@ public class EventCommand extends Command { for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().isBlockStaffAlerts()) { continue; + } habbo.getClient().sendResponse(msg); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java index ac211cd4..a897b7cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java @@ -36,7 +36,7 @@ public class FacelessCommand extends Command { } } - } catch (Exception e) { + } catch (Exception ignored) { } } 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 9e208a0a..e746f954 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java @@ -4,15 +4,14 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class FilterWordCommand extends Command { - private static final Logger LOGGER = LoggerFactory.getLogger(FilterWordCommand.class); public FilterWordCommand() { super("cmd_filterword", Emulator.getTexts().getValue("commands.keys.cmd_filterword").split(";")); @@ -39,7 +38,7 @@ public class FilterWordCommand extends Command { statement.setString(2, replacement); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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/FreezeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java index b640a806..c79d5aa1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java @@ -23,13 +23,12 @@ public class FreezeCommand extends Command { habbo.getRoomUnit().setCanWalk(false); habbo.whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.frozen"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.user_frozen").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } else { habbo.getRoomUnit().setCanWalk(true); habbo.whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.unfrozen"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.user_unfrozen").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } + return true; } } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_freeze.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java index 13640d4f..05abb1f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java @@ -8,8 +8,8 @@ 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.habbohotel.users.HabboManager; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import gnu.trove.map.hash.THashMap; @@ -25,7 +25,7 @@ public class GiftCommand extends Command { int itemId; try { - itemId = Integer.valueOf(params[2]); + itemId = Integer.parseInt(params[2]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; @@ -80,7 +80,7 @@ public class GiftCommand extends Command { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}notifications/gift.gif"); keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous")); - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); + habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys)); } return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java index 274368c1..1ea3275f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java @@ -28,7 +28,7 @@ public class GiveRankCommand extends Command { if (params.length == 3) { if (StringUtils.isNumeric(params[2])) { - int rankId = Integer.valueOf(params[2]); + int rankId = Integer.parseInt(params[2]); if (Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId); } else { @@ -52,11 +52,10 @@ public class GiveRankCommand extends Command { Emulator.getGameEnvironment().getHabboManager().setRank(habbo.getId(), rank.getId()); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_give_rank.updated").replace("%id%", rank.getName()).replace("%username%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_give_rank.user_offline").replace("%id%", rank.getName()).replace("%username%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } + 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 31aa0006..2f8ce1b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java @@ -27,7 +27,7 @@ public class HotelAlertCommand extends Command { for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().isBlockStaffAlerts()) continue; habbo.getClient().sendResponse(msg); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java index 27e1eb16..64b019b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java @@ -6,9 +6,9 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; public class InvisibleCommand extends Command { @@ -23,7 +23,7 @@ public class InvisibleCommand extends Command { if (roomUnit.isInvisible()) { RoomLayout roomLayout = roomUnit.getRoom().getLayout(); - new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().x, roomLayout.getDoorTile().y, roomLayout.getDoorTile().z, 0).run(); + new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().getX(), roomLayout.getDoorTile().getY(), roomLayout.getDoorTile().getZ(), 0).run(); roomUnit.setInvisible(false); roomUnit.setInRoom(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java index b874d70d..267327ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import gnu.trove.map.hash.THashMap; @@ -31,7 +31,7 @@ public class MassBadgeCommand extends Command { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); - ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); + ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose(); for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); @@ -40,18 +40,17 @@ public class MassBadgeCommand extends Command { if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { HabboBadge b = BadgesComponent.createBadge(badge, habbo); - if (b != null) { - habbo.getClient().sendResponse(new BadgeReceivedComposer(b)); - - habbo.getClient().sendResponse(message); - } + habbo.getClient().sendResponse(new BadgeReceivedComposer(b)); + habbo.getClient().sendResponse(message); } } } + return true; } - return true; } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_massbadge.no_badge"), RoomChatMessageBubbles.ALERT); return true; + + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java index 7028183d..584fa20d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java @@ -19,7 +19,7 @@ public class MassCreditsCommand extends Command { int amount; try { - amount = Integer.valueOf(params[1]); + amount = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masscredits.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; 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 2ca71e0a..b267cbba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import gnu.trove.map.hash.THashMap; @@ -25,7 +25,7 @@ public class MassGiftCommand extends Command { int itemId; try { - itemId = Integer.valueOf(params[1]); + itemId = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; @@ -57,7 +57,7 @@ public class MassGiftCommand extends Command { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}notifications/gift.gif"); keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous")); - ServerMessage giftNotificiationMessage = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); + ServerMessage giftNotificiationMessage = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose(); Emulator.getThreading().run(() -> { for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java index 7d4fd95b..504bd75e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java @@ -18,7 +18,7 @@ public class MassPixelsCommand extends Command { int amount; try { - amount = Integer.valueOf(params[1]); + amount = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_massduckets.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java index 79103ea8..dd659c7a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java @@ -19,7 +19,7 @@ public class MassPointsCommand extends Command { if (params.length == 3) { amountString = params[1]; try { - type = Integer.valueOf(params[2]); + type = Integer.parseInt(params[2]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT); return true; @@ -48,7 +48,7 @@ public class MassPointsCommand extends Command { int amount; try { - amount = Integer.valueOf(amountString); + amount = Integer.parseInt(amountString); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java index 768a42e2..15e29098 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java @@ -11,8 +11,8 @@ public class MuteBotsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - gameClient.getHabbo().getHabboStats().ignoreBots = !gameClient.getHabbo().getHabboStats().ignoreBots; - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_bots." + (gameClient.getHabbo().getHabboStats().ignoreBots ? "ignored" : "unignored")), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().getHabboStats().setIgnoreBots(!gameClient.getHabbo().getHabboStats().isIgnoreBots()); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_bots." + (gameClient.getHabbo().getHabboStats().isIgnoreBots() ? "ignored" : "unignored")), RoomChatMessageBubbles.ALERT); return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java index 0d41a472..0b0d60f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java @@ -33,7 +33,7 @@ public class MuteCommand extends Command { if (params.length == 3) { try { - duration = Integer.valueOf(params[2]); + duration = Integer.parseInt(params[2]); if (duration <= 0) throw new Exception(""); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java index 6dcb6972..7c33c505 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java @@ -11,8 +11,8 @@ public class MutePetsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - gameClient.getHabbo().getHabboStats().ignorePets = !gameClient.getHabbo().getHabboStats().ignorePets; - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_pets." + (gameClient.getHabbo().getHabboStats().ignorePets ? "ignored" : "unignored")), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().getHabboStats().setIgnorePets(!gameClient.getHabbo().getHabboStats().isIgnorePets()); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_pets." + (gameClient.getHabbo().getHabboStats().isIgnorePets() ? "ignored" : "unignored")), RoomChatMessageBubbles.ALERT); return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java index 00a81642..ffe2d433 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java @@ -2,10 +2,8 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import gnu.trove.procedure.TIntObjectProcedure; public class PetInfoCommand extends Command { public PetInfoCommand() { @@ -20,30 +18,27 @@ public class PetInfoCommand extends Command { String name = params[1]; - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry(new TIntObjectProcedure() { - @Override - public boolean execute(int a, Pet pet) { - if (pet.getName().equalsIgnoreCase(name)) { - gameClient.getHabbo().alert("" + - Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + - Emulator.getTexts().getValue("generic.pet.id") + ": " + pet.getId() + "\r" + - Emulator.getTexts().getValue("generic.pet.name") + ": " + pet.getName() + "\r" + - Emulator.getTexts().getValue("generic.pet.age") + ": " + pet.daysAlive() + " " + Emulator.getTexts().getValue("generic.pet.days.alive") + "\r" + - Emulator.getTexts().getValue("generic.pet.level") + ": " + pet.getLevel() + "\r" + - "\r" + - Emulator.getTexts().getValue("commands.generic.cmd_pet_info.stats") + "\r\n" + - Emulator.getTexts().getValue("generic.pet.scratches") + ": " + pet.getRespect() + "\r" + - Emulator.getTexts().getValue("generic.pet.energy") + ": " + pet.getEnergy() + "/" + PetManager.maxEnergy(pet.getLevel()) + "\r" + - Emulator.getTexts().getValue("generic.pet.happyness") + ": " + pet.getHappyness() + "\r" + - Emulator.getTexts().getValue("generic.pet.level.thirst") + ": " + pet.levelThirst + "\r" + - Emulator.getTexts().getValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" + - Emulator.getTexts().getValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? Emulator.getTexts().getValue("generic.nothing") : pet.getTask().name()) + "\r" + - Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "" - ); - } - - return true; + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry((a, pet) -> { + if (pet.getName().equalsIgnoreCase(name)) { + gameClient.getHabbo().alert("" + + Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + + Emulator.getTexts().getValue("generic.pet.id") + ": " + pet.getId() + "\r" + + Emulator.getTexts().getValue("generic.pet.name") + ": " + pet.getName() + "\r" + + Emulator.getTexts().getValue("generic.pet.age") + ": " + pet.daysAlive() + " " + Emulator.getTexts().getValue("generic.pet.days.alive") + "\r" + + Emulator.getTexts().getValue("generic.pet.level") + ": " + pet.getLevel() + "\r" + + "\r" + + Emulator.getTexts().getValue("commands.generic.cmd_pet_info.stats") + "\r\n" + + Emulator.getTexts().getValue("generic.pet.scratches") + ": " + pet.getRespect() + "\r" + + Emulator.getTexts().getValue("generic.pet.energy") + ": " + pet.getEnergy() + "/" + PetManager.maxEnergy(pet.getLevel()) + "\r" + + Emulator.getTexts().getValue("generic.pet.happyness") + ": " + pet.getHappiness() + "\r" + + Emulator.getTexts().getValue("generic.pet.level.thirst") + ": " + pet.levelThirst + "\r" + + Emulator.getTexts().getValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" + + Emulator.getTexts().getValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? Emulator.getTexts().getValue("generic.nothing") : pet.getTask().name()) + "\r" + + Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "" + ); } + + return true; }); } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pet_info.pet_not_found"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java index 327dc4e9..11a7eb99 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java @@ -20,11 +20,11 @@ public class PixelCommand extends Command { if (Integer.parseInt(params[2]) != 0) { habbo.givePixels(Integer.parseInt(params[2])); if (habbo.getHabboInfo().getCurrentRoom() != null) - habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""), RoomChatMessageBubbles.ALERT); + habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT); else - habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + "")); + habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.parseInt(params[2]) + "")); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.valueOf(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.invalid_amount"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java index 0580188f..56ca70cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java @@ -21,7 +21,7 @@ public class PointsCommand extends Command { if (params.length == 4) { try { - type = Integer.valueOf(params[3]); + type = Integer.parseInt(params[3]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT); return true; @@ -31,7 +31,7 @@ public class PointsCommand extends Command { int amount; try { - amount = Integer.valueOf(params[2]); + amount = Integer.parseInt(params[2]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java index de943796..6263bb88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java @@ -47,8 +47,8 @@ public class PromoteTargetOfferCommand extends Command { } else { int offerId = 0; try { - offerId = Integer.valueOf(offerKey); - } catch (Exception e) { + offerId = Integer.parseInt(offerKey); + } catch (Exception ignored) { } if (offerId > 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java index 5e041f3a..f8a4fffe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java @@ -31,23 +31,23 @@ public class PushCommand extends Command { } RoomTile tFront = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tFront != null && tFront.isWalkable() && tFront.x == habbo.getRoomUnit().getX() && tFront.y == habbo.getRoomUnit().getY()) { - RoomTile tFrontTarget = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); + if (tFront != null && tFront.isWalkable()) { + if (tFront.getX() == habbo.getRoomUnit().getX() && tFront.getY() == habbo.getRoomUnit().getY()) { + RoomTile tFrontTarget = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tFrontTarget != null && tFrontTarget.isWalkable()) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tFrontTarget) { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.invalid").replace("%username%", params[1])); - return true; + if (tFrontTarget != null && tFrontTarget.isWalkable()) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tFrontTarget) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.invalid").replace("%username%", params[1])); + return true; + } + habbo.getRoomUnit().setGoalLocation(tFrontTarget); + gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("commands.succes.cmd_push.push").replace("%user%", params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); } - habbo.getRoomUnit().setGoalLocation(tFrontTarget); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("commands.succes.cmd_push.push").replace("%user%", params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); + } else { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.cant_reach").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + return true; } - } else { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.cant_reach").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - return true; } - - return true; } } 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 ad48e0f7..df56edad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java @@ -9,7 +9,6 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; import gnu.trove.map.TIntIntMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TIntIntProcedure; import java.util.ArrayList; @@ -35,21 +34,21 @@ public class RedeemCommand extends Command { items.add(item); if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { try { - credits += Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } catch (Exception e) { + credits += Integer.parseInt(item.getBaseItem().getName().split("_")[1]); + } catch (Exception ignored) { } } else if (item.getBaseItem().getName().startsWith("PF_")) { try { - pixels += Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } catch (Exception e) { + pixels += Integer.parseInt(item.getBaseItem().getName().split("_")[1]); + } catch (Exception ignored) { } } else if (item.getBaseItem().getName().startsWith("DF_")) { int pointsType; int pointsAmount; - pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + pointsType = Integer.parseInt(item.getBaseItem().getName().split("_")[1]); + pointsAmount = Integer.parseInt(item.getBaseItem().getName().split("_")[2]); points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount); } @@ -58,7 +57,7 @@ public class RedeemCommand extends Command { int pointsAmount; pointsType = 5; - pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + pointsAmount = Integer.parseInt(item.getBaseItem().getName().split("_")[2]); points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount); } @@ -89,13 +88,10 @@ public class RedeemCommand extends Command { } if (!points.isEmpty()) { - points.forEachEntry(new TIntIntProcedure() { - @Override - public boolean execute(int a, int b) { - gameClient.getHabbo().givePoints(a, b); - message[0] += " ," + Emulator.getTexts().getValue("seasonal.name." + a) + ": " + b; - return true; - } + points.forEachEntry((a, b) -> { + gameClient.getHabbo().givePoints(a, b); + message[0] += " ," + Emulator.getTexts().getValue("seasonal.name." + a) + ": " + b; + return true; }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java index 3d9be4c8..099ff962 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import gnu.trove.map.hash.THashMap; @@ -32,7 +32,7 @@ public class RoomBadgeCommand extends Command { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); - ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); + ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose(); for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) { if (habbo.isOnline()) { 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 3b3f5161..1ce9dfc1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java @@ -7,13 +7,12 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j public class RoomBundleCommand extends Command { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleCommand.class); public RoomBundleCommand() { super("cmd_bundle", Emulator.getTexts().getValue("commands.keys.cmd_bundle").split(";")); @@ -36,10 +35,10 @@ public class RoomBundleCommand extends Command { return true; } - parentId = Integer.valueOf(params[1]); - credits = Integer.valueOf(params[2]); - points = Integer.valueOf(params[3]); - pointsType = Integer.valueOf(params[4]); + parentId = Integer.parseInt(params[1]); + credits = Integer.parseInt(params[2]); + points = Integer.parseInt(params[3]); + pointsType = Integer.parseInt(params[4]); CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName(), "room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getRank().getId(), parentId); @@ -66,7 +65,7 @@ public class RoomBundleCommand extends Command { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } ((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java index 1c72b7a8..762b1d29 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java @@ -16,7 +16,7 @@ public class RoomCreditsCommand extends Command { int amount; try { - amount = Integer.valueOf(params[1]); + amount = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masscredits.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java index b968342c..32db45a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java @@ -18,7 +18,7 @@ public class RoomDanceCommand extends Command { int danceId; try { - danceId = Integer.valueOf(params[1]); + danceId = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_danceall.invalid_dance"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java index 111b3887..0f4fb4f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java @@ -19,7 +19,7 @@ public class RoomEffectCommand extends Command { } try { - int effectId = Integer.valueOf(params[1]); + int effectId = Integer.parseInt(params[1]); if (effectId >= 0) { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); @@ -27,11 +27,10 @@ public class RoomEffectCommand extends Command { room.giveEffect(habbo, effectId, -1); } - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT); - return true; } + return true; } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomeffect.numbers_only"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java index 7b821959..ad0aa1c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java @@ -20,7 +20,7 @@ public class RoomGiftCommand extends Command { int itemId; try { - itemId = Integer.valueOf(params[1]); + itemId = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java index a1a6f3a6..34a55915 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java @@ -17,7 +17,7 @@ public class RoomItemCommand extends Command { if (params.length >= 2) { try { - itemId = Integer.valueOf(params[1]); + itemId = Integer.parseInt(params[1]); if (itemId < 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomitem.positive"), RoomChatMessageBubbles.ALERT); @@ -36,10 +36,9 @@ public class RoomItemCommand extends Command { if (itemId > 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roomitem.given").replace("%item%", itemId + ""), RoomChatMessageBubbles.ALERT); - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roomitem.removed"), RoomChatMessageBubbles.ALERT); - return true; } + return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java index 567400f1..b28fd599 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java @@ -16,7 +16,7 @@ public class RoomPixelsCommand extends Command { int amount; try { - amount = Integer.valueOf(params[1]); + amount = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_massduckets.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java index 32ebe50d..eac86282 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java @@ -18,7 +18,7 @@ public class RoomPointsCommand extends Command { try { amountString = params[1]; - type = Integer.valueOf(params[2]); + type = Integer.parseInt(params[2]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT); return true; @@ -46,7 +46,7 @@ public class RoomPointsCommand extends Command { int amount; try { - amount = Integer.valueOf(amountString); + amount = Integer.parseInt(amountString); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java index b6bdfd87..ae173d33 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java @@ -14,7 +14,7 @@ public class SetMaxCommand extends Command { if (params.length >= 2) { int max; try { - max = Integer.valueOf(params[1]); + max = Integer.parseInt(params[1]); } catch (Exception e) { return false; } @@ -22,11 +22,10 @@ public class SetMaxCommand extends Command { if (max > 0 && max < 9999) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().setUsersMax(max); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.cmd_setmax").replace("%value%", max + ""), RoomChatMessageBubbles.ALERT); - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setmax.invalid_number"), RoomChatMessageBubbles.ALERT); - return true; } + return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setmax.forgot_number"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java index b9c0072f..9678aadb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java @@ -15,8 +15,8 @@ public class SetPollCommand extends Command { if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { int pollId = -1; try { - pollId = Integer.valueOf(params[1]); - } catch (Exception e) { + pollId = Integer.parseInt(params[1]); + } catch (Exception ignored) { } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java index bdce54d6..ab9c1fe2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java @@ -20,7 +20,7 @@ public class SetSpeedCommand extends Command { int newSpeed; try { - newSpeed = Integer.valueOf(params[1]); + newSpeed = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setspeed.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java index 310ba8d8..c48360c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.ShoutMessageComposer; public class ShoutCommand extends Command { - private static String idea = "Kudo's To Droppy for this idea!"; public ShoutCommand() { super("cmd_shout", Emulator.getTexts().getValue("commands.keys.cmd_shout").split(";")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java index 19eabcab..fe47fdab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java @@ -20,7 +20,7 @@ public class StaffOnlineCommand extends Command { if (params.length >= 2) { try { - int i = Integer.valueOf(params[1]); + int i = Integer.parseInt(params[1]); if (i < 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffonline.positive_only"), RoomChatMessageBubbles.ALERT); @@ -43,12 +43,7 @@ public class StaffOnlineCommand extends Command { } } - staffs.sort(new Comparator() { - @Override - public int compare(Habbo o1, Habbo o2) { - return o1.getHabboInfo().getId() - o2.getHabboInfo().getId(); - } - }); + staffs.sort(Comparator.comparingInt(o -> o.getHabboInfo().getId())); StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_staffonline.staffs")); message.append("\r\n"); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java index b4dad5c4..55e9d446 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java @@ -41,10 +41,9 @@ public class StalkCommand extends Command { gameClient.sendResponse(new GetGuestRoomResultComposer(habbo.getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false)); //gameClient.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId())); - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.forgot_username"), RoomChatMessageBubbles.ALERT); - return true; } + return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SubscriptionCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SubscriptionCommand.java index 96350ae9..27b7e55b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SubscriptionCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SubscriptionCommand.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.HabboStats; @@ -54,7 +53,7 @@ public class SubscriptionCommand extends Command { } } - if(!Emulator.getGameEnvironment().getSubscriptionManager().types.containsKey(subscription)) { + if(!Emulator.getGameEnvironment().getSubscriptionManager().getTypes().containsKey(subscription)) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.type_not_found", "%subscription% is not a valid subscription type").replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java index 366907ce..71bb9de0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java @@ -52,10 +52,9 @@ public class SummonCommand extends Command { habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername())); - return true; } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), RoomChatMessageBubbles.ALERT); - return true; } + 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 243dec78..6c9eceab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java @@ -15,7 +15,7 @@ public class TestCommand extends Command { if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL) || !Emulator.debugging) return false; - int header = Integer.valueOf(params[1]); + int header = Integer.parseInt(params[1]); ServerMessage message = new ServerMessage(header); @@ -31,11 +31,11 @@ public class TestCommand extends Command { message.appendString(""); } } else if (data[0].equals("i")) { - message.appendInt(Integer.valueOf(data[1])); + message.appendInt(Integer.parseInt(data[1])); } else if (data[0].equalsIgnoreCase("by")) { - message.appendByte(Integer.valueOf(data[1])); + message.appendByte(Integer.parseInt(data[1])); } else if (data[0].equalsIgnoreCase("sh")) { - message.appendShort(Integer.valueOf(data[1])); + message.appendShort(Integer.parseInt(data[1])); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java index b50d4bc7..d7337d37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java @@ -31,7 +31,6 @@ public class TransformCommand extends Command { } gameClient.sendResponse(new MOTDNotificationComposer(new String[]{petNames.toString()})); - return true; } else { String petName = params[1]; PetData petData = Emulator.getGameEnvironment().getPetManager().getPetData(petName); @@ -40,7 +39,7 @@ public class TransformCommand extends Command { if (params.length >= 3) { try { - race = Integer.valueOf(params[2]); + race = Integer.parseInt(params[2]); } catch (Exception e) { return true; } @@ -54,16 +53,16 @@ public class TransformCommand extends Command { if (petData != null) { RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit(); roomUnit.setRoomUnitType(RoomUnitType.PET); - gameClient.getHabbo().getHabboStats().cache.put("pet_type", petData); - gameClient.getHabbo().getHabboStats().cache.put("pet_race", race); - gameClient.getHabbo().getHabboStats().cache.put("pet_color", color); + gameClient.getHabbo().getHabboStats().getCache().put("pet_type", petData); + gameClient.getHabbo().getHabboStats().getCache().put("pet_race", race); + gameClient.getHabbo().getHabboStats().getCache().put("pet_color", color); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserRemoveMessageComposer(gameClient.getHabbo().getRoomUnit()).compose()); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose()); } else { //Pet Not Found return true; } - return true; } + return true; } } \ No newline at end of file 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 b4a3ca78..b5f7148e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java @@ -46,7 +46,7 @@ public class UserInfoCommand extends Command { ((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.getHabboInfo().getIpLogin() + "\r") + - (onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : "")); + (onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().getAchievementScore() + "\r" : "")); ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId()); @@ -70,7 +70,7 @@ public class UserInfoCommand extends Command { message.append(Emulator.getTexts().getValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r"); } - message.append("\r").append(onlineHabbo != null ? "" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : ""); + message.append("\r").append(onlineHabbo != null ? "" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().getRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().getPetRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().isBlockFollowing()) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().isBlockFriendRequests()) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3); @@ -85,12 +85,7 @@ public class UserInfoCommand extends Command { message.append("\r" + "Other accounts ("); ArrayList users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10); - users.sort(new Comparator() { - @Override - public int compare(HabboInfo o1, HabboInfo o2) { - return o1.getId() - o2.getId(); - } - }); + users.sort(Comparator.comparingInt(HabboInfo::getId)); message.append(users.size()).append("):\r"); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java index ba74d5d2..c66cb4b6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java @@ -25,7 +25,7 @@ public class WordQuizCommand extends Command { duration = Integer.parseInt(params[params.length-1]); params = Arrays.copyOf(params, params.length-1); } - catch (Exception e) {} + catch (Exception ignored) {} for (int i = 1; i < params.length; i++) { question.append(" ").append(params[i]); 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 9fe611a4..c356f337 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java @@ -3,17 +3,15 @@ package com.eu.habbo.habbohotel.crafting; 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class CraftingManager { - private static final Logger LOGGER = LoggerFactory.getLogger(CraftingManager.class); private final THashMap altars; @@ -29,7 +27,7 @@ public class CraftingManager { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM crafting_altars_recipes " + "INNER JOIN crafting_recipes ON crafting_altars_recipes.recipe_id = crafting_recipes.id " + "INNER JOIN crafting_recipes_ingredients ON crafting_recipes.id = crafting_recipes_ingredients.recipe_id " + - "WHERE crafting_recipes.enabled = ? ORDER BY altar_id ASC")) { + "WHERE crafting_recipes.enabled = ? ORDER BY altar_id ")) { statement.setString(1, "1"); try (ResultSet set = statement.executeQuery()) { while (set.next()) { @@ -56,14 +54,14 @@ public class CraftingManager { recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount")); altar.addIngredient(ingredientItem); } else { - LOGGER.error("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); + log.error("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); } } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -71,15 +69,12 @@ public class CraftingManager { final int[] i = {0}; synchronized (this.altars) { - this.altars.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CraftingAltar altar) { - if (altar.hasIngredient(item)) { - i[0]++; - } - - return true; + this.altars.forEachValue(altar -> { + if (altar.hasIngredient(item)) { + i[0]++; } + + return true; }); } @@ -117,7 +112,7 @@ public class CraftingManager { } statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.altars.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java index 286dfb62..2dffae90 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java @@ -3,18 +3,27 @@ package com.eu.habbo.habbohotel.crafting; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import gnu.trove.map.hash.THashMap; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; public class CraftingRecipe { + @Getter private final int id; + @Getter private final String name; + @Getter private final Item reward; + @Getter private final boolean secret; + @Getter private final String achievement; + @Getter private final boolean limited; + @Getter private final THashMap ingredients; + @Getter private int remaining; public CraftingRecipe(ResultSet set) throws SQLException { @@ -30,7 +39,7 @@ public class CraftingRecipe { } public boolean canBeCrafted() { - return !this.limited || this.remaining > 0; + return this.limited && this.remaining <= 0; } public synchronized boolean decrease() { @@ -54,35 +63,4 @@ public class CraftingRecipe { return this.ingredients.containsKey(item); } - public int getId() { - return this.id; - } - - public String getName() { - return this.name; - } - - public Item getReward() { - return this.reward; - } - - public boolean isSecret() { - return this.secret; - } - - public String getAchievement() { - return this.achievement; - } - - public boolean isLimited() { - return this.limited; - } - - public THashMap getIngredients() { - return this.ingredients; - } - - public int getRemaining() { - return this.remaining; - } } \ No newline at end of file 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 a05ef0a0..be3f12f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -7,24 +7,28 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.MessageComposer; import io.netty.channel.Channel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; +@Slf4j public class GameClient { - - private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); - + + @Getter private final Channel channel; + @Getter private final HabboEncryption encryption; + @Setter + @Getter private Habbo habbo; + @Setter + @Getter private boolean handshakeFinished; + @Getter private String machineId = ""; public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); @@ -41,41 +45,6 @@ public class GameClient { : 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) { this.sendResponse(composer.compose()); @@ -119,7 +88,16 @@ public class GameClient { this.habbo = null; } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } + + public void setMachineId(String machineId) { + if (machineId == null) { + throw new RuntimeException("Cannot set machineID to NULL"); + } + + this.machineId = machineId; + } + } \ 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 ad9b28ff..056c566b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java @@ -4,7 +4,11 @@ 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.channel.Channel; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelId; +import lombok.Getter; import java.util.ArrayList; import java.util.List; @@ -13,6 +17,7 @@ import java.util.concurrent.ConcurrentMap; public class GameClientManager { + @Getter private final ConcurrentMap clients; public GameClientManager() { @@ -20,19 +25,10 @@ public class GameClientManager { } - public ConcurrentMap getSessions() { - return this.clients; - } - public boolean addClient(ChannelHandlerContext ctx) { GameClient client = new GameClient(ctx.channel()); - ctx.channel().closeFuture().addListener(new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture channelFuture) throws Exception { - GameClientManager.this.disposeClient(ctx.channel()); - } - }); + ctx.channel().closeFuture().addListener((ChannelFutureListener) channelFuture -> GameClientManager.this.disposeClient(ctx.channel())); ctx.channel().attr(GameServerAttributes.CLIENT).set(client); ctx.fireChannelRegistered(); 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 a7219978..aa50cea7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; -import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry; import com.eu.habbo.messages.outgoing.guides.YouArePlayingGameMessageComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.games.GameHabboJoinEvent; @@ -20,14 +20,13 @@ 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 lombok.extern.slf4j.Slf4j; import java.util.Map; import java.util.stream.Collectors; +@Slf4j public abstract class Game implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(Game.class); protected final THashMap teams = new THashMap<>(); protected final Room room; private final Class gameTeamClazz; @@ -75,7 +74,7 @@ public abstract class Game implements Runnable { return true; } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return false; 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 143974dd..794160ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -1,9 +1,6 @@ package com.eu.habbo.habbohotel.games; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.plugin.Event; -import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent; import gnu.trove.set.hash.THashSet; public class GameTeam { 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 c82796c1..33f83e3b 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,26 +17,21 @@ import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; 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 lombok.extern.slf4j.Slf4j; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; +@Slf4j public class BattleBanzaiGame extends Game { - private static final Logger LOGGER = LoggerFactory.getLogger(BattleBanzaiGame.class); - - + public static final int effectId = 32; - - + public static final int POINTS_HIJACK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.steal", 0); - - + public static final int POINTS_FILL_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.fill", 0); - - + public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock", 1); private static final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Emulator.getConfig().getInt("hotel.banzai.fill.threads", 2)); @@ -165,7 +160,7 @@ public class BattleBanzaiGame extends Game { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -283,7 +278,7 @@ public class BattleBanzaiGame extends Game { if (largestAreaOfAll.isPresent()) { for (RoomTile tile : largestAreaOfAll.get()) { - Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny(); + Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.getX() && i.getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny(); tileItem.ifPresent(habboItem -> { this.tileLocked(teamColor, habboItem, habbo, true); @@ -375,7 +370,7 @@ public class BattleBanzaiGame extends Game { scoreboard.setExtradata("0"); } - int oldScore = Integer.valueOf(scoreboard.getExtradata()); + int oldScore = Integer.parseInt(scoreboard.getExtradata()); if (oldScore == totalScore) continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java index 2156e471..94725332 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java @@ -38,7 +38,7 @@ public class BattleBanzaiGameTeam extends GameTeam { RoomUnit roomUnit = habbo.getRoomUnit(); Room room = roomUnit.getRoom(); if(room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; 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 1f341d45..262f48db 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 @@ -21,17 +21,14 @@ import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.threading.runnables.freeze.FreezeClearEffects; 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 lombok.extern.slf4j.Slf4j; import java.util.HashMap; import java.util.Map; +@Slf4j public class FreezeGame extends Game { - private static final Logger LOGGER = LoggerFactory.getLogger(FreezeGame.class); - public static final int effectId = 39; public static int POWER_UP_POINTS; @@ -113,7 +110,7 @@ public class FreezeGame extends Game { for (int j = 0; j < radius; j++) { t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), rotatation, j); - if (t == null || t.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY()) + if (t == null || t.getX() < 0 || t.getY() < 0 || t.getX() >= this.room.getLayout().getMapSizeX() || t.getY() >= this.room.getLayout().getMapSizeY()) continue; tiles.add(t); @@ -127,13 +124,13 @@ public class FreezeGame extends Game { THashSet tiles = new THashSet<>(); for (int rotation = 1; rotation < 9; rotation += 2) { - RoomTile t = this.room.getLayout().getTile(x, y); + RoomTile t; for (int j = 0; j < radius; j++) { t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), rotation, j); if (t != null) { - if (t.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY()) + if (t.getX() < 0 || t.getY() < 0 || t.getX() >= this.room.getLayout().getMapSizeX() || t.getY() >= this.room.getLayout().getMapSizeY()) continue; tiles.add(t); @@ -159,37 +156,16 @@ public class FreezeGame extends Game { player.addScore(FreezeGame.POWER_UP_POINTS); switch (powerUpId) { - case 2: { - player.increaseExplosion(); - break; - } - - case 3: { - player.addSnowball(); - break; - } - - case 4: { - player.nextDiagonal = true; - break; - } - - case 5: { + case 2 -> player.increaseExplosion(); + case 3 -> player.addSnowball(); + case 4 -> player.nextDiagonal = true; + case 5 -> { player.nextHorizontal = true; player.nextDiagonal = true; player.tempMassiveExplosion = true; - break; - } - - case 6: { - player.addLife(); - break; - } - - case 7: { - player.addProtection(); - break; } + case 6 -> player.addLife(); + case 7 -> player.addProtection(); } } @@ -265,7 +241,7 @@ public class FreezeGame extends Game { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -318,13 +294,10 @@ public class FreezeGame extends Game { } public void setFreezeTileState(String state) { - this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(InteractionFreezeExitTile object) { - object.setExtradata(state); - FreezeGame.this.room.updateItemState(object); - return true; - } + this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(object -> { + object.setExtradata(state); + FreezeGame.this.room.updateItemState(object); + return true; }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java index 3b8964c2..7c14d9cb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java @@ -6,12 +6,14 @@ import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.GamePlayerValueMessageComposer; +import lombok.Getter; public class FreezeGamePlayer extends GamePlayer { public boolean nextDiagonal; public boolean nextHorizontal; public boolean tempMassiveExplosion; public boolean dead; + @Getter private int lives; private int snowBalls; private int explosionBoost; @@ -69,10 +71,6 @@ public class FreezeGamePlayer extends GamePlayer { } } - public int getLives() { - return this.lives; - } - public boolean canPickupLife() { return this.lives < 3; } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index dea71694..845a9bb6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; 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.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -29,7 +28,7 @@ public class FreezeGameTeam extends GameTeam { Room room = roomUnit.getRoom(); if(room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java index 68955a6e..f9ccdb67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java @@ -176,7 +176,7 @@ public abstract class TagGame extends Game { Room room = roomUnit.getRoom(); if (room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index f17de53a..9cb2a072 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -45,7 +45,7 @@ public class WiredGame extends Game { Room room = this.room; if (room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java index 4e2caa19..c9d578ad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java @@ -11,6 +11,7 @@ import com.eu.habbo.messages.outgoing.guides.GuideTicketResolutionMessageCompose import com.eu.habbo.threading.runnables.GuardianNotAccepted; import com.eu.habbo.threading.runnables.GuardianVotingFinish; import gnu.trove.map.hash.THashMap; +import lombok.Getter; import java.util.ArrayList; import java.util.Collections; @@ -18,16 +19,26 @@ import java.util.Date; import java.util.Map; public class GuardianTicket { + @Getter private final THashMap votes = new THashMap<>(); + @Getter private final Habbo reporter; + @Getter private final Habbo reported; + @Getter private final Date date; + @Getter private final ArrayList chatLogs; + @Getter private GuardianVoteType verdict; + @Getter private int timeLeft = 120; + @Getter private int resendCount = 0; - private int checkSum = 0; - private int guardianCount = 0; //TODO: Figure out what this was supposed to do. + @Getter + private final int checkSum = 0; + @Getter + private final int guardianCount = 0; //TODO: Figure out what this was supposed to do. public GuardianTicket(Habbo reporter, Habbo reported, ArrayList chatLogs) { this.chatLogs = chatLogs; @@ -185,46 +196,6 @@ public class GuardianTicket { return this.votes.get(guardian); } - public THashMap getVotes() { - return this.votes; - } - - public int getTimeLeft() { - return this.timeLeft; - } - - public GuardianVoteType getVerdict() { - return this.verdict; - } - - public ArrayList getChatLogs() { - return this.chatLogs; - } - - public int getResendCount() { - return this.resendCount; - } - - public int getCheckSum() { - return this.checkSum; - } - - public Habbo getReporter() { - return this.reporter; - } - - public Habbo getReported() { - return this.reported; - } - - public Date getDate() { - return this.date; - } - - public int getGuardianCount() { - return this.guardianCount; - } - public ArrayList getSortedVotes(Habbo guardian) { synchronized (this.votes) { diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java index 68d93ae3..f005c0f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java @@ -1,5 +1,9 @@ package com.eu.habbo.habbohotel.guides; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor public enum GuardianVoteType { FORWARDED(-1), WAITING(0), @@ -9,14 +13,7 @@ public enum GuardianVoteType { NOT_VOTED(4), SEARCHING(5); + @Getter private final int type; - GuardianVoteType(int type) { - this.type = type; - } - - public int getType() { - return this.type; - } - } diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuideChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuideChatMessage.java index 8011fdca..9dd21138 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuideChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuideChatMessage.java @@ -1,13 +1,12 @@ package com.eu.habbo.habbohotel.guides; -public class GuideChatMessage { - public final int userId; - public final String message; - public final int timestamp; +import lombok.AllArgsConstructor; +import lombok.Getter; - public GuideChatMessage(int userId, String message, int timestamp) { - this.userId = userId; - this.message = message; - this.timestamp = timestamp; - } +@Getter +@AllArgsConstructor +public class GuideChatMessage { + private final int userId; + private final String message; + private final int timestamp; } diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java index 8e52be22..2ef42c45 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java @@ -4,17 +4,28 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; public class GuideTour { + @Getter private final Habbo noob; + @Getter private final String helpRequest; private final THashSet sendMessages = new THashSet<>(); private final THashSet declinedHelpers = new THashSet<>(); public int checkSum = 0; + @Setter + @Getter private Habbo helper; + @Setter + @Getter private int startTime; + @Getter private int endTime; + @Getter private boolean ended; + @Getter private GuideRecommendStatus wouldRecommend = GuideRecommendStatus.UNKNOWN; public GuideTour(Habbo noob, String helpRequest) { @@ -29,30 +40,10 @@ public class GuideTour { //TODO Query messages. } - public Habbo getNoob() { - return this.noob; - } - - public String getHelpRequest() { - return this.helpRequest; - } - - public Habbo getHelper() { - return this.helper; - } - - public void setHelper(Habbo helper) { - this.helper = helper; - } - public void addMessage(GuideChatMessage message) { this.sendMessages.add(message); } - public GuideRecommendStatus getWouldRecommend() { - return this.wouldRecommend; - } - public void setWouldRecommend(GuideRecommendStatus wouldRecommend) { this.wouldRecommend = wouldRecommend; @@ -78,19 +69,4 @@ public class GuideTour { AchievementManager.progressAchievement(this.noob, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GuideRequester")); } - public boolean isEnded() { - return this.ended; - } - - public int getStartTime() { - return this.startTime; - } - - public void setStartTime(int startTime) { - this.startTime = startTime; - } - - public int getEndTime() { - return this.endTime; - } } 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 d77f6773..4a8d7cf9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java @@ -1,36 +1,65 @@ package com.eu.habbo.habbohotel.guilds; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class Guild implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(Guild.class); public boolean needsUpdate; public int lastRequested = Emulator.getIntUnixTimestamp(); + @Setter + @Getter private int id; - private int ownerId; - private String ownerName; + @Getter + private final int ownerId; + @Getter + private final String ownerName; + @Setter + @Getter private String name; + @Setter + @Getter private String description; - private int roomId; + @Getter + private final int roomId; + @Setter + @Getter private String roomName; + @Setter + @Getter private GuildState state; + @Setter + @Getter private boolean rights; + @Setter + @Getter private int colorOne; + @Setter + @Getter private int colorTwo; + @Setter + @Getter private String badge; - private int dateCreated; + @Getter + private final int dateCreated; + @Getter private int memberCount; + @Getter private int requestCount; - private boolean forum = false; + @Setter + private boolean hasForum = false; + @Setter private SettingsState readForum = SettingsState.ADMINS; + @Setter private SettingsState postMessages = SettingsState.ADMINS; + @Setter private SettingsState postThreads = SettingsState.ADMINS; private SettingsState modForum = SettingsState.ADMINS; @@ -48,7 +77,7 @@ public class Guild implements Runnable { this.colorTwo = set.getInt("color_two"); this.badge = set.getString("badge"); this.dateCreated = set.getInt("date_created"); - this.forum = set.getString("forum").equalsIgnoreCase("1"); + this.hasForum = set.getString("forum").equalsIgnoreCase("1"); this.readForum = SettingsState.valueOf(set.getString("read_forum")); this.postMessages = SettingsState.valueOf(set.getString("post_messages")); this.postThreads = SettingsState.valueOf(set.getString("post_threads")); @@ -94,7 +123,7 @@ public class Guild implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -104,7 +133,7 @@ public class Guild implements Runnable { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds SET name = ?, description = ?, state = ?, rights = ?, color_one = ?, color_two = ?, badge = ?, read_forum = ?, post_messages = ?, post_threads = ?, mod_forum = ?, forum = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.description); - statement.setInt(3, this.state.state); + statement.setInt(3, this.state.getState()); statement.setString(4, this.rights ? "1" : "0"); statement.setInt(5, this.colorOne); statement.setInt(6, this.colorTwo); @@ -113,109 +142,17 @@ public class Guild implements Runnable { statement.setString(9, this.postMessages.name()); statement.setString(10, this.postThreads.name()); statement.setString(11, this.modForum.name()); - statement.setString(12, this.forum ? "1" : "0"); + statement.setString(12, this.hasForum ? "1" : "0"); statement.setInt(13, this.id); statement.execute(); this.needsUpdate = false; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public String getOwnerName() { - return this.ownerName; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public int getRoomId() { - return this.roomId; - } - - public String getRoomName() { - return this.roomName; - } - - public void setRoomName(String roomName) { - this.roomName = roomName; - } - - public GuildState getState() { - return this.state; - } - - public void setState(GuildState state) { - this.state = state; - } - - public boolean getRights() { - return this.rights; - } - - public void setRights(boolean rights) { - this.rights = rights; - } - - public int getColorOne() { - return this.colorOne; - } - - public void setColorOne(int colorOne) { - this.colorOne = colorOne; - } - - public int getColorTwo() { - return this.colorTwo; - } - - public void setColorTwo(int colorTwo) { - this.colorTwo = colorTwo; - } - - public String getBadge() { - return this.badge; - } - - public void setBadge(String badge) { - this.badge = badge; - } - - public int getOwnerId() { - return this.ownerId; - } - - public int getDateCreated() { - return dateCreated; - } - - public int getMemberCount() { - return this.memberCount; - } - public void increaseMemberCount() { this.memberCount++; } @@ -224,10 +161,6 @@ public class Guild implements Runnable { this.memberCount--; } - public int getRequestCount() { - return this.requestCount; - } - public void increaseRequestCount() { this.requestCount++; } @@ -237,37 +170,21 @@ public class Guild implements Runnable { } public boolean hasForum() { - return this.forum; - } - - public void setForum(boolean forum) { - this.forum = forum; + return this.hasForum; } public SettingsState canReadForum() { return this.readForum; } - public void setReadForum(SettingsState readForum) { - this.readForum = readForum; - } - public SettingsState canPostMessages() { return this.postMessages; } - public void setPostMessages(SettingsState postMessages) { - this.postMessages = postMessages; - } - public SettingsState canPostThreads() { return this.postThreads; } - public void setPostThreads(SettingsState postThreads) { - this.postThreads = postThreads; - } - public SettingsState canModForum() { return this.modForum; } 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 b93c75de..d23dfc5b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -13,17 +13,15 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.*; import java.util.stream.Collectors; +@Slf4j public class GuildManager { - private static final Logger LOGGER = LoggerFactory.getLogger(GuildManager.class); - private final THashMap> guildParts; private final TIntObjectMap guilds; @@ -32,13 +30,13 @@ public class GuildManager { public GuildManager() { long millis = System.currentTimeMillis(); - this.guildParts = new THashMap>(); - this.guilds = TCollections.synchronizedMap(new TIntObjectHashMap()); + this.guildParts = new THashMap<>(); + this.guilds = TCollections.synchronizedMap(new TIntObjectHashMap<>()); this.loadGuildParts(); this.loadGuildViews(); - LOGGER.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -56,7 +54,7 @@ public class GuildManager { this.guildParts.get(GuildPartType.valueOf(set.getString("type").toUpperCase())).put(set.getInt("id"), new GuildPart(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -70,7 +68,7 @@ public class GuildManager { this.views.add(new ForumView(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -111,7 +109,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } habbo.getHabboStats().addGuild(guild.getId()); @@ -129,8 +127,8 @@ public class GuildManager { if (habbo != null) { habbo.getHabboStats().removeGuild(guild.getId()); - if (habbo.getHabboStats().guild == guild.getId()) { - habbo.getHabboStats().guild = 0; + if (habbo.getHabboStats().getGuild() == guild.getId()) { + habbo.getHabboStats().setGuild(0); } } } @@ -156,16 +154,16 @@ public class GuildManager { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); if (room != null) { - room.setGuild(0); + room.setGuildId(0); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public void clearInactiveGuilds() { - List toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); TIntObjectIterator guilds = this.guilds.iterator(); for (int i = this.guilds.size(); i-- > 0; ) { try { @@ -256,13 +254,13 @@ public class GuildManager { statement.setInt(1, guild.getId()); statement.setInt(2, client.getHabbo().getHabboInfo().getId()); statement.setInt(3, Emulator.getIntUnixTimestamp()); - statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type); + statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.getType() : GuildRank.MEMBER.getType()); statement.execute(); } } } else if (!error) { try (PreparedStatement statement = connection.prepareStatement("UPDATE guilds_members SET level_id = ?, member_since = ? WHERE user_id = ? AND guild_id = ?")) { - statement.setInt(1, GuildRank.MEMBER.type); + statement.setInt(1, GuildRank.MEMBER.getType()); statement.setInt(2, Emulator.getIntUnixTimestamp()); statement.setInt(3, userId); statement.setInt(4, guild.getId()); @@ -280,7 +278,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return !error; @@ -294,7 +292,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -309,7 +307,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -320,9 +318,9 @@ public class GuildManager { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null && habbo.getHabboStats().guild == guild.getId()) { + if (habbo != null && habbo.getHabboStats().getGuild() == guild.getId()) { habbo.getHabboStats().removeGuild(guild.getId()); - habbo.getHabboStats().guild = 0; + habbo.getHabboStats().setGuild(0); habbo.getHabboStats().run(); } @@ -331,7 +329,7 @@ public class GuildManager { statement.setInt(2, guild.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -358,7 +356,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return member; @@ -371,7 +369,7 @@ public class GuildManager { THashSet getGuildMembers(Guild guild) { - THashSet guildMembers = new THashSet(); + THashSet guildMembers = new THashSet<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.look, guilds_members.* FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ?")) { statement.setInt(1, guild.getId()); @@ -381,7 +379,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return guildMembers; @@ -389,7 +387,7 @@ public class GuildManager { public ArrayList getGuildMembers(Guild guild, int page, int levelId, String query) { - ArrayList guildMembers = new ArrayList(); + ArrayList guildMembers = new ArrayList<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.look, guilds_members.* FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ? " + (rankQuery(levelId)) + " AND users.username LIKE ? ORDER BY level_id, member_since ASC LIMIT ?, ?")) { statement.setInt(1, guild.getId()); @@ -403,14 +401,13 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return guildMembers; } - public int getGuildMembersCount(Guild guild, int page, int levelId, String query) { - ArrayList guildMembers = new ArrayList(); + public int getGuildMembersCount(Guild guild, int levelId, String query) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ? " + (rankQuery(levelId)) + " AND users.username LIKE ? ORDER BY level_id, member_since ASC")) { statement.setInt(1, guild.getId()); @@ -422,7 +419,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return 0; @@ -430,7 +427,7 @@ public class GuildManager { public THashMap getOnlyAdmins(Guild guild) { - THashMap guildAdmins = new THashMap(); + THashMap guildAdmins = new THashMap<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.look, guilds_members.* FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ? " + (rankQuery(1)))) { statement.setInt(1, guild.getId()); @@ -440,21 +437,18 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return guildAdmins; } private String rankQuery(int level) { - switch (level) { - case 2: - return "AND guilds_members.level_id = 3"; - case 1: - return "AND (guilds_members.level_id = 0 OR guilds_members.level_id = 1)"; - default: - return "AND guilds_members.level_id >= 0 AND guilds_members.level_id <= 2"; - } + return switch (level) { + case 2 -> "AND guilds_members.level_id = 3"; + case 1 -> "AND (guilds_members.level_id = 0 OR guilds_members.level_id = 1)"; + default -> "AND guilds_members.level_id >= 0 AND guilds_members.level_id <= 2"; + }; } @@ -472,7 +466,7 @@ public class GuildManager { if (g != null) g.loadMemberCount(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -486,7 +480,7 @@ public class GuildManager { } public List getGuilds(int userId) { - List guilds = new ArrayList(); + List guilds = new ArrayList<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM guilds_members WHERE user_id = ? AND level_id <= 2 ORDER BY member_since ASC")) { statement.setInt(1, userId); @@ -500,14 +494,14 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return guilds; } public List getAllGuilds() { - List guilds = new ArrayList(); + List guilds = new ArrayList<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM guilds ORDER BY id DESC LIMIT 20")) { try (ResultSet set = statement.executeQuery()) { @@ -520,7 +514,7 @@ public class GuildManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return guilds; @@ -528,7 +522,7 @@ public class GuildManager { public boolean symbolColor(int colorId) { for (GuildPart part : this.getSymbolColors()) { - if (part.id == colorId) + if (part.getId() == colorId) return true; } @@ -537,7 +531,7 @@ public class GuildManager { public boolean backgroundColor(int colorId) { for (GuildPart part : this.getBackgroundColors()) { - if (part.id == colorId) + if (part.getId() == colorId) return true; } return false; @@ -599,7 +593,7 @@ public class GuildManager { statement.setInt(2, furni.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -614,7 +608,7 @@ public class GuildManager { guildIterator.remove(); } - LOGGER.info("Guild Manager -> Disposed!"); + log.info("Guild Manager -> Disposed!"); } public boolean hasViewedForum(int userId, int guildId) { @@ -634,7 +628,7 @@ public class GuildManager { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java index 5b0d9ee3..143aaa6a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java @@ -1,13 +1,24 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.Getter; +import lombok.Setter; + import java.sql.ResultSet; import java.sql.SQLException; public class GuildMember implements Comparable { + @Getter private final int userId; + @Getter private final String username; + @Getter + @Setter private String look; + @Getter + @Setter private int joinDate; + @Setter + @Getter private GuildRank rank; public GuildMember(ResultSet set) throws SQLException { @@ -26,38 +37,6 @@ public class GuildMember implements Comparable { this.rank = GuildRank.values()[guildRank]; } - public int getUserId() { - return userId; - } - - public String getUsername() { - return username; - } - - public String getLook() { - return look; - } - - public void setLook(String look) { - this.look = look; - } - - public int getJoinDate() { - return joinDate; - } - - public void setJoinDate(int joinDate) { - this.joinDate = joinDate; - } - - public GuildRank getRank() { - return rank; - } - - public void setRank(GuildRank rank) { - this.rank = rank; - } - @Override public int compareTo(GuildMember o) { return this.userId - o.userId; diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java index e6cb38f7..8dff47de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java @@ -1,17 +1,15 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor public enum GuildMembershipStatus { NOT_MEMBER(0), MEMBER(1), PENDING(2); - private int status; + @Getter + private final int status; - GuildMembershipStatus(int status) { - this.status = status; - } - - public int getStatus() { - return status; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java index 2595c37d..270edd75 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java @@ -1,17 +1,17 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@Getter public class GuildPart { + private final int id; - public final int id; + private final String valueA; - - public final String valueA; - - - public final String valueB; + private final String valueB; public GuildPart(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java index a7afa1b1..127e7752 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum GuildRank { OWNER(0), ADMIN(1), @@ -7,11 +12,7 @@ public enum GuildRank { REQUESTED(3), DELETED(4); - public final int type; - - GuildRank(int type) { - this.type = type; - } + private final int type; public static GuildRank getRank(int type) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java index 7fcd74eb..f28fc87f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum GuildState { OPEN(0), EXCLUSIVE(1), @@ -7,11 +12,8 @@ public enum GuildState { LARGE(3), LARGE_CLOSED(4); - public final int state; + private final int state; - GuildState(int state) { - this.state = state; - } public static GuildState valueOf(int state) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java index 146606d3..0582eeed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java @@ -1,16 +1,17 @@ package com.eu.habbo.habbohotel.guilds; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum SettingsState { EVERYONE(0), MEMBERS(1), ADMINS(2), OWNER(3); - public final int state; - - SettingsState(int state) { - this.state = state; - } + private final int state; public static SettingsState fromValue(int state) { try { @@ -24,7 +25,7 @@ public enum SettingsState { case 3: return OWNER; } - } catch (Exception e) { + } catch (Exception ignored) { } return EVERYONE; 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 a65eb87b..64eb975a 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,33 +9,48 @@ 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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.*; +@Slf4j + public class ForumThread implements Runnable, ISerialize { - private static final Logger LOGGER = LoggerFactory.getLogger(ForumThread.class); private final static THashMap> guildThreadsCache = new THashMap<>(); private final static THashMap forumThreadsCache = new THashMap<>(); + @Getter private final int threadId; + @Getter private final int guildId; + @Getter private final int openerId; + @Getter private final String subject; + @Getter private final int createdAt; private final THashMap comments; + @Getter private int postsCount; + @Getter private int updatedAt; + @Getter private ForumThreadState state; + @Getter private boolean pinned; + @Getter private boolean locked; + @Getter private int adminId; private boolean needsUpdate; private boolean hasCommentsLoaded; private int commentIndex; + @Setter + @Getter private ForumThreadComment lastComment; public ForumThread(int threadId, int guildId, int openerId, String subject, int postsCount, int createdAt, int updatedAt, ForumThreadState state, boolean pinned, boolean locked, int adminId, ForumThreadComment lastComment) { @@ -74,7 +89,7 @@ public class ForumThread implements Runnable, ISerialize { try { this.lastComment = ForumThreadComment.getById(set.getInt("last_comment_id")); } catch (SQLException e) { - LOGGER.error("ForumThread last_comment_id exception", e); + log.error("ForumThread last_comment_id exception", e); } this.comments = new THashMap<>(); @@ -113,7 +128,7 @@ public class ForumThread implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return createdThread; @@ -159,7 +174,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return threads; @@ -184,7 +199,7 @@ public class ForumThread implements Runnable, ISerialize { "ORDER BY B.`id` " + ") " + "ORDER BY `id` DESC " + - ") B ON A.`id` = B.`thread_id` " + + ") B ON A.`iód` = B.`thread_id` " + "WHERE A.`id` = ? " + "ORDER BY A.`pinned` DESC, B.`created_at` DESC " + "LIMIT 1" @@ -198,7 +213,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return foundThread; @@ -236,88 +251,36 @@ public class ForumThread implements Runnable, ISerialize { } } - public int getThreadId() { - return threadId; - } - - public int getGuildId() { - return guildId; - } - - public int getOpenerId() { - return openerId; - } - - public String getSubject() { - return subject; - } - - public int getCreatedAt() { - return createdAt; - } - - public int getPostsCount() { - return postsCount; - } - public void setPostsCount(int postsCount) { this.postsCount = postsCount; this.needsUpdate = true; } - public int getUpdatedAt() { - return updatedAt; - } - public void setUpdatedAt(int updatedAt) { this.updatedAt = updatedAt; this.needsUpdate = true; } - public ForumThreadState getState() { - return state; - } - public void setState(ForumThreadState state) { this.state = state; this.needsUpdate = true; } - public boolean isPinned() { - return pinned; - } - public void setPinned(boolean pinned) { this.pinned = pinned; this.needsUpdate = true; } - public boolean isLocked() { - return locked; - } - public void setLocked(boolean locked) { this.locked = locked; this.needsUpdate = true; } - public int getAdminId() { - return adminId; - } - public void setAdminId(int adminId) { this.adminId = adminId; this.needsUpdate = true; } - public ForumThreadComment getLastComment() { - return lastComment; - } - - public void setLastComment(ForumThreadComment lastComment) { - this.lastComment = lastComment; - } - private void loadComments() { if (this.hasCommentsLoaded) return; @@ -337,7 +300,7 @@ public class ForumThread implements Runnable, ISerialize { addComment(comment); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -461,7 +424,7 @@ public class ForumThread implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 1be9631a..507ad8ef 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,24 +8,34 @@ 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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j public class ForumThreadComment implements Runnable, ISerialize { - private static final Logger LOGGER = LoggerFactory.getLogger(ForumThreadComment.class); - private static THashMap forumCommentsCache = new THashMap<>(); + private static final THashMap forumCommentsCache = new THashMap<>(); + @Getter private final int commentId; + @Getter private final int threadId; + @Getter private final int userId; + @Getter private final String message; + @Getter private final int createdAt; + @Getter private ForumThreadState state; + @Getter private int adminId; - private int index; - private boolean needsUpdate; + @Setter + @Getter + private int index = -1; + private boolean needsUpdate = false; public ForumThreadComment(int commentId, int threadId, int userId, String message, int createdAt, ForumThreadState state, int adminId) { this.commentId = commentId; @@ -35,8 +45,6 @@ public class ForumThreadComment implements Runnable, ISerialize { this.createdAt = createdAt; this.state = state; this.adminId = adminId; - this.index = -1; - this.needsUpdate = false; } public ForumThreadComment(ResultSet set) throws SQLException { @@ -67,7 +75,7 @@ public class ForumThreadComment implements Runnable, ISerialize { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return foundComment; @@ -106,58 +114,22 @@ public class ForumThreadComment implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return createdComment; } - public int getCommentId() { - return commentId; - } - - public int getThreadId() { - return threadId; - } - - public int getUserId() { - return userId; - } - - public String getMessage() { - return message; - } - - public int getCreatedAt() { - return createdAt; - } - - public ForumThreadState getState() { - return state; - } - public void setState(ForumThreadState state) { this.state = state; this.needsUpdate = true; } - public int getAdminId() { - return adminId; - } - public void setAdminId(int adminId) { this.adminId = adminId; this.needsUpdate = true; } - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - public Habbo getHabbo() { return Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId); } @@ -187,7 +159,7 @@ public class ForumThreadComment implements Runnable, ISerialize { message.appendInt(this.adminId); message.appendString(admin != null ? admin.getUsername() : ""); message.appendInt(0); // admin action time ago? - message.appendInt(habbo != null ? habbo.getHabboStats().forumPostsCount : 0); + message.appendInt(habbo != null ? habbo.getHabboStats().getForumPostsCount() : 0); } @Override @@ -203,7 +175,7 @@ public class ForumThreadComment implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java index 2e57039e..a089209f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java @@ -1,16 +1,18 @@ package com.eu.habbo.habbohotel.guilds.forums; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor public enum ForumThreadState { OPEN(0), CLOSED(1), HIDDEN_BY_STAFF_MEMBER(10), HIDDEN_BY_GUILD_ADMIN(20); + @Getter private int stateId; - ForumThreadState(int stateId) { - this.stateId = stateId; - } public static ForumThreadState fromValue(int value) { for (ForumThreadState state : ForumThreadState.values()) { @@ -22,7 +24,4 @@ public enum ForumThreadState { return CLOSED; } - public int getStateId() { - return this.stateId; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java index c1b2569e..66dba2ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java @@ -1,34 +1,24 @@ package com.eu.habbo.habbohotel.guilds.forums; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@AllArgsConstructor public class ForumView { + @Getter private final int userId; + @Getter private final int guildId; + @Getter private final int timestamp; - public ForumView(int userId, int guildId, int timestamp) { - this.userId = userId; - this.guildId = guildId; - this.timestamp = timestamp; - } - public ForumView(ResultSet set) throws SQLException { this.userId = set.getInt("user_id"); this.guildId = set.getInt("guild_id"); this.timestamp = set.getInt("timestamp"); } - public int getUserId() { - return userId; - } - - public int getGuildId() { - return guildId; - } - - public int getTimestamp() { - return timestamp; - } } 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 a4c398b8..81b5d187 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java @@ -2,20 +2,23 @@ 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 lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +@Slf4j public class HallOfFame { - private static final Logger LOGGER = LoggerFactory.getLogger(HallOfFame.class); - + @Getter private final THashMap winners = new THashMap<>(); + @Getter + @Setter private String competitionName; public HallOfFame() { @@ -35,20 +38,9 @@ public class HallOfFame { this.winners.put(winner.getId(), winner); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } - public THashMap getWinners() { - return this.winners; - } - - public String getCompetitionName() { - return this.competitionName; - } - - void setCompetitionName(String name) { - this.competitionName = name; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java index 998de6f2..6b6568bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java @@ -1,20 +1,19 @@ package com.eu.habbo.habbohotel.hotelview; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; public class HallOfFameWinner implements Comparable { - - private int id; - - - private String username; - - - private String look; - - - private int points; + @Getter + private final int id; + @Getter + private final String username; + @Getter + private final String look; + @Getter + private final int points; public HallOfFameWinner(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -24,25 +23,6 @@ public class HallOfFameWinner implements Comparable { } - public int getId() { - return this.id; - } - - - public String getUsername() { - return this.username; - } - - - public String getLook() { - return this.look; - } - - - public int getPoints() { - return this.points; - } - @Override public int compareTo(HallOfFameWinner o) { return o.getPoints() - this.points; 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 81048f3b..94414cfd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java @@ -1,13 +1,14 @@ package com.eu.habbo.habbohotel.hotelview; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class HotelViewManager { - private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewManager.class); - + @Getter private final HallOfFame hallOfFame; + @Getter private final NewsList newsList; public HotelViewManager() { @@ -15,19 +16,11 @@ public class HotelViewManager { this.hallOfFame = new HallOfFame(); this.newsList = new NewsList(); - LOGGER.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis); - } - - public HallOfFame getHallOfFame() { - return this.hallOfFame; - } - - public NewsList getNewsList() { - return this.newsList; + log.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis); } public void dispose() { - LOGGER.info("HotelView Manager -> Disposed!"); + log.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 b3bebc4f..6a2bfa35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java @@ -1,18 +1,15 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; - +@Slf4j public class NewsList { - private static final Logger LOGGER = LoggerFactory.getLogger(NewsList.class); - private final ArrayList newsWidgets; public NewsList() { @@ -29,7 +26,7 @@ public class NewsList { this.newsWidgets.add(new NewsWidget(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java index bb309763..17e353b6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java @@ -1,29 +1,31 @@ package com.eu.habbo.habbohotel.hotelview; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; public class NewsWidget { + @Getter + private final int id; - private int id; + @Getter + private final String title; + @Getter + private final String message; - private String title; + @Getter + private final String buttonMessage; + @Getter + private final int type; - private String message; + @Getter + private final String link; - - private String buttonMessage; - - - private int type; - - - private String link; - - - private String image; + @Getter + private final String image; public NewsWidget(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -34,39 +36,4 @@ public class NewsWidget { this.link = set.getString("button_link"); this.image = set.getString("image"); } - - - public int getId() { - return this.id; - } - - - public String getTitle() { - return this.title; - } - - - public String getMessage() { - return this.message; - } - - - public String getButtonMessage() { - return this.buttonMessage; - } - - - public int getType() { - return this.type; - } - - - public String getLink() { - return this.link; - } - - - public String getImage() { - return this.image; - } } 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 60497794..ae983cb2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,18 +10,18 @@ import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; +@Slf4j +@Getter public class CrackableReward { - private static final Logger LOGGER = LoggerFactory.getLogger(CrackableReward.class); - - public final int itemId; - public final int count; - public final Map> prizes; - public final String achievementTick; - public final String achievementCracked; - public final int requiredEffect; - public final int subscriptionDuration; - public final RedeemableSubscriptionType subscriptionType; - public int totalChance; + private final int itemId; + private final int count; + private final Map> prizes; + private final String achievementTick; + private final String achievementCracked; + private final int requiredEffect; + private final int subscriptionDuration; + private final RedeemableSubscriptionType subscriptionType; + private int totalChance; public CrackableReward(ResultSet set) throws SQLException { this.itemId = set.getInt("item_id"); @@ -45,18 +45,18 @@ public class CrackableReward { int chance = 100; if (prize.contains(":") && prize.split(":").length == 2) { - itemId = Integer.valueOf(prize.split(":")[0]); - chance = Integer.valueOf(prize.split(":")[1]); + itemId = Integer.parseInt(prize.split(":")[0]); + chance = Integer.parseInt(prize.split(":")[1]); } else if (prize.contains(":")) { - LOGGER.error("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance."); + log.error("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance."); } else { - itemId = Integer.valueOf(prize.replace(":", "")); + itemId = Integer.parseInt(prize.replace(":", "")); } this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance)); this.totalChance += chance; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java b/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java index f22fc5bf..0a74151a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.items; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum FurnitureType { FLOOR("S"), WALL("I"), @@ -11,29 +16,17 @@ public enum FurnitureType { public final String code; - FurnitureType(String code) { - this.code = code; - } - public static FurnitureType fromString(String code) { - switch (code.toUpperCase()) { - case "S": - return FLOOR; - case "I": - return WALL; - case "E": - return EFFECT; - case "B": - return BADGE; - case "R": - return ROBOT; - case "H": - return HABBO_CLUB; - case "P": - return PET; - default: - return FLOOR; - } + return switch (code.toUpperCase()) { + case "S" -> FLOOR; + case "I" -> WALL; + case "E" -> EFFECT; + case "B" -> BADGE; + case "R" -> ROBOT; + case "H" -> HABBO_CLUB; + case "P" -> PET; + default -> FLOOR; + }; } } \ No newline at end of file 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 11d19294..bfb3c6a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -6,19 +6,28 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import gnu.trove.list.array.TIntArrayList; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; public class Item implements ISerialize { + @Getter private int id; + @Getter private int spriteId; + @Getter private String name; + @Getter private String fullName; + @Getter private FurnitureType type; + @Getter private short width; + @Getter private short length; + @Getter private double height; private boolean allowStack; private boolean allowWalk; @@ -29,15 +38,24 @@ public class Item implements ISerialize { private boolean allowMarketplace; private boolean allowGift; private boolean allowInventoryStack; + @Getter private short stateCount; + @Getter private short effectM; + @Getter private short effectF; + @Getter private TIntArrayList vendingItems; + @Getter private double[] multiHeights; + @Getter private String customParams; + @Getter private String clothingOnWalk; + @Getter private ItemInteraction interactionType; + @Getter private int rotations; public Item(ResultSet set) throws SQLException { @@ -55,9 +73,9 @@ public class Item implements ISerialize { } try { - int index = Integer.valueOf(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length); + int index = Integer.parseInt(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length); return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)]; - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { } } @@ -103,7 +121,7 @@ public class Item implements ISerialize { this.vendingItems = new TIntArrayList(); String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(","); for (String s : vendingIds) { - this.vendingItems.add(Integer.valueOf(s.replace(" ", ""))); + this.vendingItems.add(Integer.parseInt(s.replace(" ", ""))); } } @@ -129,38 +147,6 @@ public class Item implements ISerialize { catch (SQLException ignored) { } } - public int getId() { - return this.id; - } - - public int getSpriteId() { - return this.spriteId; - } - - public String getName() { - return this.name; - } - - public String getFullName() { - return this.fullName; - } - - public FurnitureType getType() { - return this.type; - } - - public int getWidth() { - return this.width; - } - - public int getLength() { - return this.length; - } - - public double getHeight() { - return this.height; - } - public boolean allowStack() { return this.allowStack; } @@ -197,44 +183,10 @@ public class Item implements ISerialize { return this.allowInventoryStack; } - public int getStateCount() { - return this.stateCount; - } - - public int getEffectM() { - return this.effectM; - } - - public int getEffectF() { - return this.effectF; - } - - public ItemInteraction getInteractionType() { - return this.interactionType; - } - - public TIntArrayList getVendingItems() { - return this.vendingItems; - } - public int getRandomVendingItem() { return this.vendingItems.get(Emulator.getRandom().nextInt(this.vendingItems.size())); } - public double[] getMultiHeights() { - return this.multiHeights; - } - - public String getCustomParams() { - return customParams; - } - - public String getClothingOnWalk() { return clothingOnWalk; } - - public int getRotations() { - return rotations; - } - @Override public void serialize(ServerMessage message) { message.appendString(this.type.code.toLowerCase()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java index 2e07ba22..fd32de85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java @@ -1,24 +1,13 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +import lombok.Getter; +@AllArgsConstructor public class ItemInteraction { + @Getter private final String name; + @Getter private final Class type; - - - public ItemInteraction(String name, Class type) { - this.name = name; - this.type = type; - } - - - public Class getType() { - return this.type; - } - - - public String getName() { - return this.name; - } } 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 52d85647..01eb1c77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.*; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiPuck; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateBlue; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateGreen; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateRed; @@ -47,10 +50,10 @@ import com.eu.habbo.habbohotel.items.interactions.wired.effects.*; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen; -import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -60,20 +63,20 @@ 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 lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Constructor; import java.sql.*; import java.util.*; +@Slf4j public class ItemManager { - private static final Logger LOGGER = LoggerFactory.getLogger(ItemManager.class); - //Configuration. Loaded from database & updated accordingly. public static boolean RECYCLER_ENABLED = true; + @Getter private final TIntObjectMap items; private final TIntObjectHashMap crackableRewards; private final THashSet interactionsList; @@ -105,7 +108,7 @@ public class ItemManager { this.highscoreManager.load(); this.loadNewUserGifts(); - LOGGER.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } protected void loadItemInteractions() { @@ -364,7 +367,7 @@ public class ItemManager { return interaction; } - LOGGER.debug("Can't find interaction class: {}", type.getName()); + log.debug("Can't find interaction class: {}", type.getName()); return this.getItemInteraction(InteractionDefault.class); } @@ -394,12 +397,12 @@ public class ItemManager { else this.items.get(id).update(set); } catch (Exception e) { - LOGGER.error("Failed to load Item ({})", set.getInt("id")); - LOGGER.error("Caught exception", e); + log.error("Failed to load Item ({})", set.getInt("id")); + log.error("Caught exception", e); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -412,23 +415,23 @@ public class ItemManager { try { reward = new CrackableReward(set); } catch (Exception e) { - LOGGER.error("Failed to load items_crackable item_id = {}", set.getInt("item_id")); - LOGGER.error("Caught exception", e); + log.error("Failed to load items_crackable item_id = {}", set.getInt("item_id")); + log.error("Caught exception", e); continue; } this.crackableRewards.put(set.getInt("item_id"), reward); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } public int getCrackableCount(int itemId) { if (this.crackableRewards.containsKey(itemId)) - return this.crackableRewards.get(itemId).count; + return this.crackableRewards.get(itemId).getCount(); else return 0; } @@ -455,7 +458,7 @@ public class ItemManager { this.soundTracks.put(set.getString("code"), new SoundTrack(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -488,16 +491,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) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; } @@ -512,7 +515,7 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -537,7 +540,7 @@ public class ItemManager { statement.setInt(1, item.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -555,7 +558,7 @@ public class ItemManager { try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items_presents VALUES (?, ?)")) { while (set.next() && item == null) { preparedStatement.setInt(1, set.getInt(1)); - preparedStatement.setInt(2, Integer.valueOf(itemId)); + preparedStatement.setInt(2, Integer.parseInt(itemId)); preparedStatement.addBatch(); item = new InteractionDefault(set.getInt(1), habbo.getHabboInfo().getId(), Emulator.getGameEnvironment().getCatalogManager().ecotronItem, extradata, 0, 0); } @@ -564,7 +567,7 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return item; @@ -604,9 +607,9 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return item; @@ -618,7 +621,7 @@ public class ItemManager { statement.setInt(2, itemTwoId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -628,7 +631,7 @@ public class ItemManager { statement.setInt(2, hopper.getBaseItem().getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -643,7 +646,7 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return a; @@ -659,9 +662,9 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return item; @@ -677,12 +680,12 @@ public class ItemManager { if (itemClass != null) { try { - Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); + Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); c.setAccessible(true); return (HabboItem) c.newInstance(set, baseItem); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -706,7 +709,7 @@ public class ItemManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -722,7 +725,7 @@ public class ItemManager { return null; if (extraData.length() > 1000) { - LOGGER.error("Extradata exceeds maximum length of 1000 characters: {}", extraData); + log.error("Extradata exceeds maximum length of 1000 characters: {}", extraData); extraData = extraData.substring(0, 1000); } @@ -746,17 +749,13 @@ public class ItemManager { return this.items.get(itemId); } - public TIntObjectMap getItems() { - return this.items; - } - public Item getItem(String itemName) { TIntObjectIterator item = this.items.iterator(); for (int i = this.items.size(); i-- > 0; ) { try { item.advance(); - if (item.value().getName().toLowerCase().equals(itemName.toLowerCase())) { + if (item.value().getName().equalsIgnoreCase(itemName)) { return item.value(); } } catch (NoSuchElementException e) { @@ -779,7 +778,7 @@ public class ItemManager { this.items.clear(); this.highscoreManager.dispose(); - LOGGER.info("Item Manager -> Disposed!"); + log.info("Item Manager -> Disposed!"); } public List getInteractionList() { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java index 90aff433..eda6da13 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; @@ -12,9 +13,13 @@ import java.util.HashMap; import java.util.Map; public class NewUserGift implements ISerialize { + @Getter private final int id; + @Getter private final Type type; + @Getter private final String imageUrl; + @Getter private Map items = new HashMap<>(); public NewUserGift(ResultSet set) throws SQLException { @@ -59,22 +64,6 @@ public class NewUserGift implements ISerialize { } } - public int getId() { - return this.id; - } - - public Type getType() { - return this.type; - } - - public String getImageUrl() { - return this.imageUrl; - } - - public Map getItems() { - return this.items; - } - public enum Type { ITEM, ROOM diff --git a/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java b/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java index 4822d78b..9e1e335e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java @@ -1,26 +1,19 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public enum PostItColor { - BLUE("9CCEFF"), - - GREEN("9CFF9C"), - - PINK("FF9CFF"), - - YELLOW("FFFF33"); public final String hexColor; - PostItColor(String hexColor) { - this.hexColor = hexColor; - } - public static boolean isCustomColor(String color) { for (PostItColor postItColor : PostItColor.values()) { 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 bc9662a3..c6a92d37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java @@ -1,14 +1,15 @@ package com.eu.habbo.habbohotel.items; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.util.Arrays; +@Slf4j public class RandomStateParams { - private static final Logger LOGGER = LoggerFactory.getLogger(RandomStateParams.class); - + @Getter private int states = -1; + @Getter private int delay = -1; public RandomStateParams(String customparams) throws Exception { @@ -18,15 +19,9 @@ public class RandomStateParams { if (keyValue.length != 2) return; switch (keyValue[0]) { - case "states": - this.states = Integer.parseInt(keyValue[1]); - break; - case "delay": - this.delay = Integer.parseInt(keyValue[1]); - break; - default: - LOGGER.warn("RandomStateParams: unknown key: " + keyValue[0]); - break; + case "states" -> this.states = Integer.parseInt(keyValue[1]); + case "delay" -> this.delay = Integer.parseInt(keyValue[1]); + default -> log.warn("RandomStateParams: unknown key: " + keyValue[0]); } }); @@ -34,11 +29,4 @@ public class RandomStateParams { if (this.delay < 0) throw new Exception("RandomStateParams: states not defined"); } - public int getStates() { - return states; - } - - public int getDelay() { - return delay; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java index 6747e7bb..1a416e0b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java @@ -1,25 +1,23 @@ package com.eu.habbo.habbohotel.items; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RedeemableSubscriptionType { HABBO_CLUB("hc"), BUILDERS_CLUB("bc"); - public final String subscriptionType; - RedeemableSubscriptionType(String subscriptionType) { - this.subscriptionType = subscriptionType; - } - public static RedeemableSubscriptionType fromString(String subscriptionType) { if (subscriptionType == null) return null; - switch (subscriptionType) { - case "hc": - return HABBO_CLUB; - case "bc": - return BUILDERS_CLUB; - } + return switch (subscriptionType) { + case "hc" -> HABBO_CLUB; + case "bc" -> BUILDERS_CLUB; + default -> null; + }; - return null; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java b/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java index 53430c13..d65deb1b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java @@ -1,15 +1,18 @@ package com.eu.habbo.habbohotel.items; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@Getter public class SoundTrack { - private int id; - private String name; - private String author; - private String code; - private String data; - private int length; + private final int id; + private final String name; + private final String author; + private final String code; + private final String data; + private final int length; public SoundTrack(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -20,27 +23,5 @@ public class SoundTrack { this.length = set.getInt("length"); } - public int getId() { - return this.id; - } - public String getName() { - return this.name; - } - - public String getAuthor() { - return this.author; - } - - public String getCode() { - return this.code; - } - - public String getData() { - return this.data; - } - - public int getLength() { - return this.length; - } } 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 1352f763..02f0308c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -6,8 +6,9 @@ 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 lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; @@ -24,56 +25,24 @@ import java.util.ArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; - +@Slf4j public class YoutubeManager { - private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class); + @Getter + @AllArgsConstructor public static class YoutubeVideo { private final String id; private final int duration; - - YoutubeVideo(String id, int duration) { - this.id = id; - this.duration = duration; - } - - public String getId() { - return id; - } - - public int getDuration() { - return duration; - } } + @Getter + @AllArgsConstructor public static class YoutubePlaylist { private final String id; private final String name; private final String description; private final ArrayList videos; - YoutubePlaylist(String id, String name, String description, ArrayList videos) { - this.id = id; - this.name = name; - this.description = description; - this.videos = videos; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public ArrayList getVideos() { - return videos; - } } private final THashMap> playlists = new THashMap<>(); @@ -89,7 +58,7 @@ public class YoutubeManager { Emulator.getThreading().run(() -> { ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); - LOGGER.info("YouTube Manager -> Loading..."); + log.info("YouTube Manager -> Loading..."); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { try (ResultSet set = statement.executeQuery()) { @@ -108,25 +77,25 @@ public class YoutubeManager { this.addPlaylistToItem(itemId, playlist); } } catch (IOException e) { - LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); + log.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); } }); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } youtubeDataLoaderPool.shutdown(); try { if(!youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS)) - LOGGER.error("Youtube Manager -> Failed, timeout elapsed before termination!"); + log.error("Youtube Manager -> Failed, timeout elapsed before termination!"); } catch (InterruptedException e) { - LOGGER.error("Caught Exception", e); + log.error("Caught Exception", e); Thread.currentThread().interrupt(); - } finally { - LOGGER.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + }finally { + log.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } }); } @@ -143,7 +112,7 @@ public class YoutubeManager { BufferedReader playlistBR = new BufferedReader(playlistISR); JsonObject errorObj = JsonParser.parseReader(playlistBR).getAsJsonObject(); String message = errorObj.get("error").getAsJsonObject().get("message").getAsString(); - LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message); + log.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message); return null; } InputStream playlistInputStream = playlistCon.getInputStream(); @@ -154,7 +123,7 @@ public class YoutubeManager { JsonArray playlists = playlistData.get("items").getAsJsonArray(); if (playlists.size() == 0) { - LOGGER.error("Playlist {} not found!", playlistId); + log.error("Playlist {} not found!", playlistId); return null; } JsonObject playlistItem = playlists.get(0).getAsJsonObject().get("snippet").getAsJsonObject(); @@ -217,7 +186,7 @@ public class YoutubeManager { } while (nextPageToken != null); if (videos.isEmpty()) { - LOGGER.warn("Playlist {} has no videos!", playlistId); + log.warn("Playlist {} has no videos!", playlistId); return null; } playlist = new YoutubePlaylist(playlistId, name, description, videos); 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 ab6bf36e..072eb40b 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 @@ -28,10 +28,10 @@ public class InteractionBackgroundToner extends HabboItem { serverMessage.appendInt(4); if (this.getExtradata().split(":").length == 4) { String[] colorData = this.getExtradata().split(":"); - serverMessage.appendInt(Integer.valueOf(colorData[0])); - serverMessage.appendInt(Integer.valueOf(colorData[1])); - serverMessage.appendInt(Integer.valueOf(colorData[2])); - serverMessage.appendInt(Integer.valueOf(colorData[3])); + serverMessage.appendInt(Integer.parseInt(colorData[0])); + serverMessage.appendInt(Integer.parseInt(colorData[1])); + serverMessage.appendInt(Integer.parseInt(colorData[2])); + serverMessage.appendInt(Integer.parseInt(colorData[3])); } else { serverMessage.appendInt(0); serverMessage.appendInt(126); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index a67103b8..020c43df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -113,15 +113,15 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet oldTiles = this.tiles; THashSet newTiles = new THashSet<>(); - int minX = Math.max(0, newLocation.x - Integer.parseInt(this.values.get("tilesBack"))); - int minY = Math.max(0, newLocation.y - Integer.parseInt(this.values.get("tilesRight"))); - int maxX = Math.min(room.getLayout().getMapSizeX(), newLocation.x + Integer.parseInt(this.values.get("tilesFront"))); - int maxY = Math.min(room.getLayout().getMapSizeY(), newLocation.y + Integer.parseInt(this.values.get("tilesLeft"))); + int minX = Math.max(0, newLocation.getX() - Integer.parseInt(this.values.get("tilesBack"))); + int minY = Math.max(0, newLocation.getY() - Integer.parseInt(this.values.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), newLocation.getX() + Integer.parseInt(this.values.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), newLocation.getY() + Integer.parseInt(this.values.get("tilesLeft"))); for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { RoomTile tile = room.getLayout().getTile((short) x, (short) y); - if (tile != null && tile.state != RoomTileState.INVALID) + if (tile != null && tile.getState() != RoomTileState.INVALID) newTiles.add(tile); } } @@ -162,7 +162,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { RoomTile tile = room.getLayout().getTile((short) x, (short) y); - if (tile != null && tile.state != RoomTileState.INVALID) + if (tile != null && tile.getState() != RoomTileState.INVALID) this.tiles.add(tile); } } @@ -197,7 +197,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { RoomTile tile = room.getLayout().getTile((short) x, (short) y); - if (tile != null && tile.state != RoomTileState.INVALID && !this.tiles.contains(tile)) + if (tile != null && tile.getState() != RoomTileState.INVALID && !this.tiles.contains(tile)) oldTiles.add(tile); } } @@ -224,8 +224,8 @@ public class InteractionBuildArea extends InteractionCustomValues { for (RoomTile tile : this.tiles) { id--; HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); - item.setX(tile.x); - item.setY(tile.y); + item.setX(tile.getX()); + item.setY(tile.getY()); item.setZ(tile.relativeHeight()); items.add(item); } 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 133e83c9..9d181a92 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 @@ -3,14 +3,13 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class InteractionColorPlate extends InteractionDefault { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionColorPlate.class); public InteractionColorPlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -42,9 +41,9 @@ public class InteractionColorPlate extends InteractionDefault { } try { - state = Integer.valueOf(this.getExtradata()); + state = Integer.parseInt(this.getExtradata()); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } state += amount; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index c40d27c4..1be2594c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -38,8 +38,8 @@ public class InteractionCrackable extends HabboItem { serverMessage.appendInt(7 + (this.isLimited() ? 256 : 0)); - serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.valueOf(this.getExtradata()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + ""); - serverMessage.appendInt(Integer.valueOf(this.getExtradata())); + serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtradata()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + ""); + serverMessage.appendInt(Integer.parseInt(this.getExtradata())); serverMessage.appendInt(Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())); super.serializeExtradata(serverMessage); @@ -96,7 +96,7 @@ public class InteractionCrackable extends HabboItem { CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId()); if (rewardData != null) { - if (rewardData.requiredEffect > 0 && habbo.getRoomUnit().getEffectId() != rewardData.requiredEffect) + if (rewardData.getRequiredEffect() > 0 && habbo.getRoomUnit().getEffectId() != rewardData.getRequiredEffect()) return; if(this.ticks < 1) @@ -109,26 +109,24 @@ public class InteractionCrackable extends HabboItem { this.needsUpdate(true); room.updateItem(this); - if (!rewardData.achievementTick.isEmpty()) { - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementTick)); + if (!rewardData.getAchievementTick().isEmpty()) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.getAchievementTick())); } if (!this.cracked && this.ticks == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())) { this.cracked = true; Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getX(), this.getY()), 1500); - if (!rewardData.achievementCracked.isEmpty()) { - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked)); + if (!rewardData.getAchievementCracked().isEmpty()) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.getAchievementCracked())); } - if (rewardData.subscriptionType != null && rewardData.subscriptionDuration > 0) { + if (rewardData.getSubscriptionType() != null && rewardData.getSubscriptionDuration() > 0) { // subscriptions are given immediately upon cracking - switch (rewardData.subscriptionType) { - case HABBO_CLUB: - habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, rewardData.subscriptionDuration * 86400); - break; - case BUILDERS_CLUB: - habbo.getHabboStats().createSubscription("BUILDERS_CLUB", rewardData.subscriptionDuration * 86400); - break; + switch (rewardData.getSubscriptionType()) { + case HABBO_CLUB -> + habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, rewardData.getSubscriptionDuration() * 86400); + case BUILDERS_CLUB -> + habbo.getHabboStats().createSubscription("BUILDERS_CLUB", rewardData.getSubscriptionDuration() * 86400); } } } 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 6161d131..255054ba 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 @@ -9,14 +9,13 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class InteractionDefault extends HabboItem { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionDefault.class); public InteractionDefault(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -77,9 +76,9 @@ public class InteractionDefault extends HabboItem { int currentState = 0; try { - currentState = Integer.valueOf(this.getExtradata()); + currentState = Integer.parseInt(this.getExtradata()); } catch (NumberFormatException e) { - LOGGER.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); + log.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); } this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount()); @@ -150,9 +149,8 @@ public class InteractionDefault extends HabboItem { int nextEffectDuration = -1; if (objects != null && objects.length == 2) { - if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) { - RoomTile goalTile = (RoomTile) objects[0]; - HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y, (objects[0] != objects[1]) ? this : null); + if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) { + HabboItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null); if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { return; @@ -206,7 +204,7 @@ public class InteractionDefault extends HabboItem { if (!habbo.getHabboStats().isRentingSpace()) return false; - HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().rentedItemId); + HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().getRentedItemId()); return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java index 0e6ad5d7..eb0e8b19 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java @@ -50,7 +50,7 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi if (!customparams.isEmpty()) { return Arrays.asList(customparams.split(";")) - .contains(Integer.valueOf(roomUnit.getEffectId()).toString()); + .contains(String.valueOf(roomUnit.getEffectId())); } return defaultAllowedEnables.contains(roomUnit.getEffectId()); 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 99df17f1..4d8d011a 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 @@ -27,7 +27,7 @@ public class InteractionEffectGiver extends InteractionDefault { super.onClick(client, room, objects); if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY())) { + (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java index feb63992..3084f3e4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java @@ -25,7 +25,7 @@ public class InteractionEffectToggle extends InteractionDefault { if (client != null) { if (room.hasRights(client.getHabbo())) { - if (Integer.valueOf(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) { + if (Integer.parseInt(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) { if ((client.getHabbo().getHabboInfo().getGender() == HabboGender.M && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) || (client.getHabbo().getHabboInfo().getGender() == HabboGender.F && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectF())) { super.onClick(client, room, objects); 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 ba49ed7a..49261af4 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 @@ -1,7 +1,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java index 799c2116..84f91edc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java @@ -28,7 +28,7 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa @Override public THashSet getActivatorTiles(Room room) { - THashSet tiles = new THashSet(); + 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)); 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 ca92ccf4..1da31022 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 @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.items.Item; 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.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -50,7 +49,7 @@ public class InteractionFXBox extends InteractionDefault { if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) return; - EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0); + client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0); client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); this.setExtradata("1"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index b2255e2f..22f4071d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -11,17 +11,16 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +@Slf4j public class InteractionFireworks extends InteractionDefault { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class); private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels private static final String STATE_CHARGED = "1"; @@ -129,7 +128,7 @@ public class InteractionFireworks extends InteractionDefault { try { explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams()); } catch (NumberFormatException e) { - LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); + log.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); } } 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 f7ceb0e3..9646940b 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 @@ -46,7 +46,7 @@ public class InteractionGate extends HabboItem { // 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)) + if (room.hasHabbosAt(tile.getX(), tile.getY())) return; // Gate closed = 0, open = 1 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 41fb4dc1..62f2a19e 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,18 +8,19 @@ 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 lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class InteractionGift extends HabboItem { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGift.class); - public boolean explode = false; private int[] itemId; + @Getter private int colorId = 0; + @Getter private int ribbonId = 0; private boolean showSender = false; private String message = ""; @@ -32,7 +33,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); + log.warn("Incorrect extradata for gift with ID " + this.getId()); } } @@ -42,7 +43,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); + log.warn("Incorrect extradata for gift with ID " + this.getId()); } } @@ -94,16 +95,16 @@ public class InteractionGift extends HabboItem { data = this.getExtradata().split("\t"); if (data != null && data.length >= 5) { - int count = Integer.valueOf(data[0]); + int count = Integer.parseInt(data[0]); this.itemId = new int[count]; for (int i = 0; i < count; i++) { - this.itemId[i] = Integer.valueOf(data[i + 1]); + this.itemId[i] = Integer.parseInt(data[i + 1]); } - this.colorId = Integer.valueOf(data[count + 1]); - this.ribbonId = Integer.valueOf(data[count + 2]); + this.colorId = Integer.parseInt(data[count + 1]); + this.ribbonId = Integer.parseInt(data[count + 2]); this.showSender = data[count + 3].equalsIgnoreCase("1"); this.message = data[count + 4]; @@ -120,14 +121,6 @@ public class InteractionGift extends HabboItem { } } - public int getColorId() { - return this.colorId; - } - - public int getRibbonId() { - return this.ribbonId; - } - public THashSet loadItems() { THashSet items = new THashSet<>(); for (int anItemId : this.itemId) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java index b4374f86..067405a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java @@ -13,7 +13,7 @@ import java.sql.SQLException; public class InteractionGuildFurni extends InteractionDefault { private int guildId; - private static final THashSet ROTATION_8_ITEMS = new THashSet() { + private static final THashSet ROTATION_8_ITEMS = new THashSet<>() { { this.add("gld_wall_tall"); } @@ -47,8 +47,8 @@ public class InteractionGuildFurni extends InteractionDefault { serverMessage.appendString(this.getExtradata()); serverMessage.appendString(guild.getId() + ""); serverMessage.appendString(guild.getBadge()); - serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).valueA); - serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).valueA); + serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).getValueA()); + serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).getValueA()); } else { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java index 0de6806b..a5e106c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java @@ -64,7 +64,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC if (roomUnit != null) { Habbo habbo = room.getHabbo(roomUnit); - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y); + HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; 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 7782736b..7c7599f0 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 @@ -25,7 +25,7 @@ public class InteractionHanditem extends InteractionDefault { super.onClick(client, room, objects); if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY())) { + (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } 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 786e369f..286aa9f9 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 @@ -21,7 +21,7 @@ public class InteractionHanditemTile extends InteractionHanditem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { InteractionHanditemTile instance = this; Emulator.getThreading().run(() -> { - if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY()) { + if (roomUnit.getCurrentLocation().getX() == instance.getX() && roomUnit.getCurrentLocation().getY() == instance.getY()) { instance.handle(room, roomUnit); } }, 3000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java index fa0d2571..aea5acbf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java @@ -86,10 +86,10 @@ public class InteractionHopper extends HabboItem { } protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) { - if (client.getHabbo().getRoomUnit().getX() != front.x) + if (client.getHabbo().getRoomUnit().getX() != front.getX()) return false; - if (client.getHabbo().getRoomUnit().getY() != front.y) + if (client.getHabbo().getRoomUnit().getY() != front.getY()) return false; if (client.getHabbo().getRoomUnit().isTeleporting) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java index 41bcdf9b..86b73483 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java @@ -11,7 +11,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionInformationTerminal extends InteractionCustomValues { - public static final THashMap defaultValues = new THashMap() { + public static final THashMap defaultValues = new THashMap<>() { { this.put("internalLink", "habbopages/chat/commands"); } 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 fcb41753..e6a813c5 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 @@ -77,11 +77,11 @@ public class InteractionMannequin extends HabboItem { if (gender.isEmpty() || figure.isEmpty() || (!gender.equalsIgnoreCase("m") && !gender.equalsIgnoreCase("f")) || !client.getHabbo().getHabboInfo().getGender().name().equalsIgnoreCase(gender)) return; - String newFigure = ""; + StringBuilder newFigure = new StringBuilder(); for (String playerFigurePart : client.getHabbo().getHabboInfo().getLook().split("\\.")) { if (!playerFigurePart.startsWith("ch") && !playerFigurePart.startsWith("lg")) - newFigure += playerFigurePart + "."; + newFigure.append(playerFigurePart).append("."); } String newFigureParts = figure; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java index 51e47e6c..44f024db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java @@ -46,9 +46,9 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements @Override public void reset(Room room) { RoomTile tile = room.getRandomWalkableTile(); - this.setX(tile.x); - this.setY(tile.y); - this.setZ(room.getStackHeight(tile.x, tile.y, false)); + this.setX(tile.getX()); + this.setY(tile.getY()); + this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); super.reset(room); } 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 e2c9e571..04cadffc 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 @@ -67,7 +67,7 @@ public class InteractionMultiHeight extends HabboItem { this.needsUpdate(true); room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); room.updateItemState(this); - //room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.valueOf(this.getExtradata())] * 256.0D).compose()); + //room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.parseInt(this.getExtradata())] * 256.0D).compose()); } } } @@ -77,9 +77,8 @@ public class InteractionMultiHeight extends HabboItem { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for(RoomTile tile : occupiedTiles) { - Collection unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.x, tile.y)); + Collection unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY())); - THashSet updatedUnits = new THashSet<>(); for (RoomUnit unit : unitsOnItem) { if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoal() != tile) continue; 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 f001fc20..ef9914a0 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 @@ -5,14 +5,13 @@ 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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class InteractionMusicDisc extends HabboItem { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionMusicDisc.class); private int songId; @@ -23,9 +22,9 @@ public class InteractionMusicDisc extends HabboItem { if (stuff.length >= 7 && !stuff[6].isEmpty()) { try { - this.songId = Integer.valueOf(stuff[6]); + this.songId = Integer.parseInt(stuff[6]); } catch (Exception e) { - LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); + log.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); } } } @@ -37,9 +36,9 @@ public class InteractionMusicDisc extends HabboItem { if (stuff.length >= 7 && !stuff[6].isEmpty()) { try { - this.songId = Integer.valueOf(stuff[6]); + this.songId = Integer.parseInt(stuff[6]); } catch (Exception e) { - LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); + log.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/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index b2597681..b8b1ac03 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -9,8 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.ObjectDataUpdateMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; @@ -21,7 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionMuteArea extends InteractionCustomValues { - public static THashMap defaultValues = new THashMap() { + public static THashMap defaultValues = new THashMap<>() { { this.put("tilesLeft", "0"); } @@ -43,7 +43,7 @@ public class InteractionMuteArea extends InteractionCustomValues { } }; - private THashSet tiles; + private final THashSet tiles; public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, defaultValues); @@ -98,9 +98,9 @@ public class InteractionMuteArea extends InteractionCustomValues { /*try { return new Rectangle( this.getX() - Integer.parseInt(this.values.get("tilesBack")), - this.getY() + Integer.valueOf(this.values.get("tilesLeft")) - (Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight"))), - Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight")) + 1, - Integer.valueOf(this.values.get("tilesFront")) + Integer.valueOf(this.values.get("tilesBack")) + 1).contains(location.x, location.y); + this.getY() + Integer.parseInt(this.values.get("tilesLeft")) - (Integer.parseInt(this.values.get("tilesLeft")) + Integer.parseInt(this.values.get("tilesRight"))), + Integer.parseInt(this.values.get("tilesLeft")) + Integer.parseInt(this.values.get("tilesRight")) + 1, + Integer.parseInt(this.values.get("tilesFront")) + Integer.parseInt(this.values.get("tilesBack")) + 1).contains(location.x, location.y); } catch (Exception e) { return false; }*/ @@ -117,7 +117,7 @@ public class InteractionMuteArea extends InteractionCustomValues { for(int x = minX; x <= maxX; x++) { for(int y = minY; y <= maxY; y++) { RoomTile tile = room.getLayout().getTile((short)x, (short)y); - if(tile != null && tile.state != RoomTileState.INVALID) + if(tile != null && tile.getState() != RoomTileState.INVALID) this.tiles.add(tile); } } @@ -141,8 +141,8 @@ public class InteractionMuteArea extends InteractionCustomValues { for(RoomTile tile : this.tiles) { id--; HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); - item.setX(tile.x); - item.setY(tile.y); + item.setX(tile.getX()); + item.setY(tile.getY()); item.setZ(tile.relativeHeight()); items.add(item); } 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 f2463700..f31560db 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 @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -21,7 +20,7 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine @Override public THashSet getActivatorTiles(Room room) { - THashSet tiles = new THashSet(); + 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)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java index a63dcad8..e6b008d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java @@ -17,7 +17,7 @@ import java.util.Objects; public class InteractionObstacle extends HabboItem implements ICycleable { - private THashSet middleTiles; + private final THashSet middleTiles; public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -180,12 +180,12 @@ public class InteractionObstacle extends HabboItem implements ICycleable { continue; RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentLocation(), unit.getBodyRotation().getValue()); - if(tileInfront.state != RoomTileState.INVALID && tileInfront.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) { + if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) { unit.setGoalLocation(tileInfront); } else { RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentLocation(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); - if(tileBehind.state != RoomTileState.INVALID && tileBehind.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) { + if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) { unit.setGoalLocation(tileBehind); } } 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 55e6ca99..22c822aa 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 @@ -12,8 +12,6 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.DiceValueMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -21,8 +19,6 @@ 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 { @@ -80,10 +76,10 @@ public class InteractionOneWayGate extends HabboItem { if (unit == null) return; - if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) { + if (tileInfront.getX() == unit.getX() && tileInfront.getY() == unit.getY()) { if (!currentLocation.hasUnits()) { - List onSuccess = new ArrayList(); - List onFail = new ArrayList(); + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); onSuccess.add(() -> { unit.setCanLeaveRoomByDoor(false); 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 a1cef49e..9176cecf 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 @@ -82,7 +82,7 @@ public class InteractionPressurePlate extends InteractionDefault { if (tiles == null) return; for (RoomTile tile : tiles) { - boolean hasHabbos = room.hasHabbosAt(tile.x, tile.y); + boolean hasHabbos = room.hasHabbosAt(tile.getX(), tile.getY()); if (!hasHabbos && this.requiresAllTilesOccupied()) { occupied = false; break; 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 a8d0db0e..1a894f80 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 @@ -83,7 +83,7 @@ public abstract class InteractionPushable extends InteractionDefault { 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 + if (this.getX() == roomUnit.getGoal().getX() && this.getY() == roomUnit.getGoal().getY()) //User clicked on the tile the ball is on, they want to kick it { velocity = this.getWalkOnVelocity(roomUnit, room); direction = this.getWalkOnDirection(roomUnit, room); 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 a23586ba..3de816b5 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 @@ -49,18 +49,18 @@ public class InteractionPuzzleBox extends HabboItem { RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); - if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.x, tile.y)) { + if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.getX(), tile.getY())) { return; } if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue()))) return; - HabboItem item = room.getTopItemAt(tile.x, tile.y); + HabboItem item = room.getTopItemAt(tile.getX(), tile.getY()); - if (item != null && !room.getTopItemAt(tile.x, tile.y).getBaseItem().allowStack()) return; + if (item != null && !room.getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return; - this.setZ(room.getStackHeight(tile.x, tile.y, false)); + this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); this.needsUpdate(true); room.updateItem(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java index 1ddc2be9..2055b38b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java @@ -25,7 +25,7 @@ public class InteractionPyramid extends InteractionGate { if (room != null) { if (room.getHabbosAt(this.getX(), this.getY()).isEmpty()) { - int state = Integer.valueOf(this.getExtradata()); + int state = Integer.parseInt(this.getExtradata()); state = Math.abs(state - 1); this.setExtradata(state + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java index c28ee163..2178ccef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java @@ -1,7 +1,6 @@ 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.items.RandomStateParams; import com.eu.habbo.habbohotel.rooms.Room; @@ -26,7 +25,7 @@ public class InteractionRandomState extends InteractionDefault { room.updateItemState(this); } - public void onRandomStateClick(GameClient client, Room room) throws Exception { + public void onRandomStateClick(Room room) throws Exception { RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams()); this.setExtradata(""); 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 87e9e1af..feb28cab 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,8 +12,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceStatusMessageComposer; import com.eu.habbo.threading.runnables.ClearRentedSpace; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.awt.*; import java.sql.Connection; @@ -21,8 +20,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class InteractionRentableSpace extends HabboItem { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionRentableSpace.class); private int renterId; private String renterName; @@ -36,8 +35,8 @@ public class InteractionRentableSpace extends HabboItem { this.renterName = "Unknown"; if (data.length == 2) { - this.renterId = Integer.valueOf(data[0]); - this.endTimestamp = Integer.valueOf(data[1]); + this.renterId = Integer.parseInt(data[0]); + this.endTimestamp = Integer.parseInt(data[1]); if (this.renterId > 0) { if (this.isRented()) { @@ -54,7 +53,7 @@ public class InteractionRentableSpace extends HabboItem { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } else { @@ -184,7 +183,7 @@ public class InteractionRentableSpace extends HabboItem { statement.setInt(1, zero); statement.setInt(2, zero); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -233,8 +232,8 @@ public class InteractionRentableSpace extends HabboItem { String[] data = this.getBaseItem().getName().replace("hblooza_spacerent", "").split("x"); if (data.length == 2) { - int x = Integer.valueOf(data[0]); - int y = Integer.valueOf(data[1]); + int x = Integer.parseInt(data[0]); + int y = Integer.parseInt(data[1]); return 10 * (x * y); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java index d37dea17..688d6fdc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java @@ -9,7 +9,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionRoomAds extends InteractionCustomValues { - public final static THashMap defaultValues = new THashMap() { + public final static THashMap defaultValues = new THashMap<>() { { this.put("imageUrl", ""); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java index 3a6bf457..09b3292b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java @@ -76,10 +76,10 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - Rectangle newRect = RoomLayout.getRectangle(newLocation.x, newLocation.y, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); + Rectangle newRect = RoomLayout.getRectangle(newLocation.getX(), newLocation.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for (Habbo habbo : room.getHabbosOnItem(this)) { - if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().x, habbo.getRoomUnit().getCurrentLocation().y)) { + if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().getX(), habbo.getRoomUnit().getCurrentLocation().getY())) { room.giveEffect(habbo, 0, -1); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 42813714..64af3bfa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -96,8 +96,8 @@ public class InteractionTeleport extends HabboItem { room.updateItemState(this); unit.setGoalLocation(infrontTile); - List onSuccess = new ArrayList(); - List onFail = new ArrayList(); + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); onSuccess.add(() -> { room.updateTile(currentLocation); @@ -125,8 +125,8 @@ public class InteractionTeleport extends HabboItem { Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); } else { // walk to teleport and interact - List onSuccess = new ArrayList(); - List onFail = new ArrayList(); + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); onSuccess.add(() -> { tryTeleport(client, room); 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 c58f6193..bda95b66 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 @@ -10,7 +10,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionTileEffectProvider extends InteractionCustomValues { - public static THashMap defaultValues = new THashMap() { + public static THashMap defaultValues = new THashMap<>() { { this.put("effectId", "0"); } @@ -38,7 +38,7 @@ public class InteractionTileEffectProvider extends InteractionCustomValues { public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - int effectId = Integer.valueOf(this.values.get("effectId")); + int effectId = Integer.parseInt(this.values.get("effectId")); if (roomUnit.getEffectId() == effectId) { effectId = 0; 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 68dd0eec..cf1a3782 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 @@ -22,44 +22,45 @@ public class InteractionTrap extends InteractionDefault { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - if (this.getExtradata().equals("0") || roomUnit == null || room.getHabbo(roomUnit) == null) return; + if (this.getExtradata().equals("0") || roomUnit == null || room.getHabbo(roomUnit) == null) return; - Habbo habbo = room.getHabbo(roomUnit); - int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); - roomUnit.stopWalking(); - super.onWalkOn(roomUnit, room, objects); - int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName()); - if (delay == 0) { - Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000"); - delay = 3000; - } + Habbo habbo = room.getHabbo(roomUnit); + int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); + roomUnit.stopWalking(); + super.onWalkOn(roomUnit, room, objects); + int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName()); + if (delay == 0) { + Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000"); + delay = 3000; + } - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); - return; - } - - - roomUnit.setCanWalk(false); - Emulator.getThreading().run(() -> { - room.giveEffect(roomUnit, 0, -1); - roomUnit.setCanWalk(true); - room.giveEffect(roomUnit, effect, -1); - }, delay); - - } + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { + room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + return; } + + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { + room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + return; + } + + + roomUnit.setCanWalk(false); + Emulator.getThreading().run(() -> { + room.giveEffect(roomUnit, 0, -1); + roomUnit.setCanWalk(true); + room.giveEffect(roomUnit, effect, -1); + }, delay); + } + } + } @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } + } 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 817e6039..f6e272b1 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 @@ -55,7 +55,7 @@ public class InteractionVendingMachine extends HabboItem { boolean inActivatorSpace = false; - for(RoomTile tile : activatorTiles) { + for(RoomTile ignored : activatorTiles) { if(unit.getCurrentLocation().is(unit.getX(), unit.getY())) { inActivatorSpace = true; } @@ -77,7 +77,7 @@ public class InteractionVendingMachine extends HabboItem { } if(!unit.isWalking() && !unit.hasStatus(RoomUnitStatus.SIT) && !unit.hasStatus(RoomUnitStatus.LAY)) { - this.rotateToMachine(room, unit); + this.rotateToMachine(unit); } Emulator.getThreading().run(() -> { @@ -113,7 +113,7 @@ public class InteractionVendingMachine extends HabboItem { boolean inActivatorSpace = false; for(RoomTile tile : activatorTiles) { - if(unit.getCurrentLocation().is(tile.x, tile.y)) { + if(unit.getCurrentLocation().is(tile.getX(), tile.getY())) { inActivatorSpace = true; } } @@ -121,18 +121,16 @@ public class InteractionVendingMachine extends HabboItem { if(!inActivatorSpace) { RoomTile tileToWalkTo = null; for(RoomTile tile : activatorTiles) { - if((tile.state == RoomTileState.OPEN || tile.state == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) { + if((tile.getState() == RoomTileState.OPEN || tile.getState() == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) { tileToWalkTo = tile; } } if(tileToWalkTo != null) { - List onSuccess = new ArrayList(); - List onFail = new ArrayList(); + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); - onSuccess.add(() -> { - tryInteract(client, room, unit); - }); + onSuccess.add(() -> tryInteract(client, room, unit)); unit.setGoalLocation(tileToWalkTo); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail)); @@ -175,7 +173,7 @@ public class InteractionVendingMachine extends HabboItem { return true; } - private void rotateToMachine(Room room, RoomUnit unit) { + private void rotateToMachine(RoomUnit unit) { RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())]; if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java index c8fa52b4..1df011f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java @@ -26,7 +26,7 @@ public class InteractionVikingCotie extends InteractionDefault { if (client != null && client.getHabbo().getHabboInfo().getId() == this.getUserId()) { if (client.getHabbo().getRoomUnit().getEffectId() == 172 || client.getHabbo().getRoomUnit().getEffectId() == 173) { - int state = Integer.valueOf(this.getExtradata()); + int state = Integer.parseInt(this.getExtradata()); if (state < 5) { state++; 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 d2b0f6d2..368eb5c8 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 @@ -83,7 +83,7 @@ public class InteractionWater extends InteractionDefault { if (pet == null) return; - if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) { + if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().isCanSwim()) { pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, ""); } } @@ -130,7 +130,7 @@ public class InteractionWater extends InteractionDefault { Pet pet = room.getPet(roomUnit); - return pet == null || pet.getPetData().canSwim; + return pet == null || pet.getPetData().isCanSwim(); } private void updateWaters(Room room, RoomTile oldLocation) { @@ -143,8 +143,8 @@ public class InteractionWater extends InteractionDefault { if (oldLocation != null) { targetOld = RoomLayout.getRectangle( - oldLocation.x - 1, - oldLocation.y - 1, + oldLocation.getX() - 1, + oldLocation.getY() - 1, this.getBaseItem().getWidth() + 2, this.getBaseItem().getLength() + 2, this.getRotation()); @@ -281,8 +281,7 @@ public class InteractionWater extends InteractionDefault { 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; + if (item instanceof InteractionWater water) { // Take out picked up water from the recalculation. if (!water.isInRoom) { 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 4b283da1..404e1f32 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 @@ -4,9 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; 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 7a11d10a..84838123 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 @@ -9,18 +9,17 @@ import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import gnu.trove.map.hash.TLongLongHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public abstract class InteractionWired extends InteractionDefault { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class); private long cooldown; - private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); + private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -58,7 +57,7 @@ public abstract class InteractionWired extends InteractionDefault { statement.setInt(2, this.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } super.run(); @@ -72,7 +71,7 @@ public abstract class InteractionWired extends InteractionDefault { public abstract void onPickUp(); public void activateBox(Room room) { - this.activateBox(room, (RoomUnit)null, 0L); + this.activateBox(room, null, 0L); } public void activateBox(Room room, RoomUnit roomUnit, long millis) { @@ -107,18 +106,14 @@ public abstract class InteractionWired extends InteractionDefault { } public boolean userCanExecute(int roomUnitId, long timestamp) { - if (roomUnitId == -1) { - return true; - } else { - if (this.userExecutionCache.containsKey((long)roomUnitId)) { - long lastTimestamp = this.userExecutionCache.get((long)roomUnitId); - if (timestamp - lastTimestamp < 100L) { - return false; - } + if (roomUnitId != -1) { + if (this.userExecutionCache.containsKey(roomUnitId)) { + long lastTimestamp = this.userExecutionCache.get(roomUnitId); + return timestamp - lastTimestamp >= 100L; } - return true; } + return true; } public void clearUserExecutionCache() { @@ -126,7 +121,7 @@ public abstract class InteractionWired extends InteractionDefault { } public void addUserExecutionCache(int roomUnitId, long timestamp) { - this.userExecutionCache.put((long)roomUnitId, timestamp); + this.userExecutionCache.put(roomUnitId, timestamp); } public static WiredSettings readSettings(ClientMessage packet, boolean isEffect) @@ -159,4 +154,5 @@ public abstract class InteractionWired extends InteractionDefault { settings.setStuffTypeSelectionCode(packet.readInt()); return settings; } + } 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 b8a638b2..3162ddb3 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 @@ -13,15 +13,15 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; +@Slf4j public class InteractionWiredHighscore extends HabboItem { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWiredHighscore.class); + public WiredHighscoreScoreType scoreType; public WiredHighscoreClearType clearType; @@ -40,7 +40,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.reloadData(); @@ -58,7 +58,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.reloadData(); @@ -93,7 +93,7 @@ public class InteractionWiredHighscore extends HabboItem { this.setExtradata(Math.abs(state - 1) + ""); room.updateItem(this); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } if(client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) { @@ -106,8 +106,8 @@ public class InteractionWiredHighscore extends HabboItem { public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(6); serverMessage.appendString(this.getExtradata()); - serverMessage.appendInt(this.scoreType.type); - serverMessage.appendInt(this.clearType.type); + serverMessage.appendInt(this.scoreType.getType()); + serverMessage.appendInt(this.clearType.getType()); if (this.data != null) { int size = this.data.size(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index 91fb8c08..528c6b80 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; import java.sql.ResultSet; 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 bb868c6d..ee0085f8 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 @@ -15,29 +15,36 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.games.GameTimer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; +@Slf4j public class InteractionGameTimer extends HabboItem implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGameTimer.class); private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; private int baseTime = 0; + @Getter + @Setter private int timeNow = 0; + @Getter + @Setter private boolean isRunning = false; + @Getter private boolean isPaused = false; + @Setter private boolean threadActive = false; public enum InteractionGameTimerAction { START_STOP(1), INCREASE_TIME(2); - private int action; + private final int action; InteractionGameTimerAction(int action) { this.action = action; @@ -95,7 +102,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { } }).toArray(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -127,7 +134,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { room.addGame(game); game.initialise(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -323,31 +330,8 @@ public class InteractionGameTimer extends HabboItem implements Runnable { return true; } - public boolean isRunning() { - return this.isRunning; - } - - public void setRunning(boolean running) { - this.isRunning = running; - } - - public void setThreadActive(boolean threadActive) { - this.threadActive = threadActive; - } - - public boolean isPaused() { - return this.isPaused; - } - public void reduceTime() { this.timeNow--; } - public int getTimeNow() { - return this.timeNow; - } - - public void setTimeNow(int timeNow) { - this.timeNow = timeNow; - } } 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 da8ccf7d..0882cb0b 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,8 +124,8 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { 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()))); + HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (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()))); } @@ -154,7 +154,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { if (game != null) { GameTeam team = game.getTeamForHabbo(habbo); if (team != null) { - HabboItem item = room.getTopItemAt(to.x, to.y); + HabboItem item = room.getTopItemAt(to.getX(), to.getY()); try { item.onWalkOn(kicker, room, null); } catch (Exception e) { @@ -180,6 +180,6 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { - return to.state == RoomTileState.OPEN && to.isWalkable(); + return to.getState() == RoomTileState.OPEN && to.isWalkable(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java index 8e364615..7eda506b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java @@ -57,7 +57,7 @@ public class InteractionBattleBanzaiTile extends HabboItem { if (this.getExtradata().isEmpty()) this.setExtradata("0"); - int state = Integer.valueOf(this.getExtradata()); + int state = Integer.parseInt(this.getExtradata()); if (state % 3 == 2) return; @@ -88,7 +88,7 @@ public class InteractionBattleBanzaiTile extends HabboItem { if (this.getExtradata().isEmpty()) return false; - return Integer.valueOf(this.getExtradata()) % 3 == 2; + return Integer.parseInt(this.getExtradata()) % 3 == 2; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java index 04def885..b846acf4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java @@ -25,7 +25,7 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return room.getGame(BattleBanzaiGame.class) == null || ((BattleBanzaiGame) room.getGame(BattleBanzaiGame.class)).state.equals(GameState.IDLE); + return room.getGame(BattleBanzaiGame.class) == null || room.getGame(BattleBanzaiGame.class).state.equals(GameState.IDLE); } @Override 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 225ed808..cd80544e 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 @@ -69,8 +69,8 @@ public class InteractionFootball extends InteractionPushable { @Override public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { RoomTile peek = roomUnit.getPath().peek(); - RoomTile nextWalkTile = peek != null ? room.getLayout().getTile(peek.x, peek.y) : roomUnit.getGoal(); - return RoomUserRotation.values()[(RoomUserRotation.values().length + Rotation.Calculate(roomUnit.getX(), roomUnit.getY(), nextWalkTile.x, nextWalkTile.y) + 4) % 8]; + RoomTile nextWalkTile = peek != null ? room.getLayout().getTile(peek.getX(), peek.getY()) : roomUnit.getGoal(); + return RoomUserRotation.values()[(RoomUserRotation.values().length + Rotation.Calculate(roomUnit.getX(), roomUnit.getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8]; } public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) { @@ -150,8 +150,8 @@ public class InteractionFootball extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { - if (to == null || to.state == RoomTileState.INVALID) return false; - HabboItem topItem = room.getTopItemAt(to.x, to.y, this); + if (to == null || to.getState() == RoomTileState.INVALID) return false; + HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); // Move is valid if there isnt any furni yet if (topItem == null) { @@ -174,7 +174,7 @@ public class InteractionFootball extends InteractionPushable { // If top item is a football goal, the move is only valid if ball is coming from the front side // Ball shouldn't come from the back or from the sides (tested on 22-03-2022) if (topItem instanceof InteractionFootballGoal) { - int ballDirection = Rotation.Calculate(from.x, from.y, to.x, to.y); + int ballDirection = Rotation.Calculate(from.getX(), from.getY(), to.getX(), to.getY()); int goalRotation = topItem.getRotation(); switch (goalRotation) { @@ -220,8 +220,8 @@ public class InteractionFootball extends InteractionPushable { return; } } - HabboItem currentTopItem = room.getTopItemAt(from.x, from.y, this); - HabboItem topItem = room.getTopItemAt(to.x, to.y, this); + HabboItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this); + HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && ((topItem instanceof InteractionFootballGoal))) { GameTeamColors color = ((InteractionGameTeamItem) topItem).teamColor; game.onScore(kicker, color); @@ -247,8 +247,8 @@ 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 !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.x, to.y)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); + HabboItem topItem = room.getTopItemAt(from.getX(), from.getY(), this); + return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.getX(), to.getY())) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java index 0c9dd2f5..b033118b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java @@ -63,9 +63,9 @@ public class InteractionFootballGate extends HabboItem { } private static void removeLook(Habbo habbo) { - if (habbo.getHabboStats().cache.containsKey(CACHE_KEY)) { - habbo.getHabboInfo().setLook((String) habbo.getHabboStats().cache.get(CACHE_KEY)); - habbo.getHabboStats().cache.remove(CACHE_KEY); + if (habbo.getHabboStats().getCache().containsKey(CACHE_KEY)) { + habbo.getHabboInfo().setLook((String) habbo.getHabboStats().getCache().get(CACHE_KEY)); + habbo.getHabboStats().getCache().remove(CACHE_KEY); habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); @@ -115,8 +115,8 @@ public class InteractionFootballGate extends HabboItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - if (habbo.getHabboStats().cache.containsKey(CACHE_KEY)) { - String oldlook = (String) habbo.getHabboStats().cache.get(CACHE_KEY); + if (habbo.getHabboStats().getCache().containsKey(CACHE_KEY)) { + String oldlook = (String) habbo.getHabboStats().getCache().get(CACHE_KEY); UserSavedLookEvent lookEvent = new UserSavedLookEvent(habbo, habbo.getHabboInfo().getGender(), oldlook); Emulator.getPluginManager().fireEvent(lookEvent); @@ -127,14 +127,14 @@ public class InteractionFootballGate extends HabboItem { room.sendComposer(new UserChangeMessageComposer(habbo).compose()); } - habbo.getHabboStats().cache.remove(CACHE_KEY); + habbo.getHabboStats().getCache().remove(CACHE_KEY); } else { String finalLook = FigureUtil.mergeFigures(habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getGender() == HabboGender.F ? this.figureF : this.figureM, new String[]{"hd", "hr", "ha", "he", "ea", "fa"}, new String[]{"ch", "ca", "cc", "cp", "lg", "wa", "sh"}); UserSavedLookEvent lookEvent = new UserSavedLookEvent(habbo, habbo.getHabboInfo().getGender(), finalLook); Emulator.getPluginManager().fireEvent(lookEvent); if (!lookEvent.isCancelled()) { - habbo.getHabboStats().cache.put(CACHE_KEY, habbo.getHabboInfo().getLook()); + habbo.getHabboStats().getCache().put(CACHE_KEY, habbo.getHabboInfo().getLook()); habbo.getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_FBALLGATE ? ClothingValidationManager.validateLook(habbo, lookEvent.newLook, lookEvent.gender.name()) : lookEvent.newLook); Emulator.getThreading().run(habbo.getHabboInfo()); habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java index 2ef7f309..e142f113 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java @@ -101,19 +101,9 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { int state = (Integer) objects[0]; switch (state) { - case 1: { - this.changeScore(1); - } - break; - - case 2: { - this.changeScore(-1); - } - break; - - default: - this.setScore(0); - break; + case 1 -> this.changeScore(1); + case 2 -> this.changeScore(-1); + default -> this.setScore(0); } } else { this.changeScore(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java index 84ed5552..abbd2f3a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java @@ -103,7 +103,7 @@ public class InteractionFreezeBlock extends HabboItem { int powerUp; try { - powerUp = Integer.valueOf(this.getExtradata()) / 1000; + powerUp = Integer.parseInt(this.getExtradata()) / 1000; } catch (NumberFormatException e) { powerUp = 0; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java index 5b98b827..678afd3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java @@ -41,7 +41,7 @@ public class InteractionFreezeTile extends HabboItem { if (client == null) return; - if (client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY()) { + if (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY()) { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); if (game != null) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java index ec583fde..b2d75882 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java @@ -25,7 +25,7 @@ public class InteractionFreezeGate extends InteractionGameGate { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return room.getGame(FreezeGame.class) == null || ((FreezeGame) room.getGame(FreezeGame.class)).state.equals(GameState.IDLE); + return room.getGame(FreezeGame.class) == null || room.getGame(FreezeGame.class).state.equals(GameState.IDLE); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java index ac996a8b..df20b8d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.games.tag.BunnyrunGame; import com.eu.habbo.habbohotel.items.Item; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java index f83c64fa..75d25b2b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.icetag; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.games.tag.IceTagGame; import com.eu.habbo.habbohotel.items.Item; 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 087082e7..c29af75c 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 @@ -12,8 +12,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.pets.PerkAllowancesComposer; -import com.eu.habbo.messages.outgoing.rooms.pets.breeding.NestBreedingSuccessComposer; import com.eu.habbo.messages.outgoing.rooms.pets.breeding.ConfirmBreedingRequestComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.breeding.NestBreedingSuccessComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import java.sql.ResultSet; @@ -141,7 +141,7 @@ public class InteractionPetBreedingNest extends HabboItem { } } - public void breed(Habbo habbo, String name, int petOneId, int petTwoId) { + public void breed(Habbo habbo, String name) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId())); this.setExtradata("2"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index 0a140f9e..e667e4fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; 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 9cb0c9c1..f427e465 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 @@ -65,7 +65,7 @@ public class InteractionPetToy extends InteractionDefault { pet.packetUpdate = true; HabboItem item = this; Emulator.getThreading().run(() -> { - pet.addHappyness(25); + pet.addHappiness(25); item.setExtradata("0"); room.updateItem(item); pet.getRoomUnit().clearStatus(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java index 9b21744d..122ba764 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -68,7 +67,7 @@ public class InteractionPetTrampoline extends InteractionDefault { this.setExtradata("0"); room.updateItemState(this); }, 4000); - pet.addHappyness(25); + pet.addHappiness(25); this.setExtradata("1"); room.updateItemState(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index 35965fe6..5e5aa06c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -55,7 +55,7 @@ public class InteractionPetTree extends InteractionDefault { pet.packetUpdate = true; RoomUnitStatus finalTask = task; Emulator.getThreading().run(() -> { - pet.addHappyness(25); + pet.addHappiness(25); pet.getRoomUnit().clearStatus(); new PetClearPosture(pet, finalTask, null, true); if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index aa9dcb62..c54cd768 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -44,7 +44,7 @@ public class InteractionTotemHead extends InteractionDefault { if(extraData < 3) { return TotemColor.NONE; } - return TotemColor.fromInt(extraData - 3 - (4 * (getTotemType().type - 1))); + return TotemColor.fromInt(extraData - 3 - (4 * (getTotemType().getType() - 1))); } private void update(Room room, RoomTile tile) { @@ -58,7 +58,7 @@ public class InteractionTotemHead extends InteractionDefault { if(legs == null) return; - this.setExtradata(((4 * this.getTotemType().type) + legs.getTotemColor().color) - 1 + ""); + this.setExtradata(((4 * this.getTotemType().getType()) + legs.getTotemColor().getColor()) - 1 + ""); } public void updateTotemState(Room room) { @@ -66,7 +66,7 @@ public class InteractionTotemHead extends InteractionDefault { } public void updateTotemState(Room room, RoomTile tile) { - this.setExtradata(getTotemType().type - 1 + ""); + this.setExtradata(getTotemType().getType() - 1 + ""); update(room, tile); this.needsUpdate(true); room.updateItem(this); @@ -77,12 +77,12 @@ public class InteractionTotemHead extends InteractionDefault { if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; - TotemType newType = TotemType.fromInt(getTotemType().type + 1); + TotemType newType = TotemType.fromInt(getTotemType().getType() + 1); if(newType == TotemType.NONE) { newType = TotemType.TROLL; } - this.setExtradata(newType.type - 1 + ""); + this.setExtradata(newType.getType() - 1 + ""); updateTotemState(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index 6ae0c802..f12a5193 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -37,7 +37,7 @@ public class InteractionTotemLegs extends InteractionDefault { } catch(NumberFormatException ex) { extraData = 0; } - return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1))); + return TotemColor.fromInt(extraData - (4 * (getTotemType().getType() - 1))); } private void updateHead(Room room, RoomTile tile) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index e12cb1ed..6c9ddb3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -5,7 +5,6 @@ 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.users.HabboItem; -import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -83,7 +82,7 @@ public class InteractionTotemPlanet extends InteractionDefault { return; } - EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId); + client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId); client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java index 340bb47f..1d2fd1b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.items.interactions.totems; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum TotemColor { NONE(0), @@ -7,11 +12,8 @@ public enum TotemColor { YELLOW(2), BLUE(3); - public final int color; + private final int color; - TotemColor(int color) { - this.color = color; - } public static TotemColor fromInt(int color) { for(TotemColor totemColor : TotemColor.values()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java index bf8c7378..e737c195 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java @@ -1,15 +1,17 @@ package com.eu.habbo.habbohotel.items.interactions.totems; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum TotemPlanetType { MOON(0), SUN(1), EARTH(2); - public final int type; + private final int type; - TotemPlanetType(int type) { - this.type = type; - } public static TotemPlanetType fromInt(int type) { for(TotemPlanetType planetType : TotemPlanetType.values()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java index b82d909b..a0eb82e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.items.interactions.totems; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum TotemType { NONE(0), @@ -7,11 +12,9 @@ public enum TotemType { SNAKE(2), BIRD(3); - public final int type; + private final int type; + - TotemType(int type) { - this.type = type; - } public static TotemType fromInt(int type) { for(TotemType totemType : TotemType.values()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index 050a54c6..1774a6de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; @@ -73,7 +72,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { message.appendInt(this.startDate); message.appendInt(this.endDate); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.startDate); message.appendInt(this.endDate); } @@ -138,7 +137,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { try { this.startDate = Integer.parseInt(data[0]); this.endDate = Integer.parseInt(data[1]); - } catch (Exception e) { + } catch (Exception ignored) { } } } 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 22ec093a..53b108ae 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 @@ -10,7 +10,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -23,7 +22,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI; private boolean all; - private THashSet items; + private final THashSet items; public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -131,7 +130,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.all ? 1 : 0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 6a2a70a5..abae0d25 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 @@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -122,7 +121,8 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 9330457c..83838e76 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 @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -112,7 +111,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java index 5d4133d2..acab259f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java @@ -7,7 +7,6 @@ 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.WiredConditionType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -64,7 +63,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index df8e2108..839b7db4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -81,7 +80,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { message.appendInt(this.lowerLimit); message.appendInt(this.upperLimit); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 5f9f5b1a..52f951f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -71,7 +70,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { message.appendString(this.effectId + ""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 d60ddede..f56c0f5d 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 @@ -7,16 +7,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredConditionHabboHasHandItem.class); public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM; @@ -46,7 +44,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.handItem); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } @@ -84,7 +82,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { this.handItem = Integer.parseInt(wiredData); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java index 8d2b3dbe..81831829 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -83,7 +82,7 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { message.appendString(this.badge); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index f4db5bba..bd357437 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -76,7 +75,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.cycles); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 cd185dab..e3a68648 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 @@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -23,7 +22,7 @@ import java.util.List; public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; - private THashSet settings; + private final THashSet settings; private boolean state; private boolean position; @@ -53,7 +52,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition message.appendInt(this.settings.size()); for (WiredMatchFurniSetting item : this.settings) - message.appendInt(item.item_id); + message.appendInt(item.getItem_id()); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); @@ -64,7 +63,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition message.appendInt(this.position ? 1 : 0); message.appendInt(10); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } @@ -105,21 +104,21 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition THashSet s = new THashSet<>(); for (WiredMatchFurniSetting setting : this.settings) { - HabboItem item = room.getHabboItem(setting.item_id); + HabboItem item = room.getHabboItem(setting.getItem_id()); if (item != null) { if (this.state) { - if (!item.getExtradata().equals(setting.state)) + if (!item.getExtradata().equals(setting.getState())) return false; } if (this.position) { - if (!(setting.x == item.getX() && setting.y == item.getY())) + if (!(setting.getX() == item.getX() && setting.getY() == item.getY())) return false; } if (this.direction) { - if (setting.rotation != item.getRotation()) + if (setting.getRotation() != item.getRotation()) return false; } } else { @@ -191,7 +190,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition THashSet remove = new THashSet<>(); for (WiredMatchFurniSetting setting : this.settings) { - HabboItem item = room.getHabboItem(setting.item_id); + HabboItem item = room.getHabboItem(setting.getItem_id()); if (item == null) { remove.add(setting); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index 83bd3004..f2473726 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -76,7 +75,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.cycles); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 b09314c8..b0bf441a 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 @@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -132,7 +131,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.all ? 1 : 0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 9409ebe8..4410a39c 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 @@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -25,7 +24,7 @@ import java.util.stream.Collectors; public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; - + protected THashSet items; public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { @@ -122,7 +121,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 595eee3e..d2a09c8b 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 @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -112,7 +111,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java index 7f1d6cab..d9fe194c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -80,7 +79,7 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { message.appendInt(this.lowerLimit); message.appendInt(this.upperLimit); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java index 3f1a733d..749245f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -71,7 +70,7 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { message.appendString(this.effectId + ""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java index cf84c109..96d293ce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -84,7 +83,7 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition message.appendString(this.badge); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java index d7dbfbcb..55d284ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java @@ -7,7 +7,6 @@ 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.WiredConditionType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -64,7 +63,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index 0f9d6c95..9795a9a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -84,7 +83,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.teamColor.type); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 bc29186d..d6b11988 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 @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java index b8376c01..751dd4d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -86,7 +85,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { message.appendInt(1); message.appendInt(this.teamColor.type); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 0afdf18c..a8d9aae7 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 @@ -5,13 +5,11 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -113,7 +111,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } 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 24a28885..b0e1ff48 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 @@ -42,7 +42,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { message.appendString(this.botName + ((char) 9) + "" + this.botLook); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -107,7 +107,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length >= 3) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); this.botName = data[1]; this.botLook = data[2]; } 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 b46d0417..5d8d17c9 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 @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -14,7 +13,6 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -46,19 +44,16 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.mode); message.appendInt(1); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -138,7 +133,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 3) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0); this.botName = data[2]; } 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 5b380d3c..c82b0eda 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 @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -18,7 +17,6 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -50,19 +48,16 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.itemId); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -152,8 +147,8 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 3) { - this.setDelay(Integer.valueOf(data[0])); - this.itemId = Integer.valueOf(data[1]); + this.setDelay(Integer.parseInt(data[0])); + this.itemId = Integer.parseInt(data[1]); this.botName = data[2]; } 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 79fae2ca..11681d45 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 @@ -46,7 +46,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.mode); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -143,7 +143,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 4) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; this.message = data[3]; 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 ad0c8764..2c3b0698 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 @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -15,7 +14,6 @@ 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.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -49,19 +47,16 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.mode); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -166,7 +161,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 4) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; this.message = data[3]; 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 3374dc57..cea716c7 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 @@ -62,13 +62,13 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { return; } - if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) { + if (tile.getState() == RoomTileState.INVALID || tile.getState() == 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) { + if (optionalTile.getState() != RoomTileState.INVALID && optionalTile.getState() != RoomTileState.BLOCKED) { alternativeTile = optionalTile; break; } @@ -80,7 +80,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); - 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); + Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); } @Override @@ -107,7 +107,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { message.appendString(this.botName); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } 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 b4b9d262..c1b4da34 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 @@ -11,7 +11,6 @@ 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.incoming.wired.WiredSaveException; import gnu.trove.set.hash.THashSet; @@ -62,7 +61,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { message.appendString(this.botName); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -171,14 +170,14 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { String[] wiredDataSplit = set.getString("wired_data").split("\t"); if (wiredDataSplit.length >= 2) { - this.setDelay(Integer.valueOf(wiredDataSplit[0])); + this.setDelay(Integer.parseInt(wiredDataSplit[0])); String[] data = wiredDataSplit[1].split(";"); if (data.length > 1) { this.botName = data[0]; for (int i = 1; i < data.length; i++) { - HabboItem item = room.getHabboItem(Integer.valueOf(data[i])); + HabboItem item = room.getHabboItem(Integer.parseInt(data[i])); if (item != null) this.items.add(item); 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 7ee3859c..d3111df6 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 @@ -7,8 +7,10 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.*; -import com.eu.habbo.messages.ClientMessage; +import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -61,14 +63,14 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { for (Map.Entry entry : this.items.entrySet()) { HabboItem item = entry.getKey(); - RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().direction.getValue()); + RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue()); int count = 1; - while ((targetTile == null || targetTile.state == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { - entry.getValue().direction = this.nextRotation(entry.getValue().direction); + while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { + entry.getValue().setDirection(this.nextRotation(entry.getValue().getDirection())); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().direction.getValue()); - if (tile != null && tile.state != RoomTileState.INVALID) { + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue()); + if (tile != null && tile.getState() != RoomTileState.INVALID) { targetTile = tile; } @@ -78,15 +80,15 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { for (Map.Entry entry : this.items.entrySet()) { HabboItem item = entry.getKey(); - int newDirection = entry.getValue().direction.getValue(); + int newDirection = entry.getValue().getDirection().getValue(); RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirection); - if(item.getRotation() != entry.getValue().rotation) { - if(room.furnitureFitsAt(targetTile, item, entry.getValue().rotation, false) != FurnitureMovementError.NONE) + if(item.getRotation() != entry.getValue().getRotation()) { + if(room.furnitureFitsAt(targetTile, item, entry.getValue().getRotation(), false) != FurnitureMovementError.NONE) continue; - room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().rotation, null, true); + room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().getRotation(), null, true); } boolean hasRoomUnits = false; @@ -101,7 +103,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } } - if (targetTile != null && targetTile.state != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { + if (targetTile != null && targetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { if (!hasRoomUnits) { RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()); double oldZ = entry.getKey().getZ(); @@ -135,7 +137,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { this.blockedAction = data.blocked_action; for(WiredChangeDirectionSetting setting : data.items) { - HabboItem item = room.getHabboItem(setting.item_id); + HabboItem item = room.getHabboItem(setting.getItem_id()); if (item != null) { this.items.put(item, setting); @@ -205,7 +207,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { message.appendInt(this.startRotation != null ? this.startRotation.getValue() : 0); message.appendInt(this.blockedAction); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index 5b98543e..71345755 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -21,7 +21,7 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { int effectId; try { - effectId = Integer.valueOf(this.message); + effectId = Integer.parseInt(this.message); } catch (Exception e) { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java index ca39a49f..468cadaa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java @@ -20,7 +20,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { try { - int itemId = Integer.valueOf(this.message); + int itemId = Integer.parseInt(this.message); Habbo habbo = room.getHabbo(roomUnit); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java index 771e88b1..5903e1d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java @@ -43,7 +43,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff message.appendString(this.amount + ""); message.appendInt(0); message.appendInt(0); - message.appendInt(type.code); + message.appendInt(type.getCode()); message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { @@ -92,7 +92,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff return false; if (this.amount > 0) { - habbo.getHabboInfo().addCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount); + habbo.givePoints(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount); habbo.getClient().sendResponse(new BonusRareInfoMessageComposer(habbo)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java index d228c75e..f518cd0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java @@ -4,16 +4,13 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -43,19 +40,16 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { message.appendString(this.amount + ""); message.appendInt(0); message.appendInt(0); - message.appendInt(type.code); + message.appendInt(type.getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -117,11 +111,11 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { this.amount = 0; if (wiredData.split("\t").length >= 2) { - super.setDelay(Integer.valueOf(wiredData.split("\t")[0])); + super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); try { - this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]); - } catch (Exception e) { + this.amount = Integer.parseInt(this.getWiredData().split("\t")[1]); + } catch (Exception ignored) { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java index 91b78467..e25ab19a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java @@ -5,16 +5,13 @@ 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.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -44,19 +41,16 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { message.appendString(this.respects + ""); message.appendInt(0); message.appendInt(0); - message.appendInt(type.code); + message.appendInt(type.getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -92,7 +86,7 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { if (habbo == null) return false; - habbo.getHabboStats().respectPointsReceived += this.respects; + habbo.getHabboStats().increaseRespectPointsReceived(respects); AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), this.respects); return true; @@ -117,10 +111,10 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { this.respects = 0; if (data.length >= 2) { - super.setDelay(Integer.valueOf(data[0])); + super.setDelay(Integer.parseInt(data[0])); try { - this.respects = Integer.valueOf(data[1]); + this.respects = Integer.parseInt(data[1]); } catch (Exception e) { } } 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 607aa57e..bfe6afdf 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 @@ -4,7 +4,6 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; @@ -17,7 +16,6 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.generic.alerts.WiredValidationErrorComposer; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -80,12 +78,12 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { else { String[] data = wiredData.split(":"); if (data.length > 0) { - this.limit = Integer.valueOf(data[0]); - this.given = Integer.valueOf(data[1]); - this.rewardTime = Integer.valueOf(data[2]); + this.limit = Integer.parseInt(data[0]); + this.given = Integer.parseInt(data[1]); + this.rewardTime = Integer.parseInt(data[2]); this.uniqueRewards = data[3].equals("1"); - this.limitationInterval = Integer.valueOf(data[4]); - this.setDelay(Integer.valueOf(data[5])); + this.limitationInterval = Integer.parseInt(data[4]); + this.setDelay(Integer.parseInt(data[5])); if (data.length > 6) { if (!data[6].equalsIgnoreCase("\t")) { @@ -96,7 +94,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { for (String s : items) { try { this.rewardItems.add(new WiredGiveRewardItem(s)); - } catch (Exception e) { + } catch (Exception ignored) { } } } @@ -151,19 +149,16 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { message.appendInt(this.limit); message.appendInt(this.limitationInterval); message.appendInt(this.limit > 0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -196,7 +191,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { if (d.length == 3) { if (!(d[1].contains(":") || d[1].contains(";"))) { - this.rewardItems.add(new WiredGiveRewardItem(i, d[0].equalsIgnoreCase("0"), d[1], Integer.valueOf(d[2]))); + this.rewardItems.add(new WiredGiveRewardItem(i, d[0].equalsIgnoreCase("0"), d[1], Integer.parseInt(d[2]))); continue; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index 293515cc..ef253238 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -5,20 +5,17 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.iterator.TObjectIntIterator; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -33,7 +30,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { private int score; private int count; - private TObjectIntMap> data = new TObjectIntHashMap<>(); + private final TObjectIntMap> data = new TObjectIntHashMap<>(); public WiredEffectGiveScore(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -82,7 +79,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { try { this.data.put(new AbstractMap.SimpleEntry<>(gameStartTime, habbo.getHabboInfo().getId()), 1); } - catch(IllegalArgumentException e) { + catch(IllegalArgumentException ignored) { } @@ -116,9 +113,9 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { String[] data = wiredData.split(";"); if (data.length == 3) { - this.score = Integer.valueOf(data[0]); - this.count = Integer.valueOf(data[1]); - this.setDelay(Integer.valueOf(data[2])); + this.score = Integer.parseInt(data[0]); + this.count = Integer.parseInt(data[1]); + this.setDelay(Integer.parseInt(data[2])); } this.needsUpdate(true); @@ -149,19 +146,16 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { message.appendInt(this.score); message.appendInt(this.count); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index a439a668..b1d62b4e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.map.hash.TIntIntHashMap; @@ -79,10 +78,10 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { String[] data = set.getString("wired_data").split(";"); if (data.length == 4) { - this.points = Integer.valueOf(data[0]); - this.count = Integer.valueOf(data[1]); - this.teamColor = GameTeamColors.values()[Integer.valueOf(data[2])]; - this.setDelay(Integer.valueOf(data[3])); + this.points = Integer.parseInt(data[0]); + this.count = Integer.parseInt(data[1]); + this.teamColor = GameTeamColors.values()[Integer.parseInt(data[2])]; + this.setDelay(Integer.parseInt(data[3])); } this.needsUpdate(true); @@ -116,7 +115,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { message.appendInt(this.count); message.appendInt(this.teamColor.type); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index 28bd7c49..e83fa361 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -7,17 +7,14 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -78,10 +75,10 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { String[] data = set.getString("wired_data").split("\t"); if (data.length >= 1) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); if (data.length >= 2) { - this.teamColor = GameTeamColors.values()[Integer.valueOf(data[1])]; + this.teamColor = GameTeamColors.values()[Integer.parseInt(data[1])]; } } @@ -111,19 +108,16 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.teamColor.type); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index fa8f574f..09512ff8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -88,7 +88,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { String[] data = set.getString("wired_data").split("\t"); if (data.length >= 1) { - this.setDelay(Integer.valueOf(data[0])); + this.setDelay(Integer.parseInt(data[0])); if (data.length >= 2) { this.message = data[1]; @@ -124,7 +124,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { message.appendString(this.message); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java index 74830cfa..9265a125 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -69,7 +66,7 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { this.setDelay(data.delay); } else { - this.setDelay(Integer.valueOf(wiredData)); + this.setDelay(Integer.parseInt(wiredData)); } } @@ -93,19 +90,16 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { 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 8d74e312..5d827ded 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 @@ -11,13 +11,11 @@ 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.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,12 +23,12 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; +@Slf4j public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; public boolean checkForWiredResetPermission = true; - private THashSet settings; + private final THashSet settings; private boolean state = false; private boolean direction = false; private boolean position = false; @@ -52,11 +50,11 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int return true; for (WiredMatchFurniSetting setting : this.settings) { - HabboItem item = room.getHabboItem(setting.item_id); + HabboItem item = room.getHabboItem(setting.getItem_id()); if (item != null) { if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { - if (!setting.state.equals(" ") && !item.getExtradata().equals(setting.state)) { - item.setExtradata(setting.state); + if (!setting.getState().equals(" ") && !item.getExtradata().equals(setting.getState())) { + item.setExtradata(setting.getState()); room.updateItemState(item); } } @@ -65,16 +63,16 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int double oldZ = item.getZ(); if(this.direction && !this.position) { - if(item.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, item, setting.rotation, false) == FurnitureMovementError.NONE) { - room.moveFurniTo(item, oldLocation, setting.rotation, null, true); + if(item.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, item, setting.getRotation(), false) == FurnitureMovementError.NONE) { + room.moveFurniTo(item, oldLocation, setting.getRotation(), null, true); } } else if(this.position) { - boolean slideAnimation = !this.direction || item.getRotation() == setting.rotation; - RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); - int newRotation = this.direction ? setting.rotation : item.getRotation(); + boolean slideAnimation = !this.direction || item.getRotation() == setting.getRotation(); + RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); + int newRotation = this.direction ? setting.getRotation() : item.getRotation(); - if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { + if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { if(slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); @@ -92,7 +90,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int @Override public String getWiredData() { this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList(this.settings), this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<>(this.settings), this.getDelay())); } @Override @@ -115,17 +113,17 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int String[] items = data[1].split(Pattern.quote(";")); - for (int i = 0; i < items.length; i++) { + for (String item : items) { try { - String[] stuff = items[i].split(Pattern.quote("-")); + String[] stuff = item.split(Pattern.quote("-")); if (stuff.length >= 5) { this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -160,7 +158,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int message.appendInt(this.settings.size()); for (WiredMatchFurniSetting item : this.settings) - message.appendInt(item.item_id); + message.appendInt(item.getItem_id()); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); @@ -170,7 +168,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int message.appendInt(this.direction ? 1 : 0); message.appendInt(this.position ? 1 : 0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -227,7 +225,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int THashSet remove = new THashSet<>(); for (WiredMatchFurniSetting setting : this.settings) { - HabboItem item = room.getHabboItem(setting.item_id); + HabboItem item = room.getHabboItem(setting.getItem_id()); if (item == null) { remove.add(setting); } @@ -236,6 +234,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int for (WiredMatchFurniSetting setting : remove) { this.settings.remove(setting); } + } } 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 9f016a9e..cec31bf6 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 @@ -6,12 +6,10 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -88,7 +86,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); - if(newLocation != null && newLocation.state != RoomTileState.INVALID && newLocation != oldLocation && room.furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { + if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { if(room.moveFurniTo(item, newLocation, item.getRotation(), null, false) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } @@ -173,7 +171,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 4118fd05..6d0f8fd0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -11,7 +11,6 @@ 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.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -168,7 +167,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { message.appendInt(this.direction); message.appendInt(this.spacing); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } 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 89f56d3d..86400d3b 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 @@ -6,11 +6,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -62,16 +60,16 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { for (RoomUserRotation rot : rotations) { RoomTile tile = layout.getTileInFront(currentTile, rot.getValue()); - if (tile == null || tile.state == RoomTileState.BLOCKED || tile.state == RoomTileState.INVALID) + if (tile == null || tile.getState() == RoomTileState.BLOCKED || tile.getState() == RoomTileState.INVALID) continue; - if (!layout.tileExists(tile.x, tile.y)) + if (!layout.tileExists(tile.getX(), tile.getY())) continue; if (room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE) continue; - HabboItem topItem = room.getTopItemAt(tile.x, tile.y); + HabboItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); if (topItem != null && !topItem.getBaseItem().allowStack()) continue; @@ -131,7 +129,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { startTile = layout.getTileInFront(startTile, rot.getValue()); } - if (startTile != null && layout.tileExists(startTile.x, startTile.y)) { + if (startTile != null && layout.tileExists(startTile.getX(), startTile.getY())) { Collection roomUnitsAtTile = room.getRoomUnitsAt(startTile); if (roomUnitsAtTile.size() > 0) { target = roomUnitsAtTile.iterator().next(); @@ -222,7 +220,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if(newTile != null) { lastDirections.put(item.getId(), moveDirection); - if(newTile.state != RoomTileState.INVALID && newTile != oldLocation && room.furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { + if(newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { if (room.moveFurniTo(item, newTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getZ(), 0, room).compose()); } @@ -309,7 +307,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } 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 fd24af08..6272bc69 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 @@ -10,13 +10,11 @@ import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -24,15 +22,14 @@ import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; +@Slf4j public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable { - 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; private int rotation; - private THashSet itemCooldowns; + private final THashSet itemCooldowns; public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -69,7 +66,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement boolean slideAnimation = item.getRotation() == newRotation; FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true); - if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) { + if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) { if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { this.itemCooldowns.add(item); if(slideAnimation) { @@ -181,7 +178,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement message.appendInt(this.direction); message.appendInt(this.rotation); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -219,7 +216,6 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement * @return new rotation */ private int getNewRotation(HabboItem item) { - int rotationToAdd = 0; if(item.getMaximumRotations() == 2) { return item.getRotation() == 0 ? 4 : 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index 9497cf78..ba939604 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -44,7 +44,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.length); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); message.appendInt(0); } @@ -103,8 +103,8 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { if (data.length >= 3) { try { - this.setDelay(Integer.valueOf(data[0])); - this.length = Integer.valueOf(data[1]); + this.setDelay(Integer.parseInt(data[0])); + this.length = Integer.parseInt(data[1]); this.message = data[2]; } catch (Exception e) { } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 826b8d31..cef4072a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -10,7 +10,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredResetTimers; import gnu.trove.procedure.TObjectProcedure; @@ -44,7 +43,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { message.appendInt(1); message.appendInt(this.getDelay()); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { 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 5fa59787..06be7702 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 @@ -4,7 +4,6 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -18,7 +17,6 @@ import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -63,13 +61,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect { return; } - if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) { + if (tile.getState() == RoomTileState.INVALID || tile.getState() == 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) { + if (optionalTile.getState() != RoomTileState.INVALID && optionalTile.getState() != RoomTileState.BLOCKED) { alternativeTile = optionalTile; break; } @@ -81,7 +79,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); - 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); + Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); } @Override @@ -107,7 +105,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); 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 7a3a0e16..e1589385 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 @@ -6,9 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; -import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiPuck; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; @@ -24,13 +22,10 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -38,14 +33,14 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +@Slf4j 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; - private static final List> FORBIDDEN_TYPES = new ArrayList>() { + private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); this.add(InteractionTeleport.class); @@ -119,19 +114,16 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -178,8 +170,6 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - HabboItem triggerItem = null; - THashSet itemsToRemove = new THashSet<>(); for (HabboItem item : this.items) { if (item == null || item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { @@ -200,7 +190,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 d5e60925..48c52c48 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 @@ -21,13 +21,10 @@ 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.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -35,14 +32,14 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +@Slf4j 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<>(); - private static final List> FORBIDDEN_TYPES = new ArrayList>() { + private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); this.add(InteractionTeleport.class); @@ -114,19 +111,16 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -183,7 +177,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); room.updateItem(item); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.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 c74f39ae..64939ddc 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 @@ -4,7 +4,6 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -12,10 +11,8 @@ 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.incoming.wired.WiredSaveException; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -62,19 +59,16 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); 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; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -133,7 +127,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { { found = false; for (RoomTile tile : usedTiles) { - if (tile.x == item.getX() && tile.y == item.getY()) { + if (tile.getX() == item.getX() && tile.getY() == item.getY()) { found = true; break; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 42438dbf..7225fb29 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -7,7 +7,10 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.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.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -45,7 +48,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { message.appendString(this.message); message.appendInt(0); message.appendInt(0); - message.appendInt(type.code); + message.appendInt(type.getCode()); message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { @@ -132,7 +135,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { this.message = ""; if (wiredData.split("\t").length >= 2) { - super.setDelay(Integer.valueOf(wiredData.split("\t")[0])); + super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); this.message = wiredData.split("\t")[1]; } 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 8f859fd2..acf9fa33 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 @@ -10,27 +10,24 @@ 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 lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class WiredBlob extends InteractionDefault { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredBlob.class); + + @Getter + @AllArgsConstructor enum WiredBlobState { ACTIVE("0"), USED("1"); - private String state; - WiredBlobState(String state) { - this.state = state; - } - - public String getState() { - return state; - } + private final String state; } private int POINTS_REWARD = 0; @@ -106,14 +103,14 @@ public class WiredBlob extends InteractionDefault { String[] params = this.getBaseItem().getCustomParams().split(","); if (params.length != 2) { - LOGGER.error("Wired blobs should have customparams with two parameters (points,resetsWithGame)"); + log.error("Wired blobs should have customparams with two parameters (points,resetsWithGame)"); return; } try { this.POINTS_REWARD = Integer.parseInt(params[0]); } catch (NumberFormatException e) { - LOGGER.error("Wired blobs should have customparams with the first parameter being the amount of points (number)"); + log.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/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index 60756729..d9ce1284 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; @@ -10,10 +9,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredExecuteTask; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -88,18 +85,15 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi message.appendInt(1); message.appendInt(this.executeTime / 500); message.appendInt(1); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredEffect object) { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 7fdf0a2a..bde10d78 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; @@ -10,10 +9,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredExecuteTask; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -87,18 +84,15 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W message.appendInt(1); message.appendInt(this.executeTime / 500); message.appendInt(1); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredEffect object) { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { 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 3de2e345..c069c39d 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 @@ -1,9 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; @@ -11,12 +9,9 @@ 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.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 lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; @@ -24,12 +19,13 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +@Slf4j public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class); + public final static WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI; - private THashSet items; + private final THashSet items; private String botName = ""; public WiredTriggerBotReachedFurni(ResultSet set, Item baseItem) throws SQLException { @@ -75,18 +71,15 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { message.appendString(this.botName); message.appendInt(0); message.appendInt(0); - message.appendInt(WiredTriggerType.BOT_REACHED_STF.code); + message.appendInt(WiredTriggerType.BOT_REACHED_STF.getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredEffect object) { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { @@ -161,7 +154,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { if (item != null) this.items.add(item); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java index 0023fb6d..c303cb59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; @@ -8,12 +7,10 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; 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; -import java.util.List; public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_AVTR; @@ -43,7 +40,7 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { message.appendString(this.botName); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index a40bf2e1..11f46a8a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -8,7 +8,6 @@ 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.ClientMessage; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -60,7 +59,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(type.code); + message.appendInt(type.getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java index 5d315e52..48bd083d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java @@ -11,7 +11,6 @@ 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.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -131,7 +130,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index 55ff097c..b8b9459b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -1,15 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -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; @@ -61,18 +58,15 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredEffect object) { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 89c9a657..bd565f8a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.procedure.TObjectProcedure; @@ -61,7 +60,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.type.code); + message.appendInt(this.type.getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index d93a1ba1..a6e0ae7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -8,7 +8,6 @@ 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; @@ -80,7 +79,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { message.appendString(this.username); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index d0bdd637..0e3a04c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -8,7 +8,6 @@ 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; @@ -88,7 +87,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { message.appendString(this.key); message.appendInt(0); message.appendInt(1); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java index 10b458b9..2cf1458b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java @@ -9,7 +9,6 @@ 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.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -123,7 +122,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index d24be482..b6ba23d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java @@ -9,13 +9,11 @@ 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.ClientMessage; import com.eu.habbo.messages.ServerMessage; 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.stream.Collectors; @@ -77,7 +75,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { message.appendString(""); message.appendInt(0); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index f43ffac0..c97eaad8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; @@ -11,9 +10,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; 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 gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; @@ -56,7 +53,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy this.repeatTime = data.repeatTime; } else { if (wiredData.length() >= 1) { - this.repeatTime = (Integer.valueOf(wiredData)); + this.repeatTime = (Integer.parseInt(wiredData)); } } @@ -87,18 +84,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy message.appendInt(1); message.appendInt(this.repeatTime / 500); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredEffect object) { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 536aca86..cafe8779 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; 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 gnu.trove.procedure.TObjectProcedure; @@ -55,7 +54,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements this.repeatTime = data.repeatTime; } else { if (wiredData.length() >= 1) { - this.repeatTime = (Integer.valueOf(wiredData)); + this.repeatTime = (Integer.parseInt(wiredData)); } } @@ -85,7 +84,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements message.appendInt(1); message.appendInt(this.repeatTime / 5000); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index 463e5ba7..24cd112e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; 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; @@ -80,7 +79,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { message.appendInt(1); message.appendInt(this.score); message.appendInt(0); - message.appendInt(this.getType().code); + message.appendInt(this.getType().getCode()); message.appendInt(0); message.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java b/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java index 705fdae2..78c4bbb5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java @@ -1,8 +1,12 @@ package com.eu.habbo.habbohotel.messenger; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; - +@Getter +@AllArgsConstructor public class FriendRequest { private int id; private String username; @@ -13,22 +17,4 @@ public class FriendRequest { this.username = set.getString("username"); this.look = set.getString("look"); } - - public FriendRequest(int id, String username, String look) { - this.id = id; - this.username = username; - this.look = look; - } - - public int getId() { - return this.id; - } - - public String getUsername() { - return this.username; - } - - public String getLook() { - return this.look; - } } 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 a081bfc5..72fc3414 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java @@ -1,19 +1,22 @@ package com.eu.habbo.habbohotel.messenger; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@Getter 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; + + @Setter private String message; public Message(int fromId, int toId, String message) { @@ -35,28 +38,10 @@ public class Message implements Runnable { statement.setInt(4, this.timestamp); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } - public int getToId() { - return this.toId; - } - public int getFromId() { - return this.fromId; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - public int getTimestamp() { - return this.timestamp; - } } 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 fa4603cf..5f142514 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -10,9 +10,8 @@ import com.eu.habbo.messages.outgoing.friends.UpdateFriendComposer; import com.eu.habbo.plugin.events.users.friends.UserAcceptFriendRequestEvent; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -21,9 +20,10 @@ import java.sql.SQLException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; + +@Slf4j public class Messenger { - private static final Logger LOGGER = LoggerFactory.getLogger(Messenger.class); //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_PRIVATE_CHATS = false; @@ -46,7 +46,7 @@ public class Messenger { statement.setInt(4, userOne); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -60,7 +60,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return users; } @@ -95,7 +95,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -112,7 +112,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -124,7 +124,7 @@ public class Messenger { statement.setInt(2, userFrom); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -143,7 +143,7 @@ public class Messenger { count = set.getInt("count"); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return count; @@ -167,7 +167,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return map; } @@ -217,7 +217,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -241,7 +241,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return buddy; @@ -256,7 +256,7 @@ public class Messenger { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -315,7 +315,7 @@ public class Messenger { statement.setInt(1, userTo); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -327,7 +327,7 @@ public class Messenger { statement.setInt(3, userFrom); return statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return 0; @@ -349,7 +349,7 @@ public class Messenger { statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 44ef0a0b..05ccdc3a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -7,24 +7,36 @@ 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.NewConsoleMessageComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class MessengerBuddy implements Runnable, ISerialize { - private static final Logger LOGGER = LoggerFactory.getLogger(MessengerBuddy.class); + @Getter private int id; + @Getter + @Setter private String username; + @Getter + @Setter private HabboGender gender = HabboGender.M; + @Getter private int online = 0; + @Setter + @Getter private String look = ""; + @Getter private String motto = ""; + @Getter private short relation; + @Getter private int categoryId = 0; private boolean inRoom; private int userOne = 0; @@ -49,7 +61,7 @@ public class MessengerBuddy implements Runnable, ISerialize { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -62,7 +74,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.userOne = 0; this.online = set.getInt("online"); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -89,57 +101,15 @@ public class MessengerBuddy implements Runnable, ISerialize { this.inRoom = habbo.getHabboInfo().getCurrentRoom() != null; } - public int getId() { - return this.id; - } - - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.username = username; - } - - public HabboGender getGender() { - return this.gender; - } - - public void setGender(HabboGender gender) { - this.gender = gender; - } - - public int getOnline() { - return this.online; - } - public void setOnline(boolean value) { this.online = (value ? 1 : 0); } - public String getLook() { - return this.look; - } - - public void setLook(String look) { - this.look = look; - } - - public String getMotto() { - return this.motto; - } - - public short getRelation() { - return this.relation; - } - public void setRelation(int relation) { this.relation = (short) relation; Emulator.getThreading().run(this); } - public int getCategoryId() { return this.categoryId; } - public boolean inRoom() { return this.inRoom; } @@ -157,7 +127,7 @@ public class MessengerBuddy implements Runnable, ISerialize { statement.setInt(3, this.id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java index b19a43b0..ac8ef3f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java @@ -1,31 +1,20 @@ package com.eu.habbo.habbohotel.messenger; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@AllArgsConstructor public class MessengerCategory { - private int user_id; + @Setter + @Getter private String name; + @Getter + private int user_id; + @Setter + @Getter private int id; - public MessengerCategory(String name, int user_id, int id) { - this.name = name; - this.user_id = user_id; - this.id = id; - } - - public String getName() { - return name; - } - - public int getUserId() { - return user_id; - } - - public int getId() { - return id; - } - - public void setName(String name) { - this.name = name; - } - public void setId(int id) { this.id = id; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java index 2c6f95d0..d9cd3aea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java @@ -1,30 +1,27 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum CfhActionType { MODS(0), AUTO_REPLY(1), AUTO_IGNORE(2), GUARDIANS(3); - public final int type; + private final int type; - CfhActionType(int type) { - this.type = type; - } public static CfhActionType get(String name) { - switch (name) { - case "auto_reply": - return CfhActionType.AUTO_REPLY; + return switch (name) { + case "auto_reply" -> CfhActionType.AUTO_REPLY; + case "auto_ignore" -> CfhActionType.AUTO_IGNORE; + case "guardians" -> CfhActionType.GUARDIANS; + default -> CfhActionType.MODS; + }; - case "auto_ignore": - return CfhActionType.AUTO_IGNORE; - - case "guardians": - return CfhActionType.GUARDIANS; - } - - return CfhActionType.MODS; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java index dfb196da..a93b43b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java @@ -3,10 +3,13 @@ package com.eu.habbo.habbohotel.modtool; import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; +import lombok.Getter; public class CfhCategory { private final int id; + @Getter private final String name; + @Getter private final TIntObjectMap topics; public CfhCategory(int id, String name) { @@ -16,14 +19,7 @@ public class CfhCategory { } public void addTopic(CfhTopic topic) { - this.topics.put(topic.id, topic); + this.topics.put(topic.getId(), topic); } - public TIntObjectMap getTopics() { - return this.topics; - } - - public String getName() { - return this.name; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java index 1a7f3bed..3464f379 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java @@ -1,15 +1,19 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; +@Getter public class CfhTopic { - public final int id; - public final String name; - public final CfhActionType action; - public final boolean ignoreTarget; - public final String reply; - public final ModToolPreset defaultSanction; + private final int id; + private final String name; + private final CfhActionType action; + private final boolean ignoreTarget; + + private final String reply; + private final ModToolPreset defaultSanction; public CfhTopic(ResultSet set, ModToolPreset defaultSanction) throws SQLException { this.id = set.getInt("id"); 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 3c8517da..1515f324 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -10,21 +10,22 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; +@Slf4j +@Getter 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; - public String machineId; - public int staffId; - public int expireDate; - public int timestamp; - public String reason; - public ModToolBanType type; - public int cfhTopic; + private int userId; + private String ip; + private String machineId; + private int staffId; + private int expireDate; + private int timestamp; + private String reason; + private ModToolBanType type; + private int cfhTopic; - private boolean needsInsert; + private boolean needsInsert; public ModToolBan(ResultSet set) throws SQLException { this.userId = set.getInt("user_id"); @@ -67,7 +68,7 @@ public class ModToolBan implements Runnable { statement.setInt(9, this.cfhTopic); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java index 76c0142e..69d9af77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolBanType { ACCOUNT("account"), MACHINE("machine"), @@ -9,10 +14,6 @@ public enum ModToolBanType { private final String type; - ModToolBanType(String type) { - this.type = type; - } - public static ModToolBanType fromString(String type) { for (ModToolBanType t : ModToolBanType.values()) { if (t.type.equalsIgnoreCase(type)) { @@ -22,8 +23,4 @@ public enum ModToolBanType { return UNKNOWN; } - - public String getType() { - return this.type; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java index 10e28a84..32fd86c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java @@ -3,9 +3,12 @@ package com.eu.habbo.habbohotel.modtool; import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; +import lombok.Getter; public class ModToolCategory { + @Getter private final String name; + @Getter private final TIntObjectMap presets; public ModToolCategory(String name) { @@ -14,14 +17,7 @@ public class ModToolCategory { } public void addPreset(ModToolPreset preset) { - this.presets.put(preset.id, preset); + this.presets.put(preset.getId(), preset); } - public TIntObjectMap getPresets() { - return this.presets; - } - - public String getName() { - return this.name; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java index 0ba469f7..636ec815 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java @@ -1,27 +1,19 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@AllArgsConstructor +@RequiredArgsConstructor public class ModToolChatLog implements Comparable { - public final int timestamp; - public final int habboId; - public final String username; - public final String message; - public final boolean highlighted; + private final int timestamp; + private final int habboId; + private final String username; + private final String message; + private boolean highlighted = false; - public ModToolChatLog(int timestamp, int habboId, String username, String message) { - this.timestamp = timestamp; - this.habboId = habboId; - this.username = username; - this.message = message; - this.highlighted = false; - } - - public ModToolChatLog(int timestamp, int habboId, String username, String message, boolean highlighted) { - this.timestamp = timestamp; - this.habboId = habboId; - this.username = username; - this.message = message; - this.highlighted = highlighted; - } @Override public int compareTo(ModToolChatLog o) { diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java index 37908488..db7833c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java @@ -1,7 +1,11 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.messages.ServerMessage; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public enum ModToolChatRecordDataContext { ROOM_NAME("roomName", 2), ROOM_ID("roomId", 1), @@ -10,13 +14,9 @@ public enum ModToolChatRecordDataContext { MESSAGE_ID("messageId", 1), PHOTO_ID("extraDataId", 2); - public final String key; - public final int type; + private final String key; + private final int type; - ModToolChatRecordDataContext(String key, int type) { - this.key = key; - this.type = type; - } public void append(final ServerMessage message) { message.appendString(this.key); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java index 8d08a88f..700d3a07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolChatRecordDataType { UNKNOWN(0), ROOM_TOOL(1), @@ -9,9 +14,6 @@ public enum ModToolChatRecordDataType { SELFIE(5), PHOTO_REPORT(6); - public final int type; + private final int type; - ModToolChatRecordDataType(int type) { - this.type = type; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java index b3cac442..c9919cfe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java @@ -1,13 +1,15 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolChatlogType { BOT_PET(0), YELLOW(1), BLUE(2); - public final int type; + private final int type; - ModToolChatlogType(int type) { - this.type = type; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index f9b008db..a3dfbd23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -96,9 +96,9 @@ public class ModToolIssue implements ISerialize { if (this.chatLogs != null) { message.appendInt(this.chatLogs.size()); for (ModToolChatLog chatLog : this.chatLogs) { - message.appendString(chatLog.message); + message.appendString(chatLog.getMessage()); message.appendInt(0); - message.appendInt(chatLog.message.length()); + message.appendInt(chatLog.getMessage().length()); } } else { message.appendInt(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java index 35db44b7..c04b5785 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolIssueChatlogType { NORMAL(0), CHAT(1), @@ -9,13 +14,6 @@ public enum ModToolIssueChatlogType { SELFIE(5), PHOTO(6); - private int type; + private final int type; - ModToolIssueChatlogType(int type) { - this.type = type; - } - - public int getType() { - return type; - } } 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 988c7de7..3656c48f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -18,11 +18,9 @@ import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; 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 lombok.extern.slf4j.Slf4j; import java.net.InetSocketAddress; import java.sql.*; @@ -30,8 +28,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +@Slf4j public class ModToolManager { - private static final Logger LOGGER = LoggerFactory.getLogger(ModToolManager.class); private final TIntObjectMap category; private final THashMap> presets; @@ -45,7 +43,7 @@ public class ModToolManager { this.tickets = new THashMap<>(); this.cfhCategories = new TIntObjectHashMap<>(); this.loadModTool(); - LOGGER.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void requestUserInfo(GameClient client, ClientMessage packet) { @@ -62,9 +60,9 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -82,7 +80,7 @@ public class ModToolManager { this.loadTickets(connection); this.loadCfhCategories(connection); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -101,7 +99,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -112,7 +110,7 @@ public class ModToolManager { this.presets.get(set.getString("type")).add(set.getString("preset")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -124,7 +122,7 @@ public class ModToolManager { this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -150,14 +148,14 @@ public class ModToolManager { this.cfhCategories.get(set.getInt("support_cfh_category_id")).addTopic(new CfhTopic(set, this.getIssuePreset(set.getInt("default_sanction")))); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public CfhTopic getCfhTopic(int topicId) { for (CfhCategory category : this.getCfhCategories().valueCollection()) { for (CfhTopic topic : category.getTopics().valueCollection()) { - if (topic.id == topicId) { + if (topic.getId() == topicId) { return topic; } } @@ -171,12 +169,9 @@ public class ModToolManager { return null; final ModToolPreset[] preset = {null}; - this.category.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(ModToolCategory object) { - preset[0] = object.getPresets().get(id); - return preset[0] == null; - } + this.category.forEachValue(object -> { + preset[0] = object.getPresets().get(id); + return preset[0] == null; }); return preset[0]; @@ -200,7 +195,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return chatlogs; @@ -217,7 +212,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return chatlogs; @@ -237,7 +232,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return chatLogs; @@ -255,7 +250,7 @@ public class ModToolManager { ModToolRoomVisit visit = null; for (ModToolRoomVisit v : chatlogs) { - if (v.timestamp == set.getInt("enter_timestamp") && v.exitTimestamp == set.getInt("exit_timestamp")) { + if (v.getTimestamp() == set.getInt("enter_timestamp") && v.getExitTimestamp() == set.getInt("exit_timestamp")) { visit = v; } } @@ -264,7 +259,7 @@ public class ModToolManager { visit = new ModToolRoomVisit(set.getInt("room_id"), set.getString("name"), set.getInt("enter_timestamp"), set.getInt("exit_timestamp")); chatlogs.add(visit); } - visit.chat.add(new ModToolChatLog(set.getInt("timestamp"), set.getInt("user_from_id"), set.getString("username"), set.getString("message"))); + visit.getChat().add(new ModToolChatLog(set.getInt("timestamp"), set.getInt("user_from_id"), set.getString("username"), set.getString("message"))); if (userid == 0) userid = set.getInt("user_from_id"); @@ -274,7 +269,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return chatlogs; @@ -292,7 +287,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return roomVisits; @@ -350,7 +345,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return roomVisits; @@ -380,7 +375,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return null; @@ -427,16 +422,16 @@ public class ModToolManager { } //if machine id is empty, downgrade ban type to IP ban - if( (type == ModToolBanType.MACHINE || type == ModToolBanType.SUPER) && (offlineInfo == null || offlineInfo.getMachineID().isEmpty())) { + if((type == ModToolBanType.MACHINE || type == ModToolBanType.SUPER) && offlineInfo.getMachineID().isEmpty()) { type = ModToolBanType.IP; } //if ip address is empty, downgrade ban type to account ban - if( (type == ModToolBanType.IP || type == ModToolBanType.SUPER) && (offlineInfo == null || offlineInfo.getIpLogin().isEmpty())) { + if((type == ModToolBanType.IP || type == ModToolBanType.SUPER) && offlineInfo.getIpLogin().isEmpty()) { type = ModToolBanType.ACCOUNT; } - ModToolBan ban = new ModToolBan(targetUserId, offlineInfo != null ? offlineInfo.getIpLogin() : "offline", offlineInfo != null ? offlineInfo.getMachineID() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); + ModToolBan ban = new ModToolBan(targetUserId, offlineInfo.getIpLogin(), offlineInfo.getMachineID(), moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, target, ban)); Emulator.getThreading().run(ban); bans.add(ban); @@ -445,11 +440,11 @@ public class ModToolManager { Emulator.getGameServer().getGameClientManager().disposeClient(target.getClient()); } - if ((type == ModToolBanType.IP || type == ModToolBanType.SUPER) && target != null && !ban.ip.equals("offline")) { - for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(ban.ip)) { + if ((type == ModToolBanType.IP || type == ModToolBanType.SUPER) && target != null && !ban.getIp().equals("offline")) { + for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(ban.getIp())) { if (h.getHabboInfo().getRank().getId() >= moderator.getHabboInfo().getRank().getId()) continue; - ban = new ModToolBan(h.getHabboInfo().getId(), h != null ? h.getHabboInfo().getIpLogin() : "offline", h != null ? h.getClient().getMachineId() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); + ban = new ModToolBan(h.getHabboInfo().getId(), h.getHabboInfo().getIpLogin(), h.getClient().getMachineId(), moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, h, ban)); Emulator.getThreading().run(ban); bans.add(ban); @@ -457,11 +452,11 @@ public class ModToolManager { } } - if ((type == ModToolBanType.MACHINE || type == ModToolBanType.SUPER) && target != null && !ban.machineId.equals("offline")) { - for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithMachineId(ban.machineId)) { + if ((type == ModToolBanType.MACHINE || type == ModToolBanType.SUPER) && target != null && !ban.getMachineId().equals("offline")) { + for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithMachineId(ban.getMachineId())) { if (h.getHabboInfo().getRank().getId() >= moderator.getHabboInfo().getRank().getId()) continue; - ban = new ModToolBan(h.getHabboInfo().getId(), h != null ? h.getHabboInfo().getIpLogin() : "offline", h != null ? h.getClient().getMachineId() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); + ban = new ModToolBan(h.getHabboInfo().getId(), h.getHabboInfo().getIpLogin(), h.getClient().getMachineId(), moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic); Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, h, ban)); Emulator.getThreading().run(ban); bans.add(ban); @@ -507,7 +502,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return ban; @@ -536,7 +531,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return banned; } @@ -559,7 +554,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -573,7 +568,7 @@ public class ModToolManager { statement.execute(); return statement.getUpdateCount() > 0; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; @@ -678,7 +673,7 @@ public class ModToolManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return total; @@ -711,15 +706,12 @@ public class ModToolManager { public List openTicketsForHabbo(Habbo habbo) { List issues = new ArrayList<>(); synchronized (this.tickets) { - this.tickets.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(ModToolIssue object) { - if (object.senderId == habbo.getHabboInfo().getId() && object.state == ModToolTicketState.OPEN) { - issues.add(object); - } - - return true; + this.tickets.forEachValue(object -> { + if (object.senderId == habbo.getHabboInfo().getId() && object.state == ModToolTicketState.OPEN) { + issues.add(object); } + + return true; }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java index 2b4208c4..6e705862 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java @@ -1,15 +1,17 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; - +@Getter public class ModToolPreset { - public final int id; - public final String name; - public final String message; - public final String reminder; - public final int banLength; - public final int muteLength; + private final int id; + private final String name; + private final String message; + private final String reminder; + private final int banLength; + private final int muteLength; public ModToolPreset(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java index 0ccabbdb..42197409 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java @@ -1,16 +1,20 @@ package com.eu.habbo.habbohotel.modtool; import gnu.trove.set.hash.THashSet; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; + +@Getter public class ModToolRoomVisit implements Comparable { - public int roomId; - public String roomName; - public int timestamp; - public int exitTimestamp; - public THashSet chat; + private final int roomId; + private final String roomName; + private final int timestamp; + private int exitTimestamp; + private THashSet chat = new THashSet<>(); + ; public ModToolRoomVisit(ResultSet set) throws SQLException { this.roomId = set.getInt("room_id"); @@ -23,7 +27,7 @@ public class ModToolRoomVisit implements Comparable { this.roomName = roomName; this.timestamp = timestamp; this.exitTimestamp = exitTimestamp; - this.chat = new THashSet<>(); + } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java index 70d2b375..90bd9ed2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java @@ -1,14 +1,17 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.Getter; + +@Getter public class ModToolSanctionItem { - public int id; - public int habboId; - public int sanctionLevel; - public int probationTimestamp; - public boolean isMuted; - public int muteDuration; - public int tradeLockedUntil; - public String reason; + private int id; + private int habboId; + private int sanctionLevel; + private int probationTimestamp; + private boolean isMuted; + private int muteDuration; + private int tradeLockedUntil; + private String reason; public ModToolSanctionItem(int id, int habboId, int sanctionLevel, int probationTimestamp, boolean isMuted, int muteDuration, int tradeLockedUntil, String reason) { this.id = id; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java index d893b4e2..362a3d46 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.Getter; + +@Getter public class ModToolSanctionLevelItem { - public int sanctionLevel; - public String sanctionType; - public int sanctionHourLength; - public int sanctionProbationDays; + private int sanctionLevel; + private String sanctionType; + private int sanctionHourLength; + private int sanctionProbationDays; public ModToolSanctionLevelItem(int sanctionLevel, String sanctionType, int sanctionHourLength, int sanctionProbationDays) { this.sanctionLevel = sanctionLevel; 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 3960d07e..beec976e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -4,8 +4,7 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,9 +12,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; - +@Slf4j public class ModToolSanctions { - private static final Logger LOGGER = LoggerFactory.getLogger(ModToolSanctions.class); private final THashMap> sanctionHashmap; private final THashMap sanctionLevelsHashmap; @@ -26,7 +24,7 @@ public class ModToolSanctions { this.sanctionLevelsHashmap = new THashMap<>(); this.loadModSanctions(); - LOGGER.info("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public synchronized void loadModSanctions() { @@ -44,7 +42,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -59,9 +57,7 @@ public class ModToolSanctions { statement.setInt(1, habboId); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - if (this.sanctionHashmap.get(set.getInt("habbo_id")) == null) { - this.sanctionHashmap.put(set.getInt("habbo_id"), new ArrayList<>()); - } + this.sanctionHashmap.computeIfAbsent(set.getInt("habbo_id"), k -> new ArrayList<>()); ModToolSanctionItem item = new ModToolSanctionItem(set.getInt("id"), set.getInt("habbo_id"), set.getInt("sanction_level"), set.getInt("probation_timestamp"), set.getBoolean("is_muted"), set.getInt("mute_duration"), set.getInt("trade_locked_until"), set.getString("reason")); @@ -71,7 +67,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return this.sanctionHashmap; @@ -90,7 +86,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -101,7 +97,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -112,7 +108,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -123,7 +119,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -140,11 +136,11 @@ public class ModToolSanctions { } private int buildProbationTimestamp(ModToolSanctionLevelItem sanctionLevelItem) { - return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.sanctionProbationDays * 24 * 60 * 60); + return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.getSanctionProbationDays() * 24 * 60 * 60); } public int getProbationDays(ModToolSanctionLevelItem sanctionLevelItem) { - return sanctionLevelItem.sanctionProbationDays; + return sanctionLevelItem.getSanctionProbationDays(); } private void runSanctionBasedOnLevel(ModToolSanctionLevelItem sanctionLevelItem, int habboId, String reason, int cfhTopic, Habbo self, int muteDuration) { @@ -158,19 +154,21 @@ public class ModToolSanctions { muteDurationSeconds = Math.toIntExact(diff / 1000); } - switch (sanctionLevelItem.sanctionType) { - case "ALERT": habbo.alert(reason); break; - case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break; - case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds, false); break; - default: break; + switch (sanctionLevelItem.getSanctionType()) { + case "ALERT" -> habbo.alert(reason); + case "BAN" -> + Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.getSanctionHourLength(), ModToolBanType.ACCOUNT, cfhTopic); + case "MUTE" -> habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds, false); + default -> { + } } } public String getSanctionType(ModToolSanctionLevelItem sanctionLevelItem) { - return sanctionLevelItem.sanctionType; + return sanctionLevelItem.getSanctionType(); } public int getTimeOfSanction(ModToolSanctionLevelItem sanctionLevelItem) { - return sanctionLevelItem.sanctionHourLength; + return sanctionLevelItem.getSanctionHourLength(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java index 4bba6c84..f1e4d5fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolTicketState { CLOSED(0), OPEN(1), @@ -7,9 +12,6 @@ public enum ModToolTicketState { private final int state; - ModToolTicketState(int state) { - this.state = state; - } public static ModToolTicketState getState(int number) { for (ModToolTicketState s : ModToolTicketState.values()) { @@ -20,7 +22,4 @@ public enum ModToolTicketState { return CLOSED; } - public int getState() { - return this.state; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java index 4eb8aace..b577f924 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ModToolTicketType { NORMAL(1), NORMAL_UNKNOWN(2), @@ -19,11 +24,4 @@ public enum ModToolTicketType { private final int type; - ModToolTicketType(int type) { - this.type = type; - } - - public int getType() { - return this.type; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ScripterEvent.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ScripterEvent.java index 82843275..b12e2b2e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ScripterEvent.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ScripterEvent.java @@ -2,10 +2,12 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.support.SupportEvent; +import lombok.Getter; +@Getter public class ScripterEvent extends SupportEvent { - public final Habbo habbo; - public final String reason; + private final Habbo habbo; + private final String reason; public ScripterEvent(Habbo habbo, String reason) { super(null); 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 b6f7fe01..66762361 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -8,9 +8,8 @@ import com.eu.habbo.messages.outgoing.friends.NewConsoleMessageComposer; import com.eu.habbo.plugin.events.users.UserTriggerWordFilterEvent; import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -19,8 +18,8 @@ import java.sql.Statement; import java.text.Normalizer; import java.util.regex.Pattern; +@Slf4j public class WordFilter { - private static final Logger LOGGER = LoggerFactory.getLogger(WordFilter.class); private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+"); //Configuration. Loaded from database & updated accordingly. @@ -33,7 +32,7 @@ public class WordFilter { public WordFilter() { long start = System.currentTimeMillis(); this.reload(); - LOGGER.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); + log.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); } private static String stripDiacritics(String str) { @@ -58,20 +57,20 @@ public class WordFilter { try { word = new WordFilterWord(set); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); continue; } - if (word.autoReport) + if (word.isAutoReport()) this.autoReportWords.add(word); - else if (word.hideMessage) + else if (word.isHideMessage()) this.hideMessageWords.add(word); this.words.add(word); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -90,16 +89,12 @@ public class WordFilter { public boolean autoReportCheck(RoomChatMessage roomChatMessage) { String message = this.normalise(roomChatMessage.getMessage()).toLowerCase(); - TObjectHashIterator iterator = this.autoReportWords.iterator(); - - while (iterator.hasNext()) { - WordFilterWord word = (WordFilterWord) iterator.next(); - - if (message.contains(word.key)) { + for (WordFilterWord word : this.autoReportWords) { + if (message.contains(word.getKey())) { Emulator.getGameEnvironment().getModToolManager().quickTicket(roomChatMessage.getHabbo(), "Automatic WordFilter", roomChatMessage.getMessage()); if (Emulator.getConfig().getBoolean("notify.staff.chat.auto.report")) { - Emulator.getGameEnvironment().getHabboManager().sendPacketToHabbosWithPermission(new NewConsoleMessageComposer(new Message(roomChatMessage.getHabbo().getHabboInfo().getId(), 0, Emulator.getTexts().getValue("warning.auto.report").replace("%user%", roomChatMessage.getHabbo().getHabboInfo().getUsername()).replace("%word%", word.key))).compose(), "acc_staff_chat"); + Emulator.getGameEnvironment().getHabboManager().sendPacketToHabbosWithPermission(new NewConsoleMessageComposer(new Message(roomChatMessage.getHabbo().getHabboInfo().getId(), 0, Emulator.getTexts().getValue("warning.auto.report").replace("%user%", roomChatMessage.getHabbo().getHabboInfo().getUsername()).replace("%word%", word.getKey()))).compose(), "acc_staff_chat"); } return true; } @@ -111,12 +106,8 @@ public class WordFilter { public boolean hideMessageCheck(String message) { message = this.normalise(message).toLowerCase(); - TObjectHashIterator iterator = this.hideMessageWords.iterator(); - - while (iterator.hasNext()) { - WordFilterWord word = (WordFilterWord) iterator.next(); - - if (message.contains(word.key)) { + for (WordFilterWord word : this.hideMessageWords) { + if (message.contains(word.getKey())) { return true; } } @@ -145,16 +136,16 @@ public class WordFilter { while (iterator.hasNext()) { WordFilterWord word = (WordFilterWord) iterator.next(); - if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) { + if (StringUtils.containsIgnoreCase(filteredMessage, word.getKey())) { if (habbo != null) { if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } - filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement); + filteredMessage = filteredMessage.replace("(?i)" + word.getKey(), word.getReplacement()); foundShit = true; - if (habbo != null && word.muteTime > 0) { - habbo.mute(word.muteTime, false); + if (habbo != null && word.getMuteTime() > 0) { + habbo.mute(word.getMuteTime(), false); } } } @@ -173,18 +164,14 @@ public class WordFilter { message = this.normalise(message); } - TObjectHashIterator iterator = this.words.iterator(); - - while (iterator.hasNext()) { - WordFilterWord word = (WordFilterWord) iterator.next(); - - if (StringUtils.containsIgnoreCase(message, word.key)) { + for (WordFilterWord word : this.words) { + if (StringUtils.containsIgnoreCase(message, word.getKey())) { if (habbo != null) { if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } - message = message.replace(word.key, word.replacement); + message = message.replace(word.getKey(), word.getReplacement()); roomChatMessage.filtered = true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java index 0f8420a3..1016110a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java @@ -1,14 +1,16 @@ package com.eu.habbo.habbohotel.modtool; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; - +@Getter public class WordFilterWord { - public final String key; - public final String replacement; - public final boolean hideMessage; - public final boolean autoReport; - public final int muteTime; + private final String key; + private final String replacement; + private final boolean hideMessage; + private final boolean autoReport; + private final int muteTime; public WordFilterWord(ResultSet set) throws SQLException { this.key = set.getString("key"); diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java index 264c8943..63a19af4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java @@ -1,39 +1,27 @@ package com.eu.habbo.habbohotel.navigation; import com.eu.habbo.messages.ServerMessage; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class EventCategory { private int id; private String caption; private boolean visible; - public EventCategory(int id, String caption, boolean visible) { - this.id = id; - this.caption = caption; - this.visible = visible; - } public EventCategory(String serialized) throws Exception { String[] parts = serialized.split(","); if (parts.length != 3) throw new Exception("A serialized event category should contain 3 fields"); - this.id = Integer.valueOf(parts[0]); + this.id = Integer.parseInt(parts[0]); this.caption = parts[1]; this.visible = parts[2].equalsIgnoreCase("true"); } - public int getId() { - return id; - } - - public String getCaption() { - return caption; - } - - public boolean isVisible() { - return visible; - } public void serialize(ServerMessage message) { message.appendInt(this.id); diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java b/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java index cf4e50b0..9f2bfb86 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java @@ -1,15 +1,17 @@ package com.eu.habbo.habbohotel.navigation; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum ListMode { LIST(0), THUMBNAILS(1), FORCED_THUNBNAILS(2); - public final int type; + private final int type; - ListMode(int type) { - this.type = type; - } public static ListMode fromType(int type) { for (ListMode m : ListMode.values()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java index 71225cd3..93c3c761 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class NavigatorFavoriteFilter extends NavigatorFilter { @@ -19,7 +18,7 @@ public class NavigatorFavoriteFilter extends NavigatorFilter { public List getResult(Habbo habbo) { List resultLists = new ArrayList<>(); List rooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("favorites", habbo); - resultLists.add(new SearchResultList(0, "favorites", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("favorites", ListMode.LIST), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("popular", DisplayMode.VISIBLE), rooms, true, true, DisplayOrder.ACTIVITY, -1)); + resultLists.add(new SearchResultList(0, "favorites", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("favorites", ListMode.LIST), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("popular", DisplayMode.VISIBLE), rooms, true, true, DisplayOrder.ACTIVITY, -1)); return resultLists; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java index 52475d0f..019f5dc5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java @@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public abstract class NavigatorFilter { @@ -29,11 +28,11 @@ public abstract class NavigatorFilter { } for (SearchResultList result : collection) { - if (!result.filter) { + if (!result.isFilter()) { continue; } - this.filterRooms(method, value, result.rooms); + this.filterRooms(method, value, result.getRooms()); } } @@ -82,7 +81,7 @@ public abstract class NavigatorFilter { } } } - } catch (Exception e) { + } catch (Exception ignored) { } result.removeAll(toRemove); diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java index e7a717c0..5da5872d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java @@ -1,17 +1,15 @@ package com.eu.habbo.habbohotel.navigation; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.lang.reflect.Method; +@AllArgsConstructor +@Getter public class NavigatorFilterField { - public final String key; - public final Method field; - public final String databaseQuery; - public final NavigatorFilterComparator comparator; - - public NavigatorFilterField(String key, Method field, String databaseQuery, NavigatorFilterComparator comparator) { - this.key = key; - this.field = field; - this.databaseQuery = databaseQuery; - this.comparator = comparator; - } + private final String key; + private final Method field; + private final String databaseQuery; + private final NavigatorFilterComparator comparator; } \ No newline at end of file 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 0a7825a5..b8999b16 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java @@ -23,14 +23,14 @@ public class NavigatorHotelFilter extends NavigatorFilter { List resultLists = new ArrayList<>(); int i = 0; - resultLists.add(new SearchResultList(i, "popular", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("popular", ListMode.fromType(Emulator.getConfig().getInt("hotel.navigator.popular.listtype"))), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("popular"), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("popular", habbo), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); + resultLists.add(new SearchResultList(i, "popular", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("popular", ListMode.fromType(Emulator.getConfig().getInt("hotel.navigator.popular.listtype"))), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("popular"), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("popular", habbo), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); i++; for (Map.Entry> set : Emulator.getGameEnvironment().getRoomManager().getPopularRoomsByCategory(Emulator.getConfig().getInt("hotel.navigator.popular.category.maxresults")).entrySet()) { if (!set.getValue().isEmpty()) { RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getKey()); if (category != null) { - resultLists.add(new SearchResultList(i, category.getCaption(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ORDER_NUM, category.getOrder())); + resultLists.add(new SearchResultList(i, category.getCaption(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ORDER_NUM, category.getOrder())); } i++; } @@ -42,7 +42,7 @@ public class NavigatorHotelFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) { boolean showInvisible = habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); - if (!filterField.databaseQuery.isEmpty()) { + if (!filterField.getDatabaseQuery().isEmpty()) { List resultLists = new ArrayList<>(); int i = 0; @@ -51,7 +51,7 @@ public class NavigatorHotelFilter extends NavigatorFilter { RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getKey()); if (category != null) { - resultLists.add(new SearchResultList(i, category.getCaptionSave(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ACTIVITY, category.getOrder())); + resultLists.add(new SearchResultList(i, category.getCaptionSave(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ACTIVITY, category.getOrder())); } i++; } 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 5c16598e..46a3f837 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -4,24 +4,21 @@ 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 lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +@Slf4j public class NavigatorManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(NavigatorManager.class); - + public static int MAXIMUM_RESULTS_PER_PAGE = 10; public static boolean CATEGORY_SORT_USING_ORDER_NUM = false; @@ -38,7 +35,7 @@ public class NavigatorManager { this.filters.put(NavigatorUserFilter.name, new NavigatorUserFilter()); this.filters.put(NavigatorFavoriteFilter.name, new NavigatorFavoriteFilter()); - LOGGER.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadNavigator() { @@ -51,7 +48,7 @@ public class NavigatorManager { this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) { @@ -64,12 +61,12 @@ public class NavigatorManager { if (room != null) { category.addRoom(room); } else { - LOGGER.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id")); + log.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id")); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -85,7 +82,7 @@ public class NavigatorManager { field = clazz.getDeclaredMethod(s); clazz = field.getReturnType(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } } @@ -93,7 +90,7 @@ public class NavigatorManager { try { field = clazz.getDeclaredMethod(set.getString("field")); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); continue; } } @@ -103,11 +100,11 @@ public class NavigatorManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } List staffPromotedRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsStaffPromoted(); @@ -119,8 +116,8 @@ public class NavigatorManager { public NavigatorFilterComparator comperatorForField(Method field) { for (Map.Entry set : this.filterSettings.entrySet()) { - if (set.getValue().field == field) { - return set.getValue().comparator; + if (set.getValue().getField() == field) { + return set.getValue().getComparator(); } } @@ -128,7 +125,7 @@ public class NavigatorManager { } public List getRoomsForCategory(String category, Habbo habbo) { - List rooms = new ArrayList<>(); + List rooms; switch (category) { case "my": diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java index 23d4de4d..02ae1c44 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java @@ -1,18 +1,20 @@ package com.eu.habbo.habbohotel.navigation; import com.eu.habbo.habbohotel.rooms.Room; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +@Getter public class NavigatorPublicCategory { - public final int id; - public final String name; - public final List rooms; - public final ListMode image; - public final int order; + private final int id; + private final String name; + private final List rooms; + private final ListMode image; + private final int order; public NavigatorPublicCategory(ResultSet set) throws SQLException { this.id = set.getInt("id"); 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 40ae72b1..9dbef5dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java @@ -20,12 +20,12 @@ public class NavigatorPublicFilter extends NavigatorFilter { List resultLists = new ArrayList<>(); int i = 0; - resultLists.add(new SearchResultList(i, "official-root", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("official-root", ListMode.THUMBNAILS), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("official-root"), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("official-root", habbo), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); + resultLists.add(new SearchResultList(i, "official-root", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("official-root", ListMode.THUMBNAILS), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("official-root"), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("official-root", habbo), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); i++; for (NavigatorPublicCategory category : Emulator.getGameEnvironment().getNavigatorManager().publicCategories.values()) { - if (!category.rooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "", category.name, SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.name, category.image), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.name), category.rooms, true, showInvisible, DisplayOrder.ORDER_NUM, category.order)); + if (!category.getRooms().isEmpty()) { + resultLists.add(new SearchResultList(i, "", category.getName(), SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory(category.getName(), category.getImage()), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory(category.getName()), category.getRooms(), true, showInvisible, DisplayOrder.ORDER_NUM, category.getOrder())); i++; } } 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 a27d3c69..d9e34c64 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java @@ -18,7 +18,7 @@ public class NavigatorRoomAdsFilter extends NavigatorFilter { public List getResult(Habbo habbo) { 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)); + resultList.add(new SearchResultList(0, "categories", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("categories", ListMode.LIST), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("official-root", DisplayMode.VISIBLE), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("categories", habbo), false, showInvisible, DisplayOrder.ACTIVITY, 0)); return resultList; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java index 8bcbc62c..c72df7f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java @@ -1,34 +1,19 @@ package com.eu.habbo.habbohotel.navigation; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@AllArgsConstructor public class NavigatorSavedSearch { - private String searchCode; - private String filter; + private final String searchCode; + private final String filter; + @Setter private int id; public NavigatorSavedSearch(String searchCode, String filter) { this.searchCode = searchCode; this.filter = filter; } - - public NavigatorSavedSearch(String searchCode, String filter, int id) { - this.searchCode = searchCode; - this.filter = filter; - this.id = id; - } - - public String getSearchCode() { - return searchCode; - } - - public String getFilter() { - return filter; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java index 38f70200..91a81b1d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class NavigatorUserFilter extends NavigatorFilter { @@ -21,36 +20,36 @@ public class NavigatorUserFilter extends NavigatorFilter { List resultLists = new ArrayList<>(); List rooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("my", habbo); - resultLists.add(new SearchResultList(i, "my", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my"), rooms, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "my", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("my"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("my"), rooms, true, true, DisplayOrder.ORDER_NUM, i)); i++; List favoriteRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("favorites", habbo); if (!favoriteRooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "favorites", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("favorites"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("favorites"), favoriteRooms, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "favorites", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("favorites"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("favorites"), favoriteRooms, true, true, DisplayOrder.ORDER_NUM, i)); i++; } List frequentlyVisited = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("history_freq", habbo); if (!frequentlyVisited.isEmpty()) { - resultLists.add(new SearchResultList(i, "history_freq", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("history_freq"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("history_freq"), frequentlyVisited, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "history_freq", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("history_freq"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("history_freq"), frequentlyVisited, true, true, DisplayOrder.ORDER_NUM, i)); i++; } List groupRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("my_groups", habbo); if (!groupRooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "my_groups", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my_groups"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my_groups"), groupRooms, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "my_groups", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("my_groups"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("my_groups"), groupRooms, true, true, DisplayOrder.ORDER_NUM, i)); i++; } List friendRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("with_friends", habbo); if (!friendRooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "with_friends", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_friends"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_friends"), friendRooms, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "with_friends", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("with_friends"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("with_friends"), friendRooms, true, true, DisplayOrder.ORDER_NUM, i)); i++; } List rightRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("with_rights", habbo); if (!rightRooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "with_rights", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_rights"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_rights"), rightRooms, true, true, DisplayOrder.ORDER_NUM, i)); + resultLists.add(new SearchResultList(i, "with_rights", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("with_rights"), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("with_rights"), rightRooms, true, true, DisplayOrder.ORDER_NUM, i)); } return resultLists; diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java index 00feccd7..0419d7c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java @@ -4,37 +4,27 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomState; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.ArrayList; import java.util.Collections; import java.util.List; +@Getter +@AllArgsConstructor public class SearchResultList implements ISerialize, Comparable { - public final int order; - public final String code; - public final String query; - public final SearchAction action; - public final ListMode mode; - public final DisplayMode hidden; - public final List rooms; - public final boolean filter; - public final boolean showInvisible; - public final DisplayOrder displayOrder; - public final int categoryOrder; - - public SearchResultList(int order, String code, String query, SearchAction action, ListMode mode, DisplayMode hidden, List rooms, boolean filter, boolean showInvisible, DisplayOrder displayOrder, int categoryOrder) { - this.order = order; - this.code = code; - this.query = query; - this.action = action; - this.mode = mode; - this.rooms = rooms; - this.hidden = hidden; - this.filter = filter; - this.showInvisible = showInvisible; - this.displayOrder = displayOrder; - this.categoryOrder = categoryOrder; - } + private final int order; + private final String code; + private final String query; + private final SearchAction action; + private final ListMode mode; + private final DisplayMode hidden; + private final List rooms; + private final boolean filter; + private final boolean showInvisible; + private final DisplayOrder displayOrder; + private final int categoryOrder; @Override public void serialize(ServerMessage message) { @@ -42,7 +32,7 @@ public class SearchResultList implements ISerialize, Comparable ALLOWED; + case "2" -> ROOM_OWNER; + default -> DISALLOWED; + }; } } 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 e815b4b1..060beed3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -6,17 +6,18 @@ 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 lombok.extern.slf4j.Slf4j; -import java.sql.*; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; import java.util.List; import java.util.Set; +@Slf4j public class PermissionsManager { - private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManager.class); - private final TIntObjectHashMap ranks; private final TIntIntHashMap enables; private final THashMap> badges; @@ -25,11 +26,11 @@ public class PermissionsManager { long millis = System.currentTimeMillis(); this.ranks = new TIntObjectHashMap<>(); this.enables = new TIntIntHashMap(); - this.badges = new THashMap>(); + this.badges = new THashMap<>(); this.reload(); - LOGGER.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void reload() { @@ -40,29 +41,27 @@ public class PermissionsManager { private void loadPermissions() { this.badges.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permissions ORDER BY id ASC")) { - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - Rank rank = null; - if (!this.ranks.containsKey(set.getInt("id"))) { - rank = new Rank(set); - this.ranks.put(set.getInt("id"), rank); - } else { - rank = this.ranks.get(set.getInt("id")); - rank.load(set); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permissions ORDER BY id ASC")) { + while (set.next()) { + Rank rank; + if (!this.ranks.containsKey(set.getInt("id"))) { + rank = new Rank(set); + this.ranks.put(set.getInt("id"), rank); + } else { + rank = this.ranks.get(set.getInt("id")); + rank.load(set); + } + + if (!rank.getBadge().isEmpty()) { + if (!this.badges.containsKey(rank.getBadge())) { + this.badges.put(rank.getBadge(), new ArrayList<>()); } - if (rank != null && !rank.getBadge().isEmpty()) { - if (!this.badges.containsKey(rank.getBadge())) { - this.badges.put(rank.getBadge(), new ArrayList()); - } - - this.badges.get(rank.getBadge()).add(rank); - } + this.badges.get(rank.getBadge()).add(rank); } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -75,7 +74,7 @@ public class PermissionsManager { this.enables.put(set.getInt("effect_id"), set.getInt("min_rank")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java index 20929cd7..44e4de52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.permissions; import gnu.trove.map.hash.THashMap; +import lombok.Getter; import java.sql.ResultSet; import java.sql.ResultSetMetaData; @@ -8,30 +9,44 @@ import java.sql.SQLException; public class Rank { + @Getter private final int id; + @Getter private final int level; + @Getter private final THashMap permissions; + @Getter private final THashMap variables; + @Getter private String name; + @Getter private String badge; + @Getter private int roomEffect; + @Getter private boolean logCommands; + @Getter private String prefix; + @Getter private String prefixColor; private boolean hasPrefix; + @Getter private int diamondsTimerAmount; + @Getter private int creditsTimerAmount; + @Getter private int pixelsTimerAmount; + @Getter private int gotwTimerAmount; public Rank(ResultSet set) throws SQLException { @@ -74,66 +89,16 @@ public class Rank { if (this.permissions.containsKey(key)) { Permission permission = this.permissions.get(key); - return permission.setting == PermissionSetting.ALLOWED || permission.setting == PermissionSetting.ROOM_OWNER && isRoomOwner; + return permission.getSetting() == PermissionSetting.ALLOWED || permission.getSetting() == PermissionSetting.ROOM_OWNER && isRoomOwner; } return false; } - - public int getId() { - return this.id; - } - - - public int getLevel() { - return this.level; - } - - - public String getName() { - return this.name; - } - - public String getBadge() { - return this.badge; - } - - public THashMap getPermissions() { - return this.permissions; - } - - public THashMap getVariables() { - return this.variables; - } - - public int getRoomEffect() { - return this.roomEffect; - } - - public boolean isLogCommands() { - return this.logCommands; - } - - public String getPrefix() { - return this.prefix; - } - - public String getPrefixColor() { - return this.prefixColor; - } - public boolean hasPrefix() { return this.hasPrefix; } - public int getDiamondsTimerAmount() { return this.diamondsTimerAmount; } - - public int getCreditsTimerAmount() { return this.creditsTimerAmount; } - - public int getPixelsTimerAmount() { return this.pixelsTimerAmount; } - - public int getGotwTimerAmount() { return this.gotwTimerAmount; } } 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 b488f968..699c63c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -4,17 +4,15 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class GnomePet extends Pet implements IPetLook { - private static final Logger LOGGER = LoggerFactory.getLogger(GnomePet.class); - private final String gnomeData; public GnomePet(ResultSet set) throws SQLException { @@ -51,7 +49,7 @@ public class GnomePet extends Pet implements IPetLook { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 666fa8d1..6283e74a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -1,17 +1,19 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter +@Setter public class HorsePet extends RideablePet { - private static final Logger LOGGER = LoggerFactory.getLogger(HorsePet.class); - private int hairColor; private int hairStyle; @@ -44,26 +46,11 @@ public class HorsePet extends RideablePet { statement.setInt(6, super.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } super.run(); } } - public int getHairColor() { - return this.hairColor; - } - - public void setHairColor(int hairColor) { - this.hairColor = hairColor; - } - - public int getHairStyle() { - return this.hairStyle; - } - - public void setHairStyle(int hairStyle) { - this.hairStyle = hairStyle; - } } 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 97b25c00..2732ecd7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -7,14 +7,13 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; -import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetRespectNotificationComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.math3.util.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -24,10 +23,10 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; +@Slf4j public class MonsterplantPet extends Pet implements IPetLook { - private static final Logger LOGGER = LoggerFactory.getLogger(MonsterplantPet.class); - public static final Map> bodyRarity = new LinkedHashMap>() { + public static final Map> bodyRarity = new LinkedHashMap<>() { { this.put(1, new Pair<>("Blungon", 0)); this.put(2, new Pair<>("Wailzor", 1)); @@ -43,7 +42,7 @@ public class MonsterplantPet extends Pet implements IPetLook { this.put(12, new Pair<>("Snozzle", 5)); //Rarity??? } }; - public static final Map> colorRarity = new LinkedHashMap>() { + public static final Map> colorRarity = new LinkedHashMap<>() { { this.put(0, new Pair<>("Aenueus", 0)); this.put(1, new Pair<>("Griseus", 1)); @@ -142,7 +141,7 @@ public class MonsterplantPet extends Pet implements IPetLook { statement.setInt(13, this.id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -385,7 +384,7 @@ public class MonsterplantPet extends Pet implements IPetLook { if (this.mayScratch()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5); this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive); - this.addHappyness(10); + this.addHappiness(10); this.addExperience(10); this.room.sendComposer(new PetStatusUpdateComposer(this).compose()); this.room.sendComposer(new PetRespectNotificationComposer(this, PetRespectNotificationComposer.PET_TREATED).compose()); 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 d681b810..c61d6c8f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -2,41 +2,35 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetExperienceComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetRespectNotificationComposer; -import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.ChatMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.plugin.events.pets.PetTalkEvent; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; -import java.util.*; +import java.util.Calendar; +import java.util.Map; +import java.util.TimeZone; -/** - * This class represents a virtual pet in a virtual world. It has fields representing the state of the - * pet, such as its name, type, level, hunger level, and thirst level. It also has methods for - * interacting with the virtual world, such as speaking, updating its status, and running tasks. - */ +@Slf4j public class Pet implements ISerialize, Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class); - /** - * The level of thirst of the pet. - */ + @Getter + @Setter public int levelThirst; - - /** - * The level of hunger of the pet. - */ + @Getter + @Setter public int levelHunger; /** @@ -48,75 +42,48 @@ public class Pet implements ISerialize, Runnable { * Whether the pet needs to be sent as a packet update. */ public boolean packetUpdate = false; - - /** - * The ID of the pet. - */ + @Getter protected int id; - - /** - * The ID of the user that owns the pet. - */ + @Getter + @Setter protected int userId; - - /** - * The room that the pet is in. - */ + @Getter + @Setter protected Room room; - - /** - * The name of the pet. - */ + @Getter + @Setter protected String name; - - /** - * The data for the type of pet. - */ + @Setter + @Getter protected PetData petData; - - /** - * The race of the pet. - */ + @Setter + @Getter protected int race; - - /** - * The color of the pet. - */ + @Getter + @Setter protected String color; - - /** - * The happyness level of the pet. - */ - protected int happyness; - - /** - * The experience points of the pet. - */ + @Getter + @Setter + protected int happiness; + @Getter + @Setter protected int experience; - - /** - * The energy level of the pet. - */ + @Setter + @Getter protected int energy; /** * The respect points of the pet. */ protected int respect; - - /** - * The timestamp of when the pet was created. - */ + @Getter + @Setter protected int created; - - /** - * The current level of the pet. - */ + @Getter + @Setter protected int level; - - /** - * The unit that represents the pet in a room. - */ + @Getter + @Setter RoomUnit roomUnit; /** @@ -128,15 +95,7 @@ public class Pet implements ISerialize, Runnable { * The tick timeout of the pet. */ private int tickTimeout = Emulator.getIntUnixTimestamp(); - - /** - * The happyness delay of the pet. - */ - private int happynessDelay = Emulator.getIntUnixTimestamp(); - - /** - * The gesture tick timeout of the pet. - */ + private int happinessDelay = Emulator.getIntUnixTimestamp(); private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); /** @@ -148,10 +107,8 @@ public class Pet implements ISerialize, Runnable { * The posture timeout of the pet. */ private int postureTimeout = Emulator.getIntUnixTimestamp(); - - /** - * The time when the pet started staying. - */ + @Getter + @Setter private int stayStartedAt = 0; /** * The number of ticks that the pet has spent idle while waiting for a command. @@ -163,14 +120,12 @@ public class Pet implements ISerialize, Runnable { */ private int freeCommandTicks = -1; - /** - * The current task of the pet. - */ + @Getter + @Setter private PetTasks task = PetTasks.FREE; - /** - * Whether the pet is muted. - */ + @Setter + @Getter private boolean muted = false; /** @@ -188,12 +143,12 @@ public class Pet implements ISerialize, Runnable { this.name = set.getString("name"); this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(set.getInt("type")); if (this.petData == null) { - LOGGER.error("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!"); + log.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"); this.experience = set.getInt("experience"); - this.happyness = set.getInt("happyness"); + this.happiness = set.getInt("happyness"); this.energy = set.getInt("energy"); this.respect = set.getInt("respect"); this.created = set.getInt("created"); @@ -220,13 +175,13 @@ public class Pet implements ISerialize, Runnable { this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(type); if (this.petData == null) { - LOGGER.warn("Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!"); + log.warn("Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!"); } this.race = race; this.color = color; this.experience = 0; - this.happyness = 100; + this.happiness = 100; this.energy = 100; this.respect = 0; this.levelThirst = 0; @@ -253,7 +208,7 @@ public class Pet implements ISerialize, Runnable { public void say(PetVocal vocal) { if (vocal != null) - this.say(vocal.message); + this.say(vocal.getMessage()); } @@ -270,19 +225,15 @@ public class Pet implements ISerialize, Runnable { this.energy = 0; } - /** - * Increases the happyness of the pet by the given amount. - * - * @param amount the amount to increase the happyness by - */ - public void addHappyness(int amount) { - this.happyness += amount; - if (this.happyness > 100) - this.happyness = 100; + public void addHappiness(int amount) { + this.happiness += amount; - if (this.happyness < 0) - this.happyness = 0; + if (this.happiness > 100) + this.happiness = 100; + + if (this.happiness < 0) + this.happiness = 0; } /** @@ -343,7 +294,7 @@ public class Pet implements ISerialize, Runnable { statement.setInt(8, this.roomUnit != null ? this.roomUnit.getBodyRotation().getValue() : 0); statement.setInt(9, this.levelHunger); statement.setInt(10, this.levelThirst); - statement.setInt(11, this.happyness); + statement.setInt(11, this.happiness); statement.setInt(12, this.created); statement.setInt(13, this.id); statement.execute(); @@ -371,7 +322,7 @@ public class Pet implements ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.needsUpdate = false; @@ -423,7 +374,7 @@ public class Pet implements ISerialize, Runnable { //this.addEnergy(5); - this.addHappyness(1); + this.addHappiness(1); if (this.energy == PetManager.maxEnergy(this.level)) { this.roomUnit.removeStatus(RoomUnitStatus.LAY); @@ -453,8 +404,7 @@ public class Pet implements ISerialize, Runnable { this.getRoomUnit().setCanWalk(true); } } else { - int timeout = Emulator.getRandom().nextInt(10) * 2; - this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time); + this.roomUnit.setWalkTimeOut(20 + time); if (this.energy >= 2) this.addEnergy(-1); @@ -466,9 +416,9 @@ public class Pet implements ISerialize, Runnable { if (this.levelThirst < 100) this.levelThirst++; - if (this.happyness > 0 && time - this.happynessDelay >= 30) { - this.happyness--; - this.happynessDelay = time; + if (this.happiness > 0 && time - this.happinessDelay >= 30) { + this.happiness--; + this.happinessDelay = time; } } @@ -485,9 +435,9 @@ public class Pet implements ISerialize, Runnable { this.say(this.petData.randomVocal(PetVocalsType.TIRED)); if (this.energy <= 10) this.findNest(); - } else if (this.happyness > 85) { + } else if (this.happiness > 85) { this.say(this.petData.randomVocal(PetVocalsType.GENERIC_HAPPY)); - } else if (this.happyness < 15) { + } else if (this.happiness < 15) { this.say(this.petData.randomVocal(PetVocalsType.GENERIC_SAD)); } else if (this.levelHunger > 50) { this.say(this.petData.randomVocal(PetVocalsType.HUNGRY)); @@ -534,25 +484,11 @@ public class Pet implements ISerialize, Runnable { if (this.task == null) return true; - switch (this.task) { - case DOWN: - case FLAT: - case HERE: - case SIT: - case BEG: - case PLAY: - case PLAY_FOOTBALL: - case PLAY_DEAD: - case FOLLOW: - case JUMP: - case STAND: - case NEST: - case RIDE: + return switch (this.task) { + case DOWN, FLAT, HERE, SIT, BEG, PLAY, PLAY_FOOTBALL, PLAY_DEAD, FOLLOW, JUMP, STAND, NEST, RIDE -> false; + default -> true; + }; - return false; - } - - return true; } /** @@ -597,12 +533,12 @@ public class Pet implements ISerialize, Runnable { if (this.energy < 30) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); this.findNest(); - } else if (this.happyness == 100) { + } else if (this.happiness == 100) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); - } else if (this.happyness >= 90) { + } else if (this.happiness >= 90) { this.randomHappyAction(); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); - } else if (this.happyness <= 5) { + } else if (this.happiness <= 5) { this.randomSadAction(); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); } else if (this.levelHunger > 80) { @@ -738,8 +674,8 @@ public class Pet implements ISerialize, Runnable { * Makes the pet perform a random happy action. */ public void randomHappyAction() { - if (this.petData.actionsHappy.length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), ""); + if (this.petData.getActionsHappy().length > 0) { + this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsHappy()[Emulator.getRandom().nextInt(this.petData.getActionsHappy().length)]), ""); } } @@ -747,8 +683,8 @@ public class Pet implements ISerialize, Runnable { * Makes the pet perform a random sad action. */ public void randomSadAction() { - if (this.petData.actionsTired.length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), ""); + if (this.petData.getActionsTired().length > 0) { + this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsTired()[Emulator.getRandom().nextInt(this.petData.getActionsTired().length)]), ""); } } @@ -756,8 +692,8 @@ public class Pet implements ISerialize, Runnable { * Makes the pet perform a random action. */ public void randomAction() { - if (this.petData.actionsRandom.length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), ""); + if (this.petData.getActionsRandom().length > 0) { + this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsRandom()[Emulator.getRandom().nextInt(this.petData.getActionsRandom().length)]), ""); } } @@ -791,7 +727,7 @@ public class Pet implements ISerialize, Runnable { } this.level++; this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); - this.addHappyness(100); + this.addHappiness(100); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); @@ -845,13 +781,13 @@ public class Pet implements ISerialize, Runnable { * @param habbo the habbo who scratched the pet */ public void scratched(Habbo habbo) { - this.addHappyness(10); + this.addHappiness(10); this.addExperience(10); this.addRespect(); this.needsUpdate = true; if (habbo != null) { - habbo.getHabboStats().petRespectPointsToGive--; + habbo.getHabboStats().decreasePetRespectPointsToGive(); habbo.getHabboInfo().getCurrentRoom().sendComposer(new PetRespectNotificationComposer(this).compose()); AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetRespectGiver")); @@ -860,298 +796,11 @@ public class Pet implements ISerialize, Runnable { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetRespectReceiver")); } - /** - * Gets the ID of the pet. - * - * @return the ID of the pet - */ - public int getId() { - return this.id; - } - /** - * Gets the ID of the user who owns the pet. - * - * @return the ID of the user who owns the pet - */ - public int getUserId() { - return this.userId; - } - - /** - * Sets the ID of the user who owns the pet. - * - * @param userId the ID of the user who owns the pet - */ - public void setUserId(int userId) { - this.userId = userId; - } - - /** - * Gets the room the pet is currently in. - * - * @return the room the pet is currently in - */ - public Room getRoom() { - return this.room; - } - - /** - * Sets the room the pet is currently in. - * - * @param room the room the pet is currently in - */ - public void setRoom(Room room) { - this.room = room; - } - - /** - * Gets the name of the pet. - * - * @return the name of the pet - */ - public String getName() { - return this.name; - } - - /** - * Sets the name of the pet. - * - * @param name the name of the pet - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the data for the pet's species. - * - * @return the data for the pet's species - */ - public PetData getPetData() { - return this.petData; - } - - /** - * Sets the data for the pet's species. - * - * @param petData the data for the pet's species - */ - public void setPetData(PetData petData) { - this.petData = petData; - } - - /** - * Gets the race of the pet. - * - * @return the race of the pet - */ - public int getRace() { - return this.race; - } - - /** - * Sets the race of the pet. - * - * @param race the race of the pet - */ - public void setRace(int race) { - this.race = race; - } - - /** - * Gets the color of the pet. - * - * @return the color of the pet - */ - public String getColor() { - return this.color; - } - - /** - * Sets the color of the pet. - * - * @param color the color of the pet - */ - public void setColor(String color) { - this.color = color; - } - /** - * Gets the happiness level of the pet. - * - * @return the happiness level of the pet - */ - public int getHappyness() { - return this.happyness; - } - - /** - * Sets the happiness level of the pet. - * - * @param happyness the happiness level of the pet - */ - public void setHappyness(int happyness) { - this.happyness = happyness; - } - - - /** - * Gets the experience points of the pet. - * - * @return the experience points of the pet - */ - public int getExperience() { - return this.experience; - } - - /** - * Sets the experience points of the pet. - * - * @param experience the experience points of the pet - */ - public void setExperience(int experience) { - this.experience = experience; - } - - /** - * Gets the energy level of the pet. - * @return the energy level of the pet - */ - public int getEnergy() { - return this.energy; - } - - /** - * Sets the energy of the pet. - * @param energy the new energy value for the pet - */ - public void setEnergy(int energy) { - this.energy = energy; - } - - /** - * Gets the maximum energy that the pet can have at its current level. - * @return the maximum energy that the pet can have at its current level - */ public int getMaxEnergy() { return this.level * 100; } - /** - * Gets the time that the pet was created. - * @return the time that the pet was created - */ - public int getCreated() { - return this.created; - } - - /** - * Sets the time that the pet was created. - * @param created the new time that the pet was created - */ - public void setCreated(int created) { - this.created = created; - } - - /** - * Gets the level of the pet. - * @return the level of the pet - */ - public int getLevel() { - return this.level; - } - - /** - * Sets the level of the pet. - * @param level the new level of the pet - */ - public void setLevel(int level) { - this.level = level; - } - - /** - * Gets the room unit object associated with this pet. - * @return the room unit object associated with this pet - */ - public RoomUnit getRoomUnit() { - return this.roomUnit; - } - - /** - * Sets the room unit object associated with this pet. - * @param roomUnit the new room unit object for this pet - */ - public void setRoomUnit(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } - - /** - * Gets the current task of this pet. - * @return the current task of this pet - */ - public PetTasks getTask() { - return this.task; - } - - /** - * Sets the current task of this pet. - * @param newTask the new task for this pet - */ - public void setTask(PetTasks newTask) { - this.task = newTask; - } - - /** - * Gets whether this pet is currently muted. - * @return true if this pet is muted, false otherwise - */ - public boolean isMuted() { - return this.muted; - } - - /** - * Sets whether this pet is currently muted. - * @param muted true if this pet should be muted, false otherwise - */ - public void setMuted(boolean muted) { - this.muted = muted; - } - - /** - * Gets the current thirst level of this pet. - * @return the current thirst level of this pet - */ - public int getLevelThirst() { - return this.levelThirst; - } - - /** - * Sets the current thirst level of this pet. - * @param levelThirst the new thirst level of this pet - */ - public void setLevelThirst(int levelThirst) { - this.levelThirst = levelThirst; - } - - /** - * Gets the current hunger level of this pet. - * @return the current hunger level of this pet - */ - public int getLevelHunger() { - return this.levelHunger; - } - - /** - * Sets the current hunger level of this pet. - * @param levelHunger the new hunger level of this pet - */ - public void setLevelHunger(int levelHunger) { - this.levelHunger = levelHunger; - } - - /** - * Removes this pet from the room. - */ public void removeFromRoom() { removeFromRoom(false); } @@ -1176,19 +825,4 @@ public class Pet implements ISerialize, Runnable { this.needsUpdate = true; } - /** - * Gets the time at which this pet started staying in the room. - * @return the time at which this pet started staying in the room - */ - public int getStayStartedAt() { - return stayStartedAt; - } - - /** - * Sets the time at which this pet started staying in the room. - * @param stayStartedAt the new time at which this pet started staying in the room - */ - public void setStayStartedAt(int stayStartedAt) { - this.stayStartedAt = stayStartedAt; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java index 82720c52..9e481c0d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java @@ -1,17 +1,16 @@ package com.eu.habbo.habbohotel.pets; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; - +@Getter public class PetBreedingReward { + private final int petType; - public final int petType; + private final int rarityLevel; - - public final int rarityLevel; - - - public final int breed; + private final int breed; public PetBreedingReward(ResultSet set) throws SQLException { this.petType = set.getInt("pet_type"); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index 153454e2..b96c360f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -4,35 +4,21 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; -/** - * A class representing a command that can be given to a pet. - */ +@Getter public class PetCommand implements Comparable { + private final int id; + private final String key; + private final int level; + private final int xp; + private final int energyCost; + private final int happinessCost; - /** The ID of the command. */ - public final int id; - - /** The key (name) of the command. */ - public final String key; - - /** The level required to use the command. */ - public final int level; - - /** The amount of XP rewarded for using the command. */ - public final int xp; - - /** The cost in energy to use the command. */ - public final int energyCost; - - /** The cost in happiness to use the command. */ - public final int happynessCost; - - /** The action associated with the command. */ - public final PetAction action; + private final PetAction action; /** * Creates a new PetCommand instance. @@ -46,7 +32,7 @@ public class PetCommand implements Comparable { this.level = set.getInt("required_level"); this.xp = set.getInt("reward_xp"); this.energyCost = set.getInt("cost_energy"); - this.happynessCost = set.getInt("cost_happyness"); + this.happinessCost = set.getInt("cost_happyness"); this.action = action; } @@ -70,7 +56,7 @@ public class PetCommand implements Comparable { */ public void handle(Pet pet, Habbo habbo, String[] data) { // check if enough energy, happiness, and randomize do or dont || should possibly add if not hungry and thirsty but @brenoepic does those - oliver - if (this.action != null && pet.energy > this.energyCost && pet.happyness > this.happynessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) { + if (this.action != null && pet.energy > this.energyCost && pet.happiness > this.happinessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) { if (this.action.petTask != pet.getTask()) { if (this.action.stopsPetWalking) { pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentLocation()); @@ -87,7 +73,7 @@ public class PetCommand implements Comparable { pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet); pet.getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); pet.addEnergy(-this.energyCost); - pet.addHappyness(-this.happynessCost); + pet.addHappiness(-this.happinessCost); pet.addExperience(this.xp); } } @@ -95,7 +81,7 @@ public class PetCommand implements Comparable { // this is disobey if (this.action.apply(pet, habbo, data)) { pet.addEnergy(-this.energyCost / 2); - pet.addHappyness(-this.happynessCost / 2); + pet.addHappiness(-this.happinessCost / 2); } pet.say(pet.petData.randomVocal(PetVocalsType.DISOBEY)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java index dabbf764..b9d621b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -2,10 +2,14 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,6 +17,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +@Getter public class PetData implements Comparable { public static final String BLINK = "eyb"; @@ -24,11 +29,11 @@ public class PetData implements Comparable { public static final List generalNestItems = new ArrayList<>(); public static final List generalToyItems = new ArrayList<>(); public static final THashMap> generalPetVocals = new THashMap<>(); - public String[] actionsHappy; - public String[] actionsTired; - public String[] actionsRandom; - public THashMap> petVocals; - public boolean canSwim; + private String[] actionsHappy; + private String[] actionsTired; + private String[] actionsRandom; + private THashMap> petVocals; + private boolean canSwim; private int type; private String name; private List petCommands; 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 592027bf..5619a116 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -13,24 +13,22 @@ import gnu.trove.map.TIntIntMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TIntObjectProcedure; import gnu.trove.set.hash.THashSet; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.math3.distribution.NormalDistribution; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; import java.util.Collection; import java.util.Map; +@Slf4j public class PetManager { public static int MAXIMUM_PET_INVENTORY_SIZE = 25; - private static final Logger LOGGER = LoggerFactory.getLogger(PetManager.class); public static final int[] experiences = new int[]{100, 200, 400, 600, 900, 1300, 1800, 2400, 3200, 4300, 5700, 7600, 10100, 13300, 17500, 23000, 30200, 39600, 51900}; static int[] skins = new int[]{0, 1, 6, 7}; - public final THashMap petActions = new THashMap() { + public final THashMap petActions = new THashMap<>() { { this.put(0, new ActionFree()); this.put(1, new ActionSit()); @@ -91,7 +89,7 @@ public class PetManager { reloadPetData(); - LOGGER.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static int getLevel(int experience) { @@ -162,8 +160,8 @@ public class PetManager { this.loadPetCommands(connection); this.loadPetBreeding(connection); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - LOGGER.error("Pet Manager -> Failed to load!"); + log.error("Caught SQL exception", e); + log.error("Pet Manager -> Failed to load!"); } } @@ -178,7 +176,7 @@ public class PetManager { this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -188,7 +186,7 @@ public class PetManager { this.petData.put(set.getInt("pet_type"), new PetData(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.loadPetItems(connection); @@ -228,7 +226,7 @@ public class PetManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -239,13 +237,9 @@ public class PetManager { if (this.petData.containsKey(set.getInt("pet_id"))) { PetVocalsType petVocalsType = EnumUtils.getEnum(PetVocalsType.class, set.getString("type").toUpperCase());; - if (petVocalsType != null) { - this.petData.get(set.getInt("pet_id")).petVocals.get(petVocalsType).add(new PetVocal(set.getString("message"))); - } else { - LOGGER.error("Unknown pet vocal type " + set.getString("type")); - } + this.petData.get(set.getInt("pet_id")).getPetVocals().get(petVocalsType).add(new PetVocal(set.getString("message"))); } else { - LOGGER.error("Missing pet_actions table entry for pet id " + set.getInt("pet_id")); + log.error("Missing pet_actions table entry for pet id " + set.getInt("pet_id")); } } else { if (!PetData.generalPetVocals.containsKey(PetVocalsType.valueOf(set.getString("type").toUpperCase()))) @@ -255,7 +249,7 @@ public class PetManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -266,7 +260,7 @@ public class PetManager { commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) { @@ -278,7 +272,7 @@ public class PetManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -288,30 +282,30 @@ public class PetManager { this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) { while (set.next()) { PetBreedingReward reward = new PetBreedingReward(set); - if (!this.breedingReward.containsKey(reward.petType)) { - this.breedingReward.put(reward.petType, new TIntObjectHashMap<>()); + if (!this.breedingReward.containsKey(reward.getPetType())) { + this.breedingReward.put(reward.getPetType(), new TIntObjectHashMap<>()); } - if (!this.breedingReward.get(reward.petType).containsKey(reward.rarityLevel)) { - this.breedingReward.get(reward.petType).put(reward.rarityLevel, new ArrayList<>()); + if (!this.breedingReward.get(reward.getPetType()).containsKey(reward.getRarityLevel())) { + this.breedingReward.get(reward.getPetType()).put(reward.getRarityLevel(), new ArrayList<>()); } - this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); + this.breedingReward.get(reward.getPetType()).get(reward.getRarityLevel()).add(reward); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public THashSet getBreeds(String petName) { if (!petName.startsWith("a0 pet")) { - LOGGER.error("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!"); + log.error("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!"); return null; } @@ -319,7 +313,7 @@ public class PetManager { int petId = Integer.parseInt(petName.split("t")[1]); return this.petRaces.get(petId); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; @@ -336,7 +330,7 @@ public class PetManager { offspringList.forEachEntry((i, petBreedingRewards) -> { for (PetBreedingReward reward : petBreedingRewards) { - if (reward.breed == pet.getRace()) { + if (reward.getBreed() == pet.getRace()) { rarityLevel[0] = i; return false; } @@ -354,7 +348,7 @@ public class PetManager { return this.petData.get(type); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - LOGGER.error("Missing petdata for type " + type + ". Adding this to the database..."); + log.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(); @@ -366,13 +360,13 @@ public class PetManager { if (set.next()) { PetData petData = new PetData(set); this.petData.put(type, petData); - LOGGER.error("Missing petdata for type " + type + " added to the database!"); + log.error("Missing petdata for type " + type + " added to the database!"); return petData; } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -506,10 +500,6 @@ public class PetManager { return color; } - private int randomLeprechaunColor() { - return Emulator.getRandom().nextInt(2) == 1 ? 19 : 27; - } - private int randomGnomeSkinColor() { return skins[Emulator.getRandom().nextInt(skins.length)]; } @@ -519,7 +509,7 @@ public class PetManager { statement.setInt(1, pet.getId()); return statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java index c02d6a41..65484370 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java @@ -1,23 +1,19 @@ package com.eu.habbo.habbohotel.pets; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter public class PetRace { - - public final int race; - - - public final int colorOne; - - - public final int colorTwo; - - - public final boolean hasColorOne; - - - public final boolean hasColorTwo; + private final int race; + private final int colorOne; + private final int colorTwo; + private final boolean hasColorOne; + private final boolean hasColorTwo; public PetRace(ResultSet set) throws SQLException { this.race = set.getInt("race"); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java index bdba8b2b..7160a029 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.pets; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum PetTasks { NONE(""), FREE(""), @@ -52,11 +57,4 @@ public enum PetTasks { private final String status; - PetTasks(String status) { - this.status = status; - } - - public String getStatus() { - return this.status; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java index 30cd7f91..2acf89b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java @@ -1,9 +1,10 @@ package com.eu.habbo.habbohotel.pets; -public class PetVocal { - public final String message; +import lombok.AllArgsConstructor; +import lombok.Getter; - public PetVocal(String message) { - this.message = message; - } +@Getter +@AllArgsConstructor +public class PetVocal { + private final String message; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java index afdb4b39..fb26f720 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java @@ -1,15 +1,22 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.habbohotel.users.Habbo; +import lombok.Getter; +import lombok.Setter; import java.sql.ResultSet; import java.sql.SQLException; public class RideablePet extends Pet { + @Setter + @Getter private Habbo rider; private boolean hasSaddle; + @Setter private boolean anyoneCanRide; + @Setter + @Getter private int saddleItemId; public RideablePet(ResultSet set) throws SQLException { @@ -34,23 +41,4 @@ public class RideablePet extends Pet { return this.anyoneCanRide; } - public void setAnyoneCanRide(boolean anyoneCanRide) { - this.anyoneCanRide = anyoneCanRide; - } - - public Habbo getRider() { - return this.rider; - } - - public void setRider(Habbo rider) { - this.rider = rider; - } - - public int getSaddleItemId() { - return saddleItemId; - } - - public void setSaddleItemId(int saddleItemId) { - this.saddleItemId = saddleItemId; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBeg.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBeg.java index 10788778..b51a7b79 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBeg.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBeg.java @@ -17,7 +17,7 @@ public class ActionBeg extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - if (pet.getHappyness() > 60) { + if (pet.getHappiness() > 60) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java index ad32e6f0..8db538dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java @@ -20,7 +20,7 @@ public class ActionBounce extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.BOUNCE, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 80) { + if (pet.getHappiness() > 80) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreatheFire.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreatheFire.java index 3af202c9..d9ceb8e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreatheFire.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreatheFire.java @@ -19,7 +19,7 @@ public class ActionBreatheFire extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.FLAME, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 80) { + if (pet.getHappiness() > 80){ pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index 80953c52..e9d54c8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java @@ -21,9 +21,9 @@ public class ActionCroak extends PetAction { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 70) + if (pet.getHappiness() > 70) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); - else if (pet.getHappyness() < 30) + else if (pet.getHappiness() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD)); else if (pet.getLevelHunger() > 65) pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java index aab6fef3..68af564b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java @@ -19,7 +19,7 @@ public class ActionDance extends PetAction { // mambojambo works better than ur dancing skills @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() > 55) { + if (pet.getHappiness() > 55) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java index 4628ef55..9e86ee9a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java @@ -26,7 +26,7 @@ public class ActionDip extends PetAction { pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getX(), waterPatch.getY())); - if (pet.getHappyness() > 70) { + if (pet.getHappiness() > 70) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java index 7f21197e..281fd5ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java @@ -28,7 +28,7 @@ public class ActionDown extends PetAction { pet.clearPosture(); }, this.minimumActionDuration); - if (pet.getHappyness() > 40) { + if (pet.getHappiness() > 40) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java index 4790023e..76fb93dd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java @@ -22,7 +22,7 @@ public class ActionFlat extends PetAction { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.FLAT, null, false), this.minimumActionDuration); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); - if (pet.getHappyness() > 80) { + if (pet.getHappiness() > 80) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java index 1f8cc158..b0308a2e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java @@ -20,7 +20,7 @@ public class ActionFollow extends PetAction { pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, 0)); - if (pet.getHappyness() > 65) { + if (pet.getHappiness() > 65) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java index 31beb14a..dd5ec560 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java @@ -19,7 +19,7 @@ public class ActionFollowLeft extends PetAction { pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, -2)); - if (pet.getHappyness() > 75) + if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java index 3e51d877..66411c73 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java @@ -19,7 +19,7 @@ public class ActionFollowRight extends PetAction { pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, +2)); - if (pet.getHappyness() > 75) + if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java index 686fbe53..da0b5948 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java @@ -19,7 +19,7 @@ public class ActionHere extends PetAction { pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); - if (pet.getHappyness() > 50) { + if (pet.getHappiness() > 50) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java index 3d2a1b49..d0a156c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java @@ -2,14 +2,12 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTrampoline; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.PetClearPosture; public class ActionJump extends PetAction { @@ -26,7 +24,7 @@ public class ActionJump extends PetAction { pet.setTask(PetTasks.JUMP); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 60) + if (pet.getHappiness() > 60) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java index 56bce13e..e62ef857 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java @@ -20,7 +20,7 @@ public class ActionPlayDead extends PetAction { pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - if (pet.getHappyness() > 50) + if (pet.getHappiness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java index 3f11cdc1..f5f12c94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java @@ -34,7 +34,7 @@ public class ActionPlayFootball extends PetAction { pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getX(), foundBall.getY())); - if (pet.getHappyness() > 75) + if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java index 7b2e5560..25b70b38 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java @@ -14,9 +14,9 @@ public class ActionRelax extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { //Relax - if (pet.getHappyness() > 75) + if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); - else if (pet.getHappyness() < 30) + else if (pet.getHappiness() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index 6a67bf68..6923d643 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -29,7 +29,7 @@ public class ActionSit extends PetAction { pet.clearPosture(); }, this.minimumActionDuration); - if (pet.getHappyness() > 75) + if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java index be7eaeae..ed3207b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java @@ -21,9 +21,9 @@ public class ActionSpeak extends PetAction { pet.setMuted(false); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.SPEAK, null, false), 2000); - if (pet.getHappyness() > 70) + if (pet.getHappiness() > 70) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); - else if (pet.getHappyness() < 30) + else if (pet.getHappiness() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD)); else if (pet.getLevelHunger() > 65) pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java index 46dc42e2..73f10c4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java @@ -20,7 +20,7 @@ public class ActionSpin extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() > 50) { + if (pet.getHappiness() > 50) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.SPIN, null, false), this.minimumActionDuration); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStand.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStand.java index 598c66dc..309b2a9c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStand.java @@ -20,7 +20,7 @@ public class ActionStand extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - if (pet.getHappyness() > 30) + if (pet.getHappiness() > 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java index 8918e649..c0c9d441 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; -import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java index a1df91ff..56a68a7a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java @@ -23,7 +23,7 @@ public class ActionWagTail extends PetAction { pet.clearPosture(); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 50) { + if (pet.getHappiness() > 50) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java index 2818f70e..2675d8b6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; -import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; @@ -22,7 +22,7 @@ public class ActionWave extends PetAction { pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 40) { + if (pet.getHappiness() > 40) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWings.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWings.java index 5c49080b..dc5911ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWings.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWings.java @@ -19,7 +19,7 @@ public class ActionWings extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WINGS, null, false), this.minimumActionDuration); - if (pet.getHappyness() > 60) { + if (pet.getHappiness() > 60) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java b/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java index 8e7927dc..fc1dff48 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java @@ -1,24 +1,22 @@ package com.eu.habbo.habbohotel.polls; +import lombok.Getter; +import lombok.Setter; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; +@Getter public class Poll { - public final int id; - - - public final String title; - - - public final String thanksMessage; - - - public final String badgeReward; - - public int lastQuestionId; + private final int id; + private final String title; + private final String thanksMessage; + private final String badgeReward; + @Setter + private int lastQuestionId; private ArrayList questions; @@ -36,7 +34,7 @@ public class Poll { public PollQuestion getQuestion(int id) { for (PollQuestion q : this.questions) { - if (q.id == id) { + if (q.getId() == id) { return q; } } 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 8e2d78a5..065b7fd4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java @@ -3,13 +3,12 @@ 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 lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j public class PollManager { - private static final Logger LOGGER = LoggerFactory.getLogger(PollManager.class); private final THashMap activePolls = new THashMap<>(); @@ -27,7 +26,7 @@ public class PollManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; } @@ -61,13 +60,13 @@ public class PollManager { } } - poll.lastQuestionId = question.id; + poll.setLastQuestionId(question.getId()); } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java b/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java index b1c159e6..04b42f6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.polls; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import gnu.trove.map.hash.THashMap; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,29 +11,17 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Map; +@Getter public class PollQuestion implements ISerialize, Comparable { - public final int id; - - - public final int parentId; - - - public final int type; - - - public final String question; - - - public final THashMap options; - - - public final int minSelections; - - - public final int order; - - private ArrayList subQuestions; + private final int id; + private final int parentId; + private final int type; + private final String question; + private final THashMap options; + private final int minSelections; + private final int order; + private final ArrayList subQuestions; public PollQuestion(ResultSet set) throws SQLException { this.id = set.getInt("id"); 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 3ca0650f..351269ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -1,16 +1,15 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class CustomRoomLayout extends RoomLayout implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(CustomRoomLayout.class); private final int roomId; private boolean needsUpdate; @@ -34,7 +33,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable { statement.setInt(5, this.roomId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.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 9c1ddb76..8752b67c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum FurnitureMovementError { NONE(""), NO_RIGHTS("${room.error.cant_set_not_owner}"), @@ -17,9 +22,6 @@ public enum FurnitureMovementError { MAX_STICKIES("${room.error.max_stickies}"); - public final String errorCode; + private final String errorCode; - FurnitureMovementError(String errorCode) { - this.errorCode = errorCode; - } } \ No newline at end of file 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 a5b2f6ac..909dec72 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -62,13 +62,12 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TIntObjectProcedure; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import io.netty.util.internal.ConcurrentSet; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.math3.util.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -83,24 +82,11 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import java.util.stream.Collectors; +@Slf4j public class Room implements Comparable, ISerialize, Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(Room.class); - - public static final Comparator SORT_SCORE = (o1, o2) -> { - - if (!(o1 instanceof Room && o2 instanceof Room)) - return 0; - - return ((Room) o2).getScore() - ((Room) o1).getScore(); - }; - public static final Comparator SORT_ID = (o1, o2) -> { - - if (!(o1 instanceof Room && o2 instanceof Room)) - return 0; - - return ((Room) o2).getId() - ((Room) o1).getId(); - }; + public static final Comparator SORT_SCORE = (o1, o2) -> o2.getScore() - o1.getScore(); + public static final Comparator SORT_ID = (o1, o2) -> o2.getId() - o1.getId(); private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>(); //Configuration. Loaded from database & updated accordingly. public static boolean HABBO_CHAT_DELAY = false; @@ -127,18 +113,28 @@ public class Room implements Comparable, ISerialize, Runnable { public final Object roomUnitLock = new Object(); public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); public final List userVotes; + @Getter private final ConcurrentHashMap currentHabbos = new ConcurrentHashMap<>(3); + @Getter private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + @Getter private final TIntObjectMap currentBots = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + @Getter private final TIntObjectMap currentPets = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); private final THashSet activeTrades; + @Getter private final TIntArrayList rights; private final TIntIntHashMap mutedHabbos; private final TIntObjectHashMap bannedHabbos; + @Getter private final ConcurrentSet games; + @Getter private final TIntObjectMap furniOwnerNames; + @Getter private final TIntIntMap furniOwnerCount; + @Getter private final TIntObjectMap moodlightData; + @Getter private final THashSet wordFilterWords; private final TIntObjectMap roomItems; private final Object loadLock = new Object(); @@ -152,63 +148,144 @@ public class Room implements Comparable, ISerialize, Runnable { public int yesVotes = 0; public int wordQuizEnd = 0; public ScheduledFuture roomCycleTask; - private int id; + @Getter + private final int id; + @Getter + @Setter private int ownerId; + @Getter + @Setter private String ownerName; + @Getter private String name; + @Getter private String description; + @Getter + @Setter private RoomLayout layout; private boolean overrideModel; - private String layoutName; + private final String layoutName; + @Getter private String password; + @Getter + @Setter private RoomState state; + @Setter + @Getter private int usersMax; + @Getter + @Setter private volatile int score; + @Getter + @Setter private volatile int category; + @Getter + @Setter private String floorPaint; + @Getter + @Setter private String wallPaint; + @Getter + @Setter private String backgroundPaint; + @Getter + @Setter private int wallSize; + @Getter + @Setter private int wallHeight; + @Getter + @Setter private int floorSize; - private int guild; + @Setter + @Getter + private int guildId; + @Getter + @Setter private String tags; + @Setter + @Getter private volatile boolean publicRoom; + @Setter + @Getter private volatile boolean staffPromotedRoom; + @Getter private volatile boolean allowPets; + @Setter + @Getter private volatile boolean allowPetsEat; + @Setter + @Getter private volatile boolean allowWalkthrough; + @Setter + @Getter private volatile boolean allowBotsWalk; + @Setter + @Getter private volatile boolean allowEffects; + @Setter + @Getter private volatile boolean hideWall; + @Setter + @Getter private volatile int chatMode; + @Setter + @Getter private volatile int chatWeight; + @Setter + @Getter private volatile int chatSpeed; + @Setter + @Getter private volatile int chatDistance; + @Setter + @Getter private volatile int chatProtection; + @Setter + @Getter private volatile int muteOption; + @Setter + @Getter private volatile int kickOption; + @Setter + @Getter private volatile int banOption; + @Setter + @Getter private volatile int pollId; private volatile boolean promoted; + @Getter + @Setter private volatile int tradeMode; private volatile boolean moveDiagonally; private volatile boolean jukeboxActive; private volatile boolean hideWired; + @Getter private RoomPromotion promotion; + @Setter private volatile boolean needsUpdate; + @Getter private volatile boolean loaded; + @Getter private volatile boolean preLoaded; private int idleCycles; private volatile int unitCounter; + @Getter private volatile int rollerSpeed; private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); private long rollerCycle = System.currentTimeMillis(); + @Setter + @Getter private volatile int lastTimerReset = Emulator.getIntUnixTimestamp(); + @Setter + @Getter private volatile boolean muted; + @Getter private RoomSpecialTypes roomSpecialTypes; + @Getter private TraxManager traxManager; private boolean cycleOdd; + @Getter private long cycleTimestamp; public Room(ResultSet set) throws SQLException { @@ -244,7 +321,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.kickOption = set.getInt("who_can_kick"); this.banOption = set.getInt("who_can_ban"); this.pollId = set.getInt("poll_id"); - this.guild = set.getInt("guild_id"); + this.guildId = set.getInt("guild_id"); this.rollerSpeed = set.getInt("roller_speed"); this.overrideModel = set.getString("override_model").equals("1"); this.layoutName = set.getString("model"); @@ -270,7 +347,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBans(connection); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.tradeMode = set.getInt("trade_mode"); @@ -318,49 +395,49 @@ public class Room implements Comparable, ISerialize, Runnable { try { this.loadLayout(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadRights(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadItems(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadHeightmap(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadBots(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadPets(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadWordFilter(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.loadWiredData(connection); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.idleCycles = 0; @@ -368,7 +445,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.traxManager = new TraxManager(this); @@ -411,7 +488,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } else { - LOGGER.error("Unknown Room Layout for Room (ID: {})", this.id); + log.error("Unknown Room Layout for Room (ID: {})", this.id); } } @@ -426,11 +503,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } if (this.itemCount() > Room.MAXIMUM_FURNI) { - LOGGER.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); + log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); } } @@ -447,14 +524,14 @@ public class Room implements Comparable, ISerialize, Runnable { ((InteractionWired) item).loadWiredData(set, this); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -472,7 +549,7 @@ public class Room implements Comparable, ISerialize, Runnable { b.setRoomUnit(new RoomUnit()); b.getRoomUnit().setPathFinderRoom(this); b.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().state == RoomTileState.INVALID) { + if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { b.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); b.getRoomUnit().setLocation(this.getLayout().getDoorTile()); b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); @@ -491,7 +568,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -508,7 +585,7 @@ public class Room implements Comparable, ISerialize, Runnable { pet.setRoomUnit(new RoomUnit()); pet.getRoomUnit().setPathFinderRoom(this); pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().state == RoomTileState.INVALID) { + if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { pet.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); @@ -522,12 +599,12 @@ public class Room implements Comparable, ISerialize, Runnable { this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -542,13 +619,13 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public void updateTile(RoomTile tile) { if (tile != null) { - tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false)); + tile.setStackHeight(this.getStackHeight(tile.getX(), tile.getY(), false)); tile.setState(this.calculateTileState(tile)); } } @@ -556,7 +633,7 @@ public class Room implements Comparable, ISerialize, Runnable { public void updateTiles(THashSet tiles) { for (RoomTile tile : tiles) { this.tileCache.remove(tile); - tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false)); + tile.setStackHeight(this.getStackHeight(tile.getX(), tile.getY(), false)); tile.setState(this.calculateTileState(tile)); } @@ -568,7 +645,7 @@ public class Room implements Comparable, ISerialize, Runnable { } private RoomTileState calculateTileState(RoomTile tile, HabboItem exclude) { - if (tile == null || tile.state == RoomTileState.INVALID) + if (tile == null || tile.getState() == RoomTileState.INVALID) return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; @@ -642,7 +719,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean tileWalkable(RoomTile t) { - return this.tileWalkable(t.x, t.y); + return this.tileWalkable(t.getX(), t.getY()); } public boolean tileWalkable(short x, short y) { @@ -695,8 +772,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new HeightMapUpdateMessageComposer(this, updatedTiles).compose()); this.updateTiles(updatedTiles); for (RoomTile tile : updatedTiles) { - this.updateHabbosAt(tile.x, tile.y); - this.updateBotsAt(tile.x, tile.y); + this.updateHabbosAt(tile.getX(), tile.getY()); + this.updateBotsAt(tile.getX(), tile.getY()); } } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new ItemRemoveMessageComposer(item).compose()); @@ -742,7 +819,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.scheduledTasks.add(() -> { try { item.onWalkOn(roomUnit, Room.this, null); - } catch (Exception e) { + } catch (Exception ignored) { } }); @@ -759,7 +836,6 @@ public class Room implements Comparable, ISerialize, Runnable { public void updateHabbosAt(short x, short y, THashSet habbos) { HabboItem item = this.getTopItemAt(x, y); - THashSet roomUnits = new THashSet<>(); for (Habbo habbo : habbos) { double oldZ = habbo.getRoomUnit().getZ(); @@ -958,7 +1034,7 @@ public class Room implements Comparable, ISerialize, Runnable { botIterator.value().needsUpdate(true); Emulator.getThreading().run(botIterator.value()); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } } @@ -966,7 +1042,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.currentBots.clear(); this.currentPets.clear(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -978,7 +1054,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.preLoaded = true; this.layout = null; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -1061,15 +1137,13 @@ public class Room implements Comparable, ISerialize, Runnable { @Override public void run() { - long millis = System.currentTimeMillis(); - synchronized (this.loadLock) { if (this.loaded) { try { Emulator.getThreading().run( Room.this::cycle); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -1098,7 +1172,7 @@ public class Room implements Comparable, ISerialize, Runnable { int id = 1; for (RoomMoodlightData data : this.moodlightData.valueCollection()) { data.setId(id); - moodLightData.append(data.toString()).append(";"); + moodLightData.append(data).append(";"); id++; } @@ -1117,7 +1191,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(26, this.kickOption); statement.setInt(27, this.banOption); statement.setInt(28, this.pollId); - statement.setInt(29, this.guild); + statement.setInt(29, this.guildId); statement.setInt(30, this.rollerSpeed); statement.setString(31, this.overrideModel ? "1" : "0"); statement.setString(32, this.staffPromotedRoom ? "1" : "0"); @@ -1132,7 +1206,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.executeUpdate(); this.needsUpdate = false; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -1143,7 +1217,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -1187,7 +1261,7 @@ public class Room implements Comparable, ISerialize, Runnable { foundRightHolder[0] = habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE; } - if (habbo.getRoomUnit().getHandItem() > 0 && millis - habbo.getRoomUnit().getHandItemTimestamp() > (Room.HAND_ITEM_TIME * 1000)) { + if (habbo.getRoomUnit().getHandItem() > 0 && millis - habbo.getRoomUnit().getHandItemTimestamp() > (Room.HAND_ITEM_TIME * 1000L)) { this.giveHandItem(habbo, 0); } @@ -1242,17 +1316,17 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) { - habbo.getHabboStats().mutedBubbleTracker = false; + if (habbo.getHabboStats().isMutedBubbleTracker() && habbo.getHabboStats().allowTalk()) { + habbo.getHabboStats().setMutedBubbleTracker(false); this.sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.UNIGNORED).compose()); } // 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.cycleOdd && habbo.getHabboStats().getChatCounter().get() > 0) { + habbo.getHabboStats().getChatCounter().decrementAndGet(); } - if (this.cycleRoomUnit(habbo.getRoomUnit(), RoomUnitType.USER)) { + if (this.cycleRoomUnit(habbo.getRoomUnit())) { updatedUnit.add(habbo.getRoomUnit()); } } @@ -1284,13 +1358,13 @@ public class Room implements Comparable, ISerialize, Runnable { botIterator.value().cycle(this.allowBotsWalk); - if (this.cycleRoomUnit(bot.getRoomUnit(), RoomUnitType.BOT)) { + if (this.cycleRoomUnit(bot.getRoomUnit())) { updatedUnit.add(bot.getRoomUnit()); } } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } } @@ -1303,12 +1377,12 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } Pet pet = petIterator.value(); - if (this.cycleRoomUnit(pet.getRoomUnit(), RoomUnitType.PET)) { + if (this.cycleRoomUnit(pet.getRoomUnit())) { updatedUnit.add(pet.getRoomUnit()); } @@ -1366,13 +1440,13 @@ public class Room implements Comparable, ISerialize, Runnable { if (tileInFront == null) return true; - if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y)) + if (!Room.this.layout.tileExists(tileInFront.getX(), tileInFront.getY())) return true; - if (tileInFront.state == RoomTileState.INVALID) + if (tileInFront.getState() == RoomTileState.INVALID) return true; - if (!tileInFront.getAllowStack() && !(tileInFront.isWalkable() || tileInFront.state == RoomTileState.SIT || tileInFront.state == RoomTileState.LAY)) + if (!tileInFront.getAllowStack() && !(tileInFront.isWalkable() || tileInFront.getState() == RoomTileState.SIT || tileInFront.getState() == RoomTileState.LAY)) return true; if (tileInFront.hasUnits()) @@ -1382,14 +1456,9 @@ public class Room implements Comparable, ISerialize, Runnable { itemsNewTile.addAll(getItemsAt(tileInFront)); itemsNewTile.removeAll(itemsOnRoller); - List toRemove = new ArrayList<>(); - for (HabboItem item : itemsOnRoller) { - if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())) { - toRemove.add(item); - } - } - itemsOnRoller.removeAll(toRemove); - HabboItem topItem = Room.this.getTopItemAt(tileInFront.x, tileInFront.y); + itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); + + HabboItem topItem = Room.this.getTopItemAt(tileInFront.getX(), tileInFront.getY()); boolean allowUsers = true; boolean allowFurniture = true; @@ -1425,7 +1494,7 @@ public class Room implements Comparable, ISerialize, Runnable { return true; } } else { - zOffset = -Item.getCurrentHeight(roller) + tileInFront.getStackHeight() - rollerTile.z; + zOffset = -Item.getCurrentHeight(roller) + tileInFront.getStackHeight() - rollerTile.getZ(); } if (allowUsers) { @@ -1446,8 +1515,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - HabboItem nextTileChair = this.getTallestChair(tileInFront); - THashSet usersRolledThisTile = new THashSet<>(); for (RoomUnit unit : unitsOnTile) { @@ -1495,7 +1562,7 @@ public class Room implements Comparable, ISerialize, Runnable { messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, newZ + (isRiding ? 1 : 0), room)); if (itemsOnRoller.isEmpty()) { - HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y); + HabboItem item = room.getTopItemAt(tileInFront.getX(), tileInFront.getY()); if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) { Emulator.getThreading().run(() -> { @@ -1503,7 +1570,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOn(unit, room, new Object[]{rollerTile, tileInFront}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); @@ -1594,17 +1661,14 @@ public class Room implements Comparable, ISerialize, Runnable { synchronized (this.habboQueue) { if (!this.habboQueue.isEmpty() && !foundRightHolder[0]) { - this.habboQueue.forEachEntry(new TIntObjectProcedure() { - @Override - public boolean execute(int a, Habbo b) { - if (b.isOnline()) { - if (b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { - b.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); - } + this.habboQueue.forEachEntry((a, b) -> { + if (b.isOnline()) { + if (b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { + b.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); } - - return true; } + + return true; }); this.habboQueue.clear(); @@ -1621,7 +1685,7 @@ public class Room implements Comparable, ISerialize, Runnable { } - private boolean cycleRoomUnit(RoomUnit unit, RoomUnitType type) { + private boolean cycleRoomUnit(RoomUnit unit) { boolean update = unit.needsStatusUpdate(); if (unit.hasStatus(RoomUnitStatus.SIGN)) { this.sendComposer(new UserUpdateComposer(unit).compose()); @@ -1648,10 +1712,10 @@ public class Room implements Comparable, ISerialize, Runnable { unit.removeStatus(RoomUnitStatus.SIT); update = true; } - } else if (thisTile.state == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate)) { + } else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate)) { this.dance(unit, DanceType.NONE); //int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z; - unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + ""); + unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + ""); unit.setZ(topItem.getZ()); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); unit.sitUpdate = false; @@ -1670,7 +1734,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { - unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) * 1.0D + ""); + unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) + ""); unit.setRotation(RoomUserRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { @@ -1692,30 +1756,6 @@ public class Room implements Comparable, ISerialize, Runnable { return update; } - public int getId() { - return this.id; - } - - public int getOwnerId() { - return this.ownerId; - } - - public void setOwnerId(int ownerId) { - this.ownerId = ownerId; - } - - public String getOwnerName() { - return this.ownerName; - } - - public void setOwnerName(String ownerName) { - this.ownerName = ownerName; - } - - public String getName() { - return this.name; - } - public void setName(String name) { this.name = name; @@ -1724,7 +1764,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); if (guild != null) { guild.setRoomName(name); @@ -1732,10 +1772,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public String getDescription() { - return this.description; - } - public void setDescription(String description) { this.description = description; @@ -1744,14 +1780,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public RoomLayout getLayout() { - return this.layout; - } - - public void setLayout(RoomLayout layout) { - this.layout = layout; - } - public boolean hasCustomLayout() { return this.overrideModel; } @@ -1760,10 +1788,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.overrideModel = overrideModel; } - public String getPassword() { - return this.password; - } - public void setPassword(String password) { this.password = password; @@ -1772,102 +1796,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public RoomState getState() { - return this.state; - } - - public void setState(RoomState state) { - this.state = state; - } - - public int getUsersMax() { - return this.usersMax; - } - - public void setUsersMax(int usersMax) { - this.usersMax = usersMax; - } - - public int getScore() { - return this.score; - } - - public void setScore(int score) { - this.score = score; - } - - public int getCategory() { - return this.category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getFloorPaint() { - return this.floorPaint; - } - - public void setFloorPaint(String floorPaint) { - this.floorPaint = floorPaint; - } - - public String getWallPaint() { - return this.wallPaint; - } - - public void setWallPaint(String wallPaint) { - this.wallPaint = wallPaint; - } - - public String getBackgroundPaint() { - return this.backgroundPaint; - } - - public void setBackgroundPaint(String backgroundPaint) { - this.backgroundPaint = backgroundPaint; - } - - public int getWallSize() { - return this.wallSize; - } - - public void setWallSize(int wallSize) { - this.wallSize = wallSize; - } - - public int getWallHeight() { - return this.wallHeight; - } - - public void setWallHeight(int wallHeight) { - this.wallHeight = wallHeight; - } - - public int getFloorSize() { - return this.floorSize; - } - - public void setFloorSize(int floorSize) { - this.floorSize = floorSize; - } - - public String getTags() { - return this.tags; - } - - public void setTags(String tags) { - this.tags = tags; - } - - public int getTradeMode() { - return this.tradeMode; - } - - public void setTradeMode(int tradeMode) { - this.tradeMode = tradeMode; - } - public boolean moveDiagonally() { return this.moveDiagonally; } @@ -1878,21 +1806,13 @@ public class Room implements Comparable, ISerialize, Runnable { this.needsUpdate = true; } - public int getGuildId() { - return this.guild; - } - public boolean hasGuild() { - return this.guild != 0; - } - - public void setGuild(int guild) { - this.guild = guild; + return this.guildId != 0; } public String getGuildName() { if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); if (guild != null) { return guild.getName(); @@ -1902,26 +1822,6 @@ public class Room implements Comparable, ISerialize, Runnable { return ""; } - public boolean isPublicRoom() { - return this.publicRoom; - } - - public void setPublicRoom(boolean publicRoom) { - this.publicRoom = publicRoom; - } - - public boolean isStaffPromotedRoom() { - return this.staffPromotedRoom; - } - - public void setStaffPromotedRoom(boolean staffPromotedRoom) { - this.staffPromotedRoom = staffPromotedRoom; - } - - public boolean isAllowPets() { - return this.allowPets; - } - public void setAllowPets(boolean allowPets) { this.allowPets = allowPets; if (!allowPets) { @@ -1929,46 +1829,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public boolean isAllowPetsEat() { - return this.allowPetsEat; - } - - public void setAllowPetsEat(boolean allowPetsEat) { - this.allowPetsEat = allowPetsEat; - } - - public boolean isAllowWalkthrough() { - return this.allowWalkthrough; - } - - public void setAllowWalkthrough(boolean allowWalkthrough) { - this.allowWalkthrough = allowWalkthrough; - } - - public boolean isAllowBotsWalk() { - return this.allowBotsWalk; - } - - public void setAllowBotsWalk(boolean allowBotsWalk) { - this.allowBotsWalk = allowBotsWalk; - } - - public boolean isAllowEffects() { - return this.allowEffects; - } - - public void setAllowEffects(boolean allowEffects) { - this.allowEffects = allowEffects; - } - - public boolean isHideWall() { - return this.hideWall; - } - - public void setHideWall(boolean hideWall) { - this.hideWall = hideWall; - } - public Color getBackgroundTonerColor() { Color color = new Color(0, 0, 0); TIntObjectIterator iterator = this.roomItems.iterator(); @@ -1987,45 +1847,13 @@ public class Room implements Comparable, ISerialize, Runnable { } } } - } catch (Exception e) { + } catch (Exception ignored) { } } return color; } - public int getChatMode() { - return this.chatMode; - } - - public void setChatMode(int chatMode) { - this.chatMode = chatMode; - } - - public int getChatWeight() { - return this.chatWeight; - } - - public void setChatWeight(int chatWeight) { - this.chatWeight = chatWeight; - } - - public int getChatSpeed() { - return this.chatSpeed; - } - - public void setChatSpeed(int chatSpeed) { - this.chatSpeed = chatSpeed; - } - - public int getChatDistance() { - return this.chatDistance; - } - - public void setChatDistance(int chatDistance) { - this.chatDistance = chatDistance; - } - public void removeAllPets() { removeAllPets(-1); } @@ -2046,7 +1874,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } } @@ -2072,50 +1900,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public int getChatProtection() { - return this.chatProtection; - } - - public void setChatProtection(int chatProtection) { - this.chatProtection = chatProtection; - } - - public int getMuteOption() { - return this.muteOption; - } - - public void setMuteOption(int muteOption) { - this.muteOption = muteOption; - } - - public int getKickOption() { - return this.kickOption; - } - - public void setKickOption(int kickOption) { - this.kickOption = kickOption; - } - - public int getBanOption() { - return this.banOption; - } - - public void setBanOption(int banOption) { - this.banOption = banOption; - } - - public int getPollId() { - return this.pollId; - } - - public void setPollId(int pollId) { - this.pollId = pollId; - } - - public int getRollerSpeed() { - return this.rollerSpeed; - } - public void setRollerSpeed(int rollerSpeed) { this.rollerSpeed = rollerSpeed; this.rollerCycle = 0; @@ -2126,10 +1910,6 @@ public class Room implements Comparable, ISerialize, Runnable { return new String[]{this.getOwnerName(), this.getGuildName(), this.getDescription(), this.getPromotionDesc()}; } - public long getCycleTimestamp() { - return this.cycleTimestamp; - } - public boolean isPromoted() { this.promoted = this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp(); this.needsUpdate = true; @@ -2137,10 +1917,6 @@ public class Room implements Comparable, ISerialize, Runnable { return this.promoted; } - public RoomPromotion getPromotion() { - return this.promotion; - } - public String getPromotionDesc() { if (this.promotion != null) { return this.promotion.getDescription(); @@ -2174,7 +1950,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(10, this.promotion.getCategory()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.needsUpdate = true; @@ -2215,57 +1991,25 @@ public class Room implements Comparable, ISerialize, Runnable { game = gameType.getDeclaredConstructor(Room.class).newInstance(this); this.addGame(game); } catch (Exception e) { - LOGGER.error("Error getting game " + gameType.getName(), e); + log.error("Error getting game " + gameType.getName(), e); } } return game; } - public ConcurrentSet getGames() { - return this.games; - } - public int getUserCount() { return this.currentHabbos.size(); } - public ConcurrentHashMap getCurrentHabbos() { - return this.currentHabbos; - } - public Collection getHabbos() { return this.currentHabbos.values(); } - public TIntObjectMap getHabboQueue() { - return this.habboQueue; - } - - public TIntObjectMap getFurniOwnerNames() { - return this.furniOwnerNames; - } - public String getFurniOwnerName(int userId) { return this.furniOwnerNames.get(userId); } - public TIntIntMap getFurniOwnerCount() { - return this.furniOwnerCount; - } - - public TIntObjectMap getMoodlightData() { - return this.moodlightData; - } - - public int getLastTimerReset() { - return this.lastTimerReset; - } - - public void setLastTimerReset(int lastTimerReset) { - this.lastTimerReset = lastTimerReset; - } - public void addToQueue(Habbo habbo) { synchronized (this.habboQueue) { this.habboQueue.put(habbo.getHabboInfo().getId(), habbo); @@ -2280,56 +2024,12 @@ public class Room implements Comparable, ISerialize, Runnable { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return true; } - public TIntObjectMap getCurrentBots() { - return this.currentBots; - } - - public TIntObjectMap getCurrentPets() { - return this.currentPets; - } - - public THashSet getWordFilterWords() { - return this.wordFilterWords; - } - - public RoomSpecialTypes getRoomSpecialTypes() { - return this.roomSpecialTypes; - } - - public boolean isPreLoaded() { - return this.preLoaded; - } - - public boolean isLoaded() { - return this.loaded; - } - - public void setNeedsUpdate(boolean needsUpdate) { - this.needsUpdate = needsUpdate; - } - - public TIntArrayList getRights() { - return this.rights; - } - - public boolean isMuted() { - return this.muted; - } - - public void setMuted(boolean muted) { - this.muted = muted; - } - - public TraxManager getTraxManager() { - return this.traxManager; - } - public void addHabboItem(HabboItem item) { if (item == null) return; @@ -2337,7 +2037,7 @@ public class Room implements Comparable, ISerialize, Runnable { synchronized (this.roomItems) { try { this.roomItems.put(item.getId(), item); - } catch (Exception e) { + } catch (Exception ignored) { } } @@ -2353,7 +2053,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (habbo != null) { this.furniOwnerNames.put(item.getUserId(), habbo.getUsername()); } else { - LOGGER.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); + log.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); } } } @@ -2701,7 +2401,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -2758,7 +2458,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } @@ -2778,7 +2478,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } @@ -2800,7 +2500,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } @@ -2816,16 +2516,13 @@ public class Room implements Comparable, ISerialize, Runnable { final boolean[] result = {false}; synchronized (this.currentBots) { - this.currentBots.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(Bot object) { - if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { - result[0] = true; - return false; - } - - return true; + this.currentBots.forEachValue(object -> { + if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { + result[0] = true; + return false; } + + return true; }); } @@ -2843,7 +2540,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } @@ -2922,7 +2619,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } @@ -3062,8 +2759,8 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.loaded) { RoomTile tile = this.layout.getTile(x, y); - if (z < tile.z) { - z = tile.z; + if (z < tile.getZ()) { + z = tile.getZ(); } roomUnit.setLocation(tile); @@ -3127,15 +2824,15 @@ public class Room implements Comparable, ISerialize, Runnable { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } public void floodMuteHabbo(Habbo habbo, int timeOut) { - habbo.getHabboStats().mutedCount++; - timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2))); - habbo.getHabboStats().chatCounter.set(0); + habbo.getHabboStats().setMutedCount(habbo.getHabboStats().getMutedCount() + 1); + timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().getMutedCount(), 2))); + habbo.getHabboStats().getChatCounter().set(0); habbo.mute(timeOut, true); } @@ -3160,13 +2857,13 @@ public class Room implements Comparable, ISerialize, Runnable { long millis = System.currentTimeMillis(); if (HABBO_CHAT_DELAY) { - if (millis - habbo.getHabboStats().lastChat < 750) { + if (millis - habbo.getHabboStats().getLastChat() < 750) { return; } } - habbo.getHabboStats().lastChat = millis; + habbo.getHabboStats().setLastChat(millis); if (roomChatMessage != null && Emulator.getConfig().getBoolean("easter_eggs.enabled") && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { - habbo.getHabboStats().chatCounter.addAndGet(1); + habbo.getHabboStats().getChatCounter().addAndGet(1); Emulator.getThreading().run(new YouAreAPirate(habbo, this)); return; } @@ -3228,7 +2925,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FLOOD)) { - final int chatCounter = habbo.getHabboStats().chatCounter.addAndGet(1); + final int chatCounter = habbo.getHabboStats().getChatCounter().addAndGet(1); if (chatCounter > 3) { final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); @@ -3311,11 +3008,11 @@ public class Room implements Comparable, ISerialize, Runnable { this.hasRights(h) || noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - if (prefixMessage != null && !h.getHabboStats().preferOldChat) { + if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(prefixMessage); } h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { + if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(clearPrefixMessage); } } @@ -3332,11 +3029,11 @@ public class Room implements Comparable, ISerialize, Runnable { // If the receiving Habbo has not ignored the sending Habbo // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { - if (prefixMessage != null && !h.getHabboStats().preferOldChat) { + if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(prefixMessage); } h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { + if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(clearPrefixMessage); } continue; @@ -3357,7 +3054,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.onUserSay(roomChatMessage); } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } } @@ -3389,7 +3086,7 @@ public class Room implements Comparable, ISerialize, Runnable { break; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -3433,8 +3130,8 @@ public class Room implements Comparable, ISerialize, Runnable { boolean found = false; for (RoomTile tile : lockedTiles) { - if (tile.x == item.getX() && - tile.y == item.getY()) { + if (tile.getX() == item.getX() && + tile.getY() == item.getY()) { found = true; break; } @@ -3522,7 +3219,7 @@ public class Room implements Comparable, ISerialize, Runnable { 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)) + if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1)) continue; items.add(item); @@ -3604,7 +3301,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (tile == null) continue; - for (HabboItem item : this.getItemsAt(tile.x, tile.y)) { + for (HabboItem item : this.getItemsAt(tile.getX(), tile.getY())) { if (exclude != null && exclude == item) continue; @@ -3760,7 +3457,7 @@ public class Room implements Comparable, ISerialize, Runnable { return false; } - if (roomTile.state == RoomTileState.INVALID) + if (roomTile.getState() == RoomTileState.INVALID) return false; HabboItem topItem = null; @@ -3882,7 +3579,7 @@ public class Room implements Comparable, ISerialize, Runnable { public void petChat(ServerMessage message) { for (Habbo habbo : this.getHabbos()) { - if (!habbo.getHabboStats().ignorePets) + if (!habbo.getHabboStats().isIgnorePets()) habbo.getClient().sendResponse(message); } } @@ -3893,7 +3590,7 @@ public class Room implements Comparable, ISerialize, Runnable { } for (Habbo habbo : this.getHabbos()) { - if (!habbo.getHabboStats().ignoreBots) + if (!habbo.getHabboStats().isIgnoreBots()) habbo.getClient().sendResponse(message); } } @@ -3908,7 +3605,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -3927,18 +3624,18 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public RoomRightLevels getGuildRightLevel(Habbo habbo) { - if (this.guild > 0 && habbo.getHabboStats().hasGuild(this.guild)) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); + if (this.guildId > 0 && habbo.getHabboStats().hasGuild(this.guildId)) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(habbo.getHabboInfo().getId()) != null) return RoomRightLevels.GUILD_ADMIN; - if (guild.getRights()) { + if (guild.isRights()) { return RoomRightLevels.GUILD_RIGHTS; } } @@ -3951,7 +3648,7 @@ public class Room implements Comparable, ISerialize, Runnable { */ @Deprecated public int guildRightLevel(Habbo habbo) { - return this.getGuildRightLevel(habbo).level; + return this.getGuildRightLevel(habbo).getLevel(); } public boolean isOwner(Habbo habbo) { @@ -3978,7 +3675,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -4008,14 +3705,14 @@ public class Room implements Comparable, ISerialize, Runnable { return; this.sendComposer(new FlatControllerRemovedComposer(this, userId).compose()); - + if (this.rights.remove(userId)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, this.id); statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -4038,7 +3735,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(1, this.id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.refreshRightsInRoom(); @@ -4077,7 +3774,7 @@ public class Room implements Comparable, ISerialize, Runnable { } habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); - habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, flatCtrl.level + ""); + habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, flatCtrl.getLevel() + ""); habbo.getRoomUnit().setRightsLevel(flatCtrl); habbo.getRoomUnit().statusUpdate(true); @@ -4098,7 +3795,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -4118,7 +3815,7 @@ public class Room implements Comparable, ISerialize, Runnable { public boolean isBanned(Habbo habbo) { RoomBan ban = this.bannedHabbos.get(habbo.getHabboInfo().getId()); - boolean banned = ban != null && ban.endTimestamp > Emulator.getIntUnixTimestamp() && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermission("acc_enteranyroom"); + boolean banned = ban != null && ban.getEndTimestamp() > Emulator.getIntUnixTimestamp() && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermission("acc_enteranyroom"); if (!banned && ban != null) { this.unbanHabbo(habbo.getHabboInfo().getId()); @@ -4132,7 +3829,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void addRoomBan(RoomBan roomBan) { - this.bannedHabbos.put(roomBan.userId, roomBan); + this.bannedHabbos.put(roomBan.getUserId(), roomBan); } public void makeSit(Habbo habbo) { @@ -4335,7 +4032,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Habbo habbo : this.getHabbos()) { Optional member = members.stream().filter(m -> m.getUserId() == habbo.getHabboInfo().getId()).findAny(); - if (!member.isPresent()) continue; + if (member.isEmpty()) continue; habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, member.get())); } @@ -4423,7 +4120,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return; } @@ -4440,7 +4137,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -4502,7 +4199,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.hideWired = hideWired; if (this.hideWired) { - ServerMessage response = null; for (HabboItem item : this.roomSpecialTypes.getTriggers()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } @@ -4531,7 +4227,7 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.MAX_ITEMS; } - if (tile == null || tile.state == RoomTileState.INVALID) { + if (tile == null || tile.getState() == RoomTileState.INVALID) { return FurnitureMovementError.INVALID_MOVE; } @@ -4541,10 +4237,10 @@ public class Room implements Comparable, ISerialize, Runnable { } if (habbo.getHabboStats().isRentingSpace()) { - HabboItem rentSpace = this.getHabboItem(habbo.getHabboStats().rentedItemId); + HabboItem rentSpace = this.getHabboItem(habbo.getHabboStats().getRentedItemId()); if (rentSpace != null) { - if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(tile.x, tile.y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { + if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(tile.getX(), tile.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { return FurnitureMovementError.NO_RIGHTS; } else { return FurnitureMovementError.NONE; @@ -4574,11 +4270,12 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); for (RoomTile t : occupiedTiles) { - if (t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE; + if (t.getState() == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE; if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) { - if (checkForUnits && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (checkForUnits && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; - if (checkForUnits && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + if (checkForUnits && this.hasHabbosAt(t.getX(), t.getY())) + return FurnitureMovementError.TILE_HAS_HABBOS; + if (checkForUnits && this.hasBotsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_BOTS; + if (checkForUnits && this.hasPetsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_PETS; } } @@ -4588,7 +4285,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - HabboItem topItem = this.getTopItemAt(t.x, t.y, item); + HabboItem topItem = this.getTopItemAt(t.getX(), t.getY(), item); if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { return FurnitureMovementError.CANT_STACK; } @@ -4642,8 +4339,8 @@ public class Room implements Comparable, ISerialize, Runnable { } item.setZ(height); - item.setX(tile.x); - item.setY(tile.y); + item.setX(tile.getX()); + item.setY(tile.getY()); item.setRotation(rotation); if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) { this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername()); @@ -4657,8 +4354,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new ObjectAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t.x, t.y); - this.updateBotsAt(t.x, t.y); + this.updateHabbosAt(t.getX(), t.getY()); + this.updateBotsAt(t.getX(), t.getY()); } Emulator.getThreading().run(item); @@ -4721,20 +4418,20 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem topItem = this.getTopItemAt(occupiedTiles, null); - if ((!stackHelper.isPresent() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { + if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { if (oldLocation != tile) { for (RoomTile t : occupiedTiles) { - HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); - if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || + HabboItem tileTopItem = this.getTopItemAt(t.getX(), t.getY()); + if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { return FurnitureMovementError.CANT_STACK; } if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { if (checkForUnits) { - 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; + if (!magicTile && this.hasHabbosAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_HABBOS; + if (!magicTile && this.hasBotsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_BOTS; + if (!magicTile && this.hasPetsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_PETS; } } } @@ -4782,9 +4479,9 @@ public class Room implements Comparable, ISerialize, Runnable { } else if (item == topItem) { height = item.getZ(); } else { - height = this.getStackHeight(tile.x, tile.y, false, item); + height = this.getStackHeight(tile.getX(), tile.getY(), false, item); for (RoomTile til : occupiedTiles) { - double sHeight = this.getStackHeight(til.x, til.y, false, item); + double sHeight = this.getStackHeight(til.getX(), til.getY(), false, item); if (sHeight > height) { height = sHeight; } @@ -4792,7 +4489,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.getLayout().getHeightAtSquare(tile.x, tile.y)) + if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { @@ -4803,14 +4500,14 @@ public class Room implements Comparable, ISerialize, Runnable { } if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.getLayout().getHeightAtSquare(tile.x, tile.y)) + if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor - item.setX(tile.x); - item.setY(tile.y); + item.setX(tile.getX()); + item.setY(tile.getY()); item.setZ(height); if (magicTile) { - item.setZ(tile.z); + item.setZ(tile.getZ()); item.setExtradata("" + item.getZ() * 100); } if (item.getZ() > MAXIMUM_FURNI_HEIGHT) { @@ -4835,21 +4532,21 @@ public class Room implements Comparable, ISerialize, Runnable { //Update Habbos at old position for (RoomTile t : occupiedTiles) { this.updateHabbosAt( - t.x, - t.y, - this.getHabbosAt(t.x, t.y) + t.getX(), + t.getY(), + this.getHabbosAt(t.getX(), t.getY()) /*.stream() .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t) .collect(Collectors.toCollection(THashSet::new))*/ ); - this.updateBotsAt(t.x, t.y); + this.updateBotsAt(t.getX(), t.getY()); } if (Emulator.getConfig().getBoolean("wired.place.under", false)) { for (RoomTile t : newOccupiedTiles) { - for (Habbo h : this.getHabbosAt(t.x, t.y)) { + for (Habbo h : this.getHabbosAt(t.getX(), t.getY())) { try { item.onWalkOn(h.getRoomUnit(), this, null); - } catch (Exception e) { + } catch (Exception ignored) { } } @@ -4859,10 +4556,6 @@ public class Room implements Comparable, ISerialize, Runnable { } public FurnitureMovementError slideFurniTo(HabboItem item, RoomTile tile, int rotation) { - RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY()); - - HabboItem topItem = this.getTopItemAt(tile.x, tile.y); - boolean magicTile = item instanceof InteractionStackHelper; //Check if can be placed at new position @@ -4877,26 +4570,23 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.CANT_STACK; } - THashSet oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - - int oldRotation = item.getRotation(); item.setRotation(rotation); //Place at new position if (magicTile) { - item.setZ(tile.z); + item.setZ(tile.getZ()); item.setExtradata("" + item.getZ() * 100); } if (item.getZ() > MAXIMUM_FURNI_HEIGHT) { item.setZ(MAXIMUM_FURNI_HEIGHT); } - double offset = this.getStackHeight(tile.x, tile.y, false, item) - item.getZ(); + double offset = this.getStackHeight(tile.getX(), tile.getY(), false, item) - item.getZ(); this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose()); //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t.x, t.y); - this.updateBotsAt(t.x, t.y); + this.updateHabbosAt(t.getX(), t.getY()); + this.updateBotsAt(t.getX(), t.getY()); } return FurnitureMovementError.NONE; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java index 3765175b..cd7c61c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java @@ -1,29 +1,24 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter +@AllArgsConstructor public class RoomBan { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomBan.class); - - public final int roomId; - public final int userId; - public final String username; - public final int endTimestamp; - - public RoomBan(int roomId, int userId, String username, int endTimestamp) { - this.roomId = roomId; - this.userId = userId; - this.username = username; - this.endTimestamp = endTimestamp; - } + private final int roomId; + private final int userId; + private final String username; + private final int endTimestamp; public RoomBan(ResultSet set) throws SQLException { this.roomId = set.getInt("room_id"); @@ -40,7 +35,7 @@ public class RoomBan { statement.setInt(3, this.endTimestamp); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -51,7 +46,7 @@ public class RoomBan { statement.setInt(2, this.userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java index 59b7b920..ede5b230 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java @@ -1,22 +1,24 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.navigation.ListMode; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; -@SuppressWarnings("NullableProblems") +@Getter public class RoomCategory implements Comparable { - private int id; - private int minRank; - private String caption; - private String captionSave; - private boolean canTrade; - private int maxUserCount; - private boolean official; - private ListMode displayMode; - private int order; + private final int id; + private final int minRank; + private final String caption; + private final String captionSave; + private final boolean canTrade; + private final int maxUserCount; + private final boolean isPublic; + private final ListMode displayMode; + + private final int order; public RoomCategory(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -25,47 +27,11 @@ public class RoomCategory implements Comparable { this.captionSave = set.getString("caption_save"); this.canTrade = set.getBoolean("can_trade"); this.maxUserCount = set.getInt("max_user_count"); - this.official = set.getString("public").equals("1"); + this.isPublic = set.getString("public").equals("1"); this.displayMode = ListMode.fromType(set.getInt("list_type")); this.order = set.getInt("order_num"); } - public int getId() { - return this.id; - } - - public int getMinRank() { - return this.minRank; - } - - public String getCaption() { - return this.caption; - } - - public String getCaptionSave() { - return this.captionSave; - } - - public boolean isCanTrade() { - return this.canTrade; - } - - public int getMaxUserCount() { - return this.maxUserCount; - } - - public boolean isPublic() { - return this.official; - } - - public ListMode getDisplayMode() { - return this.displayMode; - } - - public int getOrder() { - return this.order; - } - @Override public int compareTo(RoomCategory o) { return o.getId() - this.getId(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index abb13894..0511771d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -8,17 +8,17 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Arrays; import java.util.List; +@Slf4j public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { - - private static final Logger LOGGER = LoggerFactory.getLogger(RoomChatMessage.class); private static final String QUERY = "INSERT INTO chatlogs_room (user_from_id, user_to_id, message, timestamp, room_id) VALUES (?, ?, ?, ?, ?)"; private static final List chatColors = Arrays.asList("@red@", "@cyan@", "@blue@", "@green@", "@purple@"); @@ -26,16 +26,23 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_ROOM_CHATS = false; public static int[] BANNED_BUBBLES = {}; + @Getter private final Habbo habbo; public int roomId; public boolean isCommand = false; public boolean filtered = false; - private int roomUnitId; + private final int roomUnitId; + @Setter + @Getter private String message; - private String unfilteredMessage; + @Getter + private final String unfilteredMessage; private int timestamp = 0; + @Getter private RoomChatMessageBubbles bubble; + @Getter private Habbo targetHabbo; + @Getter private byte emotion; public RoomChatMessage(MessageHandler message) { @@ -98,8 +105,8 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.roomUnitId = habbo.getRoomUnit().getId(); this.message = this.message.replace("\r", "").replace("\n", ""); - if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) - this.bubble = this.getHabbo().getHabboStats().chatColor; + if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().getChatColor() != RoomChatMessageBubbles.NORMAL) + this.bubble = this.getHabbo().getHabboStats().getChatColor(); } public RoomChatMessage(String message, Habbo habbo, Habbo targetHabbo, RoomChatMessageBubbles bubble) { @@ -112,8 +119,8 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.roomUnitId = this.habbo.getRoomUnit().getId(); this.message = this.message.replace("\r", "").replace("\n", ""); - if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) - this.bubble = this.getHabbo().getHabboStats().chatColor; + if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().getChatColor() != RoomChatMessageBubbles.NORMAL) + this.bubble = this.getHabbo().getHabboStats().getChatColor(); } private void checkEmotion() { @@ -137,41 +144,13 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { try { this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH - 1); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } Emulator.getDatabaseLogger().store(this); } - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getUnfilteredMessage() { - return this.unfilteredMessage; - } - - public RoomChatMessageBubbles getBubble() { - return this.bubble; - } - - public Habbo getHabbo() { - return this.habbo; - } - - public Habbo getTargetHabbo() { - return this.targetHabbo; - } - - public int getEmotion() { - return this.emotion; - } - @Override public void serialize(ServerMessage message) { if (this.habbo != null && this.bubble.isOverridable()) { @@ -199,7 +178,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { message.appendInt(0); message.appendInt(this.getMessage().length()); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -222,7 +201,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { if (muteTime > 0) { this.habbo.mute(muteTime, false); } else { - LOGGER.error("Invalid hotel.wordfilter.automute defined in emulator_settings ({}).", muteTime); + log.error("Invalid hotel.wordfilter.automute defined in emulator_settings ({}).", muteTime); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java index 31b7e905..5f74e12c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java @@ -1,5 +1,9 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor public enum RoomChatMessageBubbles { NORMAL(0, "", true, true), ALERT(1, "", true, true), @@ -48,17 +52,14 @@ public enum RoomChatMessageBubbles { UNKNOWN_44(44, "", true, false), UNKNOWN_45(45, "", true, false); + @Getter private final int type; + @Getter private final String permission; + @Getter private final boolean overridable; private final boolean triggersTalkingFurniture; - RoomChatMessageBubbles(int type, String permission, boolean overridable, boolean triggersTalkingFurniture) { - this.type = type; - this.permission = permission; - this.overridable = overridable; - this.triggersTalkingFurniture = triggersTalkingFurniture; - } public static RoomChatMessageBubbles getBubble(int bubbleId) { try { @@ -68,18 +69,6 @@ public enum RoomChatMessageBubbles { } } - public int getType() { - return this.type; - } - - public String getPermission() { - return this.permission; - } - - public boolean isOverridable() { - return this.overridable; - } - public boolean triggersTalkingFurniture() { return this.triggersTalkingFurniture; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index f70f3d3e..2f49d04f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -2,8 +2,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.awt.*; import java.sql.ResultSet; @@ -13,8 +12,8 @@ import java.util.Deque; import java.util.LinkedList; import java.util.List; +@Slf4j public class RoomLayout { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomLayout.class); protected static final int BASICMOVEMENTCOST = 10; protected static final int DIAGONALMOVEMENTCOST = 14; public static double MAXIMUM_STEP_HEIGHT = 1.1; @@ -31,7 +30,7 @@ public class RoomLayout { private int mapSizeY; private RoomTile[][] roomTiles; private RoomTile doorTile; - private Room room; + private final Room room; public RoomLayout(ResultSet set, Room room) throws SQLException { this.room = room; @@ -45,7 +44,7 @@ public class RoomLayout { this.parse(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -59,14 +58,11 @@ public class RoomLayout { if (outerSquare.x + outerSquare.width < innerSquare.x + innerSquare.width) return false; - if (outerSquare.y + outerSquare.height < innerSquare.y + innerSquare.height) - return false; - - return true; + return outerSquare.y + outerSquare.height >= innerSquare.y + innerSquare.height; } public static boolean tileInSquare(Rectangle square, RoomTile tile) { - return (square.contains(tile.x, tile.y)); + return (square.contains(tile.getX(), tile.getY())); } public static boolean pointInSquare(int x1, int y1, int x2, int y2, int pointX, int pointY) { @@ -74,7 +70,7 @@ public class RoomLayout { } public static boolean tilesAdjecent(RoomTile one, RoomTile two) { - return !(one == null || two == null) && !(Math.abs(one.x - two.x) > 1) && !(Math.abs(one.y - two.y) > 1); + return !(one == null || two == null) && !(Math.abs(one.getX() - two.getX()) > 1) && !(Math.abs(one.getY() - two.getY()) > 1); } public static Rectangle getRectangle(int x, int y, int width, int length, int rotation) { @@ -88,10 +84,10 @@ public class RoomLayout { } public static boolean tilesAdjecent(RoomTile tile, RoomTile comparator, int width, int length, int rotation) { - Rectangle rectangle = getRectangle(comparator.x, comparator.y, width, length, rotation); + Rectangle rectangle = getRectangle(comparator.getX(), comparator.getY(), width, length, rotation); rectangle = new Rectangle(rectangle.x - 1, rectangle.y - 1, rectangle.width + 2, rectangle.height + 2); - return rectangle.contains(tile.x, tile.y); + return rectangle.contains(tile.getX(), tile.getY()); } public void parse() { @@ -138,11 +134,11 @@ public class RoomLayout { this.doorTile.setAllowStack(false); RoomTile doorFrontTile = this.getTileInFront(this.doorTile, this.doorDirection); - if (doorFrontTile != null && this.tileExists(doorFrontTile.x, doorFrontTile.y)) { - if (this.roomTiles[doorFrontTile.x][doorFrontTile.y].state != RoomTileState.INVALID) { - if (this.doorZ != this.roomTiles[doorFrontTile.x][doorFrontTile.y].z || this.roomTiles[this.doorX][this.doorY].state != this.roomTiles[doorFrontTile.x][doorFrontTile.y].state) { - this.doorZ = this.roomTiles[doorFrontTile.x][doorFrontTile.y].z; - this.roomTiles[this.doorX][this.doorY].state = RoomTileState.OPEN; + if (doorFrontTile != null && this.tileExists(doorFrontTile.getX(), doorFrontTile.getY())) { + if (this.roomTiles[doorFrontTile.getX()][doorFrontTile.getY()].getState() != RoomTileState.INVALID) { + if (this.doorZ != this.roomTiles[doorFrontTile.getX()][doorFrontTile.getY()].getZ() || this.roomTiles[this.doorX][this.doorY].getState() != this.roomTiles[doorFrontTile.getX()][doorFrontTile.getY()].getState()) { + this.doorZ = this.roomTiles[doorFrontTile.getX()][doorFrontTile.getY()].getZ(); + this.roomTiles[this.doorX][this.doorY].setState(RoomTileState.OPEN); } } } @@ -212,7 +208,7 @@ public class RoomLayout { y >= this.getMapSizeY()) return 0; - return this.roomTiles[x][y].z; + return this.roomTiles[x][y].getZ(); } public double getStackHeightAtSquare(int x, int y) { @@ -248,12 +244,12 @@ public class RoomLayout { } public boolean tileWalkable(short x, short y) { - return this.tileExists(x, y) && this.roomTiles[x][y].state == RoomTileState.OPEN && this.roomTiles[x][y].isWalkable(); + return this.tileExists(x, y) && this.roomTiles[x][y].getState() == RoomTileState.OPEN && this.roomTiles[x][y].isWalkable(); } public boolean isVoidTile(short x, short y) { if (!this.tileExists(x, y)) return true; - return this.roomTiles[x][y].state == RoomTileState.INVALID; + return this.roomTiles[x][y].getState() == RoomTileState.INVALID; } public String getRelativeMap() { @@ -266,7 +262,7 @@ public class RoomLayout { /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) { - if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) + if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.getState() == RoomTileState.INVALID) return new LinkedList<>(); LinkedList openList = new LinkedList<>(); @@ -277,8 +273,8 @@ public class RoomLayout { while (!openList.isEmpty()) { RoomTile current = this.lowestFInOpen(openList); - if (current.x == newTile.x && current.y == newTile.y) { - return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); + if (current.getX() == newTile.getX() && current.getY() == newTile.getY()) { + return this.calcPath(this.findTile(openList, oldTile.getX(), oldTile.getY()), current); } closedList.add(current); @@ -290,13 +286,13 @@ public class RoomLayout { if (roomUnit.canOverrideTile(currentAdj)) { currentAdj.setPrevious(current); - currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); + currentAdj.sethCosts(this.findTile(openList, newTile.getX(), newTile.getY())); currentAdj.setgCosts(current); openList.add(currentAdj); continue; } - if (currentAdj.state == RoomTileState.BLOCKED || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) { + if (currentAdj.getState() == RoomTileState.BLOCKED || ((currentAdj.getState() == RoomTileState.SIT || currentAdj.getState() == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -304,7 +300,7 @@ public class RoomLayout { double height = currentAdj.getStackHeight() - current.getStackHeight(); - if ((!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) || (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT)) { + if ((!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) || (currentAdj.getState() == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT)) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -318,10 +314,10 @@ public class RoomLayout { if (!openList.contains(currentAdj)) { currentAdj.setPrevious(current); - currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); + currentAdj.sethCosts(this.findTile(openList, newTile.getX(), newTile.getY())); currentAdj.setgCosts(current); openList.add(currentAdj); - } else if (currentAdj.getgCosts() > currentAdj.calculategCosts(current)) { + } else if (currentAdj.getGCosts() > currentAdj.calculategCosts(current)) { currentAdj.setPrevious(current); currentAdj.setgCosts(current); } @@ -337,7 +333,7 @@ public class RoomLayout { private RoomTile findTile(List tiles, short x, short y) { for (RoomTile tile : tiles) { - if (x == tile.x && y == tile.y) { + if (x == tile.getX() && y == tile.getY()) { return tile; } } @@ -357,7 +353,7 @@ public class RoomLayout { RoomTile curr = goal; while (curr != null) { - path.addFirst(this.getTile(curr.x, curr.y)); + path.addFirst(this.getTile(curr.getX(), curr.getY())); curr = curr.getPrevious(); if ((curr != null) && (curr.equals(start))) { return path; @@ -380,15 +376,14 @@ public class RoomLayout { } private List getAdjacent(List openList, RoomTile node, RoomTile nextTile, RoomUnit unit) { - short x = node.x; - short y = node.y; + short x = node.getX(); + short y = node.getY(); List adj = new LinkedList<>(); if (x > 0) { RoomTile temp = this.findTile(openList, (short) (x - 1), y); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); - if (!adj.contains(temp)) adj.add(temp); } } @@ -396,7 +391,7 @@ public class RoomLayout { if (x < this.mapSizeX) { RoomTile temp = this.findTile(openList, (short) (x + 1), y); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); @@ -406,7 +401,7 @@ public class RoomLayout { if (y > 0) { RoomTile temp = this.findTile(openList, x, (short) (y - 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); @@ -416,7 +411,7 @@ public class RoomLayout { if (y < this.mapSizeY) { RoomTile temp = this.findTile(openList, x, (short) (y + 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); @@ -430,7 +425,7 @@ public class RoomLayout { if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -444,7 +439,7 @@ public class RoomLayout { if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -458,7 +453,7 @@ public class RoomLayout { if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -472,7 +467,7 @@ public class RoomLayout { if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1)); if (this.canWalkOn(temp, unit)) { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { + if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -485,7 +480,7 @@ public class RoomLayout { } private boolean canWalkOn(RoomTile tile, RoomUnit unit) { - return tile != null && (unit.canOverrideTile(tile) || (tile.state != RoomTileState.BLOCKED && tile.state != RoomTileState.INVALID)); + return tile != null && (unit.canOverrideTile(tile) || (tile.getState() != RoomTileState.BLOCKED && tile.getState() != RoomTileState.INVALID)); } public void moveDiagonally(boolean value) { @@ -502,38 +497,30 @@ public class RoomLayout { rotation = rotation % 8; switch (rotation) { - case 0: - offsetY--; - break; - case 1: + case 0 -> offsetY--; + case 1 -> { offsetX++; offsetY--; - break; - case 2: - offsetX++; - break; - case 3: + } + case 2 -> offsetX++; + case 3 -> { offsetX++; offsetY++; - break; - case 4: - offsetY++; - break; - case 5: + } + case 4 -> offsetY++; + case 5 -> { offsetX--; offsetY++; - break; - case 6: - offsetX--; - break; - case 7: + } + case 6 -> offsetX--; + case 7 -> { offsetX--; offsetY--; - break; + } } - short x = tile.x; - short y = tile.y; + short x = tile.getX(); + short y = tile.getY(); for (int i = 0; i <= offset; i++) { x += offsetX; @@ -545,9 +532,8 @@ public class RoomLayout { public List getTilesInFront(RoomTile tile, int rotation, int amount) { List tiles = new ArrayList<>(amount); - RoomTile previous = tile; for (int i = 0; i < amount; i++) { - RoomTile t = this.getTileInFront(previous, rotation, i); + RoomTile t = this.getTileInFront(tile, rotation, i); if (t != null) { tiles.add(t); @@ -592,7 +578,7 @@ public class RoomLayout { List toRemove = new ArrayList<>(); for (RoomTile t : availableTiles) { - if (t == null || t.state != RoomTileState.OPEN || !t.isWalkable()) { + if (t == null || t.getState() != RoomTileState.OPEN || !t.isWalkable()) { toRemove.add(t); } } @@ -607,21 +593,21 @@ public class RoomLayout { public boolean fitsOnMap(RoomTile tile, int width, int length, int rotation) { if (tile != null) { if (rotation == 0 || rotation == 4) { - for (short i = tile.x; i <= (tile.x + (width - 1)); i++) { - for (short j = tile.y; j <= (tile.y + (length - 1)); j++) { + for (short i = tile.getX(); i <= (tile.getX() + (width - 1)); i++) { + for (short j = tile.getY(); j <= (tile.getY() + (length - 1)); j++) { RoomTile t = this.getTile(i, j); - if (t == null || t.state == RoomTileState.INVALID) { + if (t == null || t.getState() == RoomTileState.INVALID) { return false; } } } } else if (rotation == 2 || rotation == 6) { - for (short i = tile.x; i <= (tile.x + (length - 1)); i++) { - for (short j = tile.y; j <= (tile.y + (width - 1)); j++) { + for (short i = tile.getX(); i <= (tile.getX() + (length - 1)); i++) { + for (short j = tile.getY(); j <= (tile.getY() + (width - 1)); j++) { RoomTile t = this.getTile(i, j); - if (t == null || t.state == RoomTileState.INVALID) { + if (t == null || t.getState() == RoomTileState.INVALID) { return false; } } @@ -637,8 +623,8 @@ public class RoomLayout { if (tile != null) { if (rotation == 0 || rotation == 4) { - for (short i = tile.x; i <= (tile.x + (width - 1)); i++) { - for (short j = tile.y; j <= (tile.y + (length - 1)); j++) { + for (short i = tile.getX(); i <= (tile.getX() + (width - 1)); i++) { + for (short j = tile.getY(); j <= (tile.getY() + (length - 1)); j++) { RoomTile t = this.getTile(i, j); if (t != null) { @@ -647,8 +633,8 @@ public class RoomLayout { } } } else if (rotation == 2 || rotation == 6) { - for (short i = tile.x; i <= (tile.x + (length - 1)); i++) { - for (short j = tile.y; j <= (tile.y + (width - 1)); j++) { + for (short i = tile.getX(); i <= (tile.getX() + (length - 1)); i++) { + for (short j = tile.getY(); j <= (tile.getY() + (width - 1)); j++) { RoomTile t = this.getTile(i, j); if (t != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 8d48bf07..fcb9fbdf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -32,11 +32,11 @@ import com.eu.habbo.messages.incoming.users.NewUserExperienceScriptProceedEvent; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; import com.eu.habbo.messages.outgoing.polls.PollOfferComposer; -import com.eu.habbo.messages.outgoing.polls.infobus.QuestionFinishedComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; +import com.eu.habbo.messages.outgoing.polls.infobus.QuestionFinishedComposer; import com.eu.habbo.messages.outgoing.rooms.*; -import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.ItemsComposer; +import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomEventComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; @@ -50,20 +50,18 @@ import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TIntProcedure; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +@Slf4j public class RoomManager { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomManager.class); - private static final int page = 0; //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ROOMS_USER = 25; @@ -93,7 +91,7 @@ public class RoomManager { registerGameType(IceTagGame.class); registerGameType(RollerskateGame.class); - LOGGER.info("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadRoomModels() { @@ -103,7 +101,7 @@ public class RoomManager { this.mapNames.add(set.getString("name")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -117,7 +115,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return layout; @@ -131,7 +129,7 @@ public class RoomManager { this.roomCategories.put(set.getInt("id"), new RoomCategory(set)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -147,15 +145,15 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } public THashMap> findRooms(NavigatorFilterField filterField, String value, int category, boolean showInvisible) { THashMap> rooms = new THashMap<>(); - String query = filterField.databaseQuery + " AND rooms.state NOT LIKE " + (showInvisible ? "''" : "'invisible'") + (category >= 0 ? "AND rooms.category = '" + category + "'" : "") + " ORDER BY rooms.users, rooms.id DESC LIMIT " + (page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + "" + ((page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + NavigatorManager.MAXIMUM_RESULTS_PER_PAGE); + String query = filterField.getDatabaseQuery() + " AND rooms.state NOT LIKE " + (showInvisible ? "''" : "'invisible'") + (category >= 0 ? "AND rooms.category = '" + category + "'" : "") + " ORDER BY rooms.users, rooms.id DESC LIMIT " + (/* TODO: This is always 0?*/page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + "" + ((page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + NavigatorManager.MAXIMUM_RESULTS_PER_PAGE); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { - statement.setString(1, (filterField.comparator == NavigatorFilterComparator.EQUALS ? value : "%" + value + "%")); + statement.setString(1, (filterField.getComparator() == NavigatorFilterComparator.EQUALS ? value : "%" + value + "%")); try (ResultSet set = statement.executeQuery()) { while (set.next()) { Room room = this.activeRooms.get(set.getInt("id")); @@ -173,7 +171,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -280,7 +278,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -321,7 +319,7 @@ public class RoomManager { this.activeRooms.put(room.getId(), room); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return room; @@ -346,7 +344,7 @@ public class RoomManager { room = this.loadRoom(set.getInt(1)); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return room; @@ -371,7 +369,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -421,7 +419,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return layout; @@ -445,7 +443,7 @@ public class RoomManager { room.setScore(room.getScore() + 1); room.setNeedsUpdate(true); - habbo.getHabboStats().votedRooms.push(room.getId()); + habbo.getHabboStats().getVotedRooms().push(room.getId()); for (Habbo h : room.getHabbos()) { h.getClient().sendResponse(new RoomRatingComposer(room.getScore(), !this.hasVotedForRoom(h, room))); } @@ -455,7 +453,7 @@ public class RoomManager { statement.setInt(2, room.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -464,7 +462,7 @@ public class RoomManager { if (room.getOwnerId() == habbo.getHabboInfo().getId()) return true; - for (int i : habbo.getHabboStats().votedRooms.toArray()) { + for (int i : habbo.getHabboStats().getVotedRooms().toArray()) { if (i == room.getId()) return true; } @@ -612,7 +610,7 @@ public class RoomManager { } else { habbo.getRoomUnit().setCanLeaveRoomByDoor(false); habbo.getRoomUnit().isTeleporting = true; - HabboItem topItem = room.getTopItemAt(doorLocation.x, doorLocation.y); + HabboItem topItem = room.getTopItemAt(doorLocation.getX(), doorLocation.getY()); if (topItem != null) { habbo.getRoomUnit().setRotation(RoomUserRotation.values()[topItem.getRotation()]); } @@ -638,7 +636,7 @@ public class RoomManager { habbo.getRoomUnit().setInRoom(true); if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo, true); - } else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null) { + } else if (!habbo.getHabboStats().isBlockFollowing() && habbo.getHabboInfo().getCurrentRoom() == null) { habbo.getMessenger().connectionChanged(habbo, true, true); } @@ -748,15 +746,15 @@ public class RoomManager { habbo.getClient().sendResponse(new UserUpdateComposer(habbos)); } - if (habbo.getHabboStats().guild != 0) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().guild); + if (habbo.getHabboStats().getGuild() != 0) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().getGuild()); if (guild != null) { room.sendComposer(new HabboAddGroupBadgesMessageComposer(guild).compose()); } } - int effect = habbo.getInventory().getEffectsComponent().activatedEffect; + int effect = habbo.getInventory().getEffectsComponent().getActivatedEffect(); room.giveEffect(habbo.getRoomUnit(), effect, -1); } @@ -798,20 +796,17 @@ public class RoomManager { } } - allFloorItems.forEach(new TObjectProcedure() { - @Override - public boolean execute(HabboItem object) { - if (room.isHideWired() && object instanceof InteractionWired) - return true; - - floorItems.add(object); - if (floorItems.size() == 250) { - habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); - floorItems.clear(); - } - + allFloorItems.forEach(object -> { + if (room.isHideWired() && object instanceof InteractionWired) return true; + + floorItems.add(object); + if (floorItems.size() == 250) { + habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); + floorItems.clear(); } + + return true; }); habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); @@ -826,13 +821,13 @@ public class RoomManager { } if (!habbo.getHabboStats().allowTalk()) { - habbo.getHabboStats().mutedBubbleTracker = true; + habbo.getHabboStats().setMutedBubbleTracker(true); int remainingMuteTime = habbo.getHabboStats().remainingMuteTime(); habbo.getClient().sendResponse(new FloodControlMessageComposer(remainingMuteTime)); habbo.getClient().sendResponse(new RemainingMutePeriodComposer(remainingMuteTime)); room.sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.MUTED).compose()); - } else if (habbo.getHabboStats().mutedBubbleTracker) { - habbo.getHabboStats().mutedBubbleTracker = false; + } else if (habbo.getHabboStats().isMutedBubbleTracker()) { + habbo.getHabboStats().setMutedBubbleTracker(false); } THashMap guildBadges = new THashMap<>(); @@ -864,19 +859,19 @@ public class RoomManager { habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.IGNORED)); } - if (roomHabbo.getHabboStats().guild != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().guild)) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().guild); + if (roomHabbo.getHabboStats().getGuild() != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().getGuild())) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().getGuild()); if (guild != null) { - guildBadges.put(roomHabbo.getHabboStats().guild, guild.getBadge()); + guildBadges.put(roomHabbo.getHabboStats().getGuild(), guild.getBadge()); } } if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) { try { habbo.getClient().sendResponse(new UserRemoveMessageComposer(roomHabbo.getRoomUnit())); - habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) roomHabbo.getHabboStats().cache.get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().cache.get("pet_race"), (String) roomHabbo.getHabboStats().cache.get("pet_color"), roomHabbo)); - } catch (Exception e) { + habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) roomHabbo.getHabboStats().getCache().get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().getCache().get("pet_race"), (String) roomHabbo.getHabboStats().getCache().get("pet_color"), roomHabbo)); + } catch (Exception ignored) { } } @@ -914,7 +909,7 @@ public class RoomManager { WiredHandler.handle(WiredTriggerType.ENTER_ROOM, habbo.getRoomUnit(), room, null); room.habboEntered(habbo); - if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) { + if (!habbo.getHabboStats().isNux() && (room.isOwner(habbo) || room.isPublicRoom())) { NewUserExperienceScriptProceedEvent.handle(habbo); } } @@ -924,13 +919,13 @@ public class RoomManager { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_enter_log (room_id, user_id, timestamp) VALUES(?, ?, ?)")) { statement.setInt(1, room.getId()); statement.setInt(2, habbo.getHabboInfo().getId()); - statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp)); + statement.setInt(3, (int) (habbo.getHabboStats().getRoomEnterTimestamp())); statement.execute(); if (!habbo.getHabboStats().visitedRoom(room.getId())) habbo.getHabboStats().addVisitRoom(room.getId()); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -983,7 +978,7 @@ public class RoomManager { statement.setInt(3, room.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -1030,7 +1025,7 @@ public class RoomManager { Collections.sort(rooms); - return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count))); + return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count)))); } public ArrayList getPopularRooms(int count, int category) { @@ -1048,7 +1043,7 @@ public class RoomManager { Collections.sort(rooms); - return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count))); + return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count)))); } public Map> getPopularRoomsByCategory(int count) { @@ -1072,7 +1067,7 @@ public class RoomManager { Collections.sort(set.getValue()); - result.put(set.getKey(), new ArrayList<>(set.getValue().subList(0, (set.getValue().size() < count ? set.getValue().size() : count)))); + result.put(set.getKey(), new ArrayList<>(set.getValue().subList(0, (Math.min(set.getValue().size(), count))))); } return result; @@ -1112,7 +1107,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -1123,7 +1118,7 @@ public class RoomManager { for (Room room : this.activeRooms.values()) { for (String s : room.getTags().split(";")) { - if (s.toLowerCase().equals(tag.toLowerCase())) { + if (s.equalsIgnoreCase(tag)) { rooms.add(room); break; } @@ -1172,7 +1167,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -1238,7 +1233,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1249,20 +1244,17 @@ public class RoomManager { public ArrayList getRoomsFavourite(Habbo habbo) { final ArrayList rooms = new ArrayList<>(); - habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() { - @Override - public boolean execute(int value) { - Room room = RoomManager.this.getRoom(value); + habbo.getHabboStats().getFavoriteRooms().forEach(value -> { + Room room = RoomManager.this.getRoom(value); - if (room != null) { - if (room.getState() == RoomState.INVISIBLE) { - room.loadData(); - if (!room.hasRights(habbo)) return true; - } - rooms.add(room); + if (room != null) { + if (room.getState() == RoomState.INVISIBLE) { + room.loadData(); + if (!room.hasRights(habbo)) return true; } - return true; + rooms.add(room); } + return true; }); return rooms; @@ -1284,7 +1276,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1307,7 +1299,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -1349,7 +1341,7 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; @@ -1371,13 +1363,13 @@ public class RoomManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return rooms; } - public ArrayList getRoomsInGroup(Habbo habbo) { + public ArrayList getRoomsInGroup() { return new ArrayList<>(); } @@ -1475,7 +1467,7 @@ public class RoomManager { this.activeRooms.clear(); - LOGGER.info("Room Manager -> Disposed!"); + log.info("Room Manager -> Disposed!"); } public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) { @@ -1492,7 +1484,7 @@ public class RoomManager { statement.setString(10, map); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return this.loadCustomLayout(room); @@ -1556,15 +1548,13 @@ public class RoomManager { return gameTypes; } + @Getter + @AllArgsConstructor public enum RoomBanTypes { RWUAM_BAN_USER_HOUR(60 * 60), RWUAM_BAN_USER_DAY(24 * 60 * 60), RWUAM_BAN_USER_PERM(10 * 365 * 24 * 60 * 60); - public int duration; - - RoomBanTypes(int duration) { - this.duration = duration; - } + private final int duration; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java index 54e12e6d..962183f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java @@ -1,42 +1,36 @@ package com.eu.habbo.habbohotel.rooms; -public class RoomMoodlightData { - private int id; - private boolean enabled; - private boolean backgroundOnly; - private String color; - private int intensity; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; - public RoomMoodlightData(int id, boolean enabled, boolean backgroundOnly, String color, int intensity) { - this.id = id; - this.enabled = enabled; - this.backgroundOnly = backgroundOnly; - this.color = color; - this.intensity = intensity; - } +@AllArgsConstructor +public class RoomMoodlightData { + @Getter + @Setter + private int id; + @Getter + private boolean enabled; + @Getter + @Setter + private boolean backgroundOnly; + @Setter + @Getter + private String color; + @Setter + @Getter + private int intensity; public static RoomMoodlightData fromString(String s) { String[] data = s.split(","); if (data.length == 5) { - return new RoomMoodlightData(Integer.valueOf(data[1]), data[0].equalsIgnoreCase("2"), data[2].equalsIgnoreCase("2"), data[3], Integer.valueOf(data[4])); + return new RoomMoodlightData(Integer.parseInt(data[1]), data[0].equalsIgnoreCase("2"), data[2].equalsIgnoreCase("2"), data[3], Integer.parseInt(data[4])); } else { return new RoomMoodlightData(1, true, true, "#000000", 255); } } - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public boolean isEnabled() { - return this.enabled; - } - public void enable() { this.enabled = true; } @@ -45,30 +39,6 @@ public class RoomMoodlightData { this.enabled = false; } - public boolean isBackgroundOnly() { - return this.backgroundOnly; - } - - public void setBackgroundOnly(boolean backgroundOnly) { - this.backgroundOnly = backgroundOnly; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public int getIntensity() { - return this.intensity; - } - - public void setIntensity(int intensity) { - this.intensity = intensity; - } - public String toString() { return (this.enabled ? 2 : 1) + "," + this.id + "," + (this.backgroundOnly ? 2 : 1) + "," + this.color + "," + this.intensity; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index f24e111a..e8bc4f23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -1,20 +1,27 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter +@Setter public class RoomPromotion { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomPromotion.class); + private final Room room; public boolean needsUpdate; + private String title; + private String description; + private int endTimestamp; private int startTimestamp; private int category; @@ -46,58 +53,15 @@ public class RoomPromotion { statement.setInt(4, this.room.getId()); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.needsUpdate = false; } } - public Room getRoom() { - return this.room; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public int getEndTimestamp() { - return this.endTimestamp; - } - - public void setEndTimestamp(int endTimestamp) { - this.endTimestamp = endTimestamp; - } - public void addEndTimestamp(int time) { this.endTimestamp += time; } - public int getStartTimestamp() { - return startTimestamp; - } - - public void setStartTimestamp(int startTimestamp) { - this.startTimestamp = startTimestamp; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightLevels.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightLevels.java index fef685a4..8157ad61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightLevels.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightLevels.java @@ -1,41 +1,23 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomRightLevels { - NONE(0), - - RIGHTS(1), - - GUILD_RIGHTS(2), - - GUILD_ADMIN(3), - - OWNER(4), - - MODERATOR(5), - - SIX(6), - - SEVEN(7), - - EIGHT(8), - - NINE(9); - public final int level; - - RoomRightLevels(int level) { - this.level = level; - } + private final int level; public boolean equals(RoomRightLevels level) { return this.level == level.level; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java index ab135ebf..3ce54325 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -504,7 +504,7 @@ public class RoomSpecialTypes { for (Map.Entry set : this.gameScoreboards.entrySet()) { if (set.getValue() instanceof InteractionFreezeScoreboard) { - if (((InteractionFreezeScoreboard) set.getValue()).teamColor.equals(teamColor)) + if (set.getValue().teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionFreezeScoreboard) set.getValue()); } } @@ -533,7 +533,7 @@ public class RoomSpecialTypes { for (Map.Entry set : this.gameScoreboards.entrySet()) { if (set.getValue() instanceof InteractionBattleBanzaiScoreboard) { - if (((InteractionBattleBanzaiScoreboard) set.getValue()).teamColor.equals(teamColor)) + if (set.getValue().teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionBattleBanzaiScoreboard) set.getValue()); } } @@ -562,7 +562,7 @@ public class RoomSpecialTypes { for (Map.Entry set : this.gameScoreboards.entrySet()) { if (set.getValue() instanceof InteractionFootballScoreboard) { - if (((InteractionFootballScoreboard) set.getValue()).teamColor.equals(teamColor)) + if (set.getValue().teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionFootballScoreboard) set.getValue()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java index d6962bfd..eda3e0b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomState { OPEN(0), LOCKED(1), @@ -8,11 +13,5 @@ public enum RoomState { private final int state; - RoomState(int state) { - this.state = state; - } - public int getState() { - return this.state; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 574dfa0c..cea73922 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -2,20 +2,30 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.items.Item; import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; import java.util.ArrayList; import java.util.List; public class RoomTile { - public final short x; - public final short y; - public final short z; + @Getter + private final short x; + @Getter + private final short y; + @Getter + private final short z; private final THashSet units; - public RoomTileState state; + @Setter + @Getter + private RoomTileState state; private double stackHeight; private boolean allowStack = true; + @Getter + @Setter private RoomTile previous = null; private boolean diagonally; + @Getter private short gCosts; private short hCosts; @@ -47,8 +57,7 @@ public class RoomTile { this.units = tile.units; } - public RoomTile() - { + public RoomTile() { x = 0; y = 0; z = 0; @@ -124,22 +133,10 @@ public class RoomTile { this.diagonally = isDiagonally; } - public RoomTile getPrevious() { - return this.previous; - } - - public void setPrevious(RoomTile previous) { - this.previous = previous; - } - public int getfCosts() { return this.gCosts + this.hCosts; } - public int getgCosts() { - return this.gCosts; - } - public void setgCosts(RoomTile previousRoomTile) { this.setgCosts(previousRoomTile, this.diagonally ? RoomLayout.DIAGONALMOVEMENTCOST : RoomLayout.BASICMOVEMENTCOST); } @@ -149,15 +146,15 @@ public class RoomTile { } void setgCosts(RoomTile previousRoomTile, int basicCost) { - this.setgCosts((short) (previousRoomTile.getgCosts() + basicCost)); + this.setgCosts((short) (previousRoomTile.getGCosts() + basicCost)); } public int calculategCosts(RoomTile previousRoomTile) { if (this.diagonally) { - return previousRoomTile.getgCosts() + 14; + return previousRoomTile.getGCosts() + 14; } - return previousRoomTile.getgCosts() + 10; + return previousRoomTile.getGCosts() + 10; } public void sethCosts(RoomTile parent) { @@ -172,14 +169,6 @@ public class RoomTile { return this.state == RoomTileState.OPEN; } - public RoomTileState getState() { - return this.state; - } - - public void setState(RoomTileState state) { - this.state = state; - } - public boolean is(short x, short y) { return this.x == x && this.y == y; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 769db3ad..a6231fa3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -4,33 +4,31 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.MessageComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.messages.outgoing.trading.*; import com.eu.habbo.plugin.events.trading.TradeConfirmEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.ArrayList; import java.util.List; + +@Slf4j public class RoomTrade { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomTrade.class); //Configuration. Loaded from database & updated accordingly. public static boolean TRADING_ENABLED = true; public static boolean TRADING_REQUIRES_PERK = true; private final List users; private final Room room; - private boolean tradeCompleted; public RoomTrade(Habbo userOne, Habbo userTwo, Room room) { this.users = new ArrayList<>(); - this.tradeCompleted = false; this.users.add(new RoomTradeUser(userOne)); this.users.add(new RoomTradeUser(userTwo)); @@ -104,8 +102,10 @@ public class RoomTrade { this.sendMessageToUsers(new TradingAcceptComposer(user)); boolean accepted = true; for (RoomTradeUser roomTradeUser : this.users) { - if (!roomTradeUser.getAccepted()) + if (!roomTradeUser.isAccepted()) { accepted = false; + break; + } } if (accepted) { this.sendMessageToUsers(new TradingConfirmationComposer()); @@ -120,8 +120,10 @@ public class RoomTrade { this.sendMessageToUsers(new TradingAcceptComposer(user)); boolean accepted = true; for (RoomTradeUser roomTradeUser : this.users) { - if (!roomTradeUser.getConfirmed()) + if (!roomTradeUser.isConfirmed()) { accepted = false; + break; + } } if (accepted) { if (this.tradeItems()) { @@ -216,7 +218,7 @@ public class RoomTrade { statement.executeBatch(); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } THashSet itemsUserOne = new THashSet<>(userOne.getItems()); @@ -327,10 +329,12 @@ public class RoomTrade { } public static int getCreditsByItem(HabboItem item) { + if (!Emulator.getConfig().getBoolean("redeem.currency.trade")) return 0; + if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0; try { - return Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + return Integer.parseInt(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { return 0; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java index 6b222e32..5fb7f103 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java @@ -3,12 +3,20 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; public class RoomTradeUser { + @Getter private final Habbo habbo; private final THashSet items; + @Setter + @Getter private int userId; + @Setter + @Getter private boolean accepted; + @Getter private boolean confirmed; public RoomTradeUser(Habbo habbo) { @@ -23,30 +31,6 @@ public class RoomTradeUser { this.items = new THashSet<>(); } - public int getUserId() { - return this.userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public Habbo getHabbo() { - return this.habbo; - } - - public boolean getAccepted() { - return this.accepted; - } - - public void setAccepted(boolean value) { - this.accepted = value; - } - - public boolean getConfirmed() { - return this.confirmed; - } - public void confirm() { this.confirmed = true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index c668ee80..6cf0b69a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -22,18 +22,16 @@ import com.eu.habbo.util.pathfinding.Rotation; import gnu.trove.map.TMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.stream.Collectors; +@Slf4j public class RoomUnit { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnit.class); - public boolean isWiredTeleporting = false; public boolean isLeavingTeleporter = false; public boolean isSwimming = false; @@ -62,7 +60,6 @@ public class RoomUnit { private boolean fastWalk = false; private boolean statusUpdate = false; private boolean invisible = false; - private boolean lastCycleStatus = false; private boolean canLeaveRoomByDoor = true; private RoomUserRotation bodyRotation = RoomUserRotation.NORTH; private RoomUserRotation headRotation = RoomUserRotation.NORTH; @@ -82,7 +79,7 @@ public class RoomUnit { private int idleTimer; private Room room; private RoomRightLevels rightsLevel = RoomRightLevels.NONE; - private THashSet overridableTiles; + private final THashSet overridableTiles; public RoomUnit() { this.id = 0; @@ -136,8 +133,8 @@ public class RoomUnit { this.status.remove(RoomUnitStatus.MOVE); } - if (rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) { - this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().x + "," + rider.getRoomUnit().getCurrentLocation().y + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight())); + if (rider.getRoomUnit().getCurrentLocation().getX() != this.getX() || rider.getRoomUnit().getCurrentLocation().getY() != this.getY()) { + this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().getX() + "," + rider.getRoomUnit().getCurrentLocation().getY() + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight())); this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation()); this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight()); this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation()); @@ -164,7 +161,7 @@ public class RoomUnit { if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true; for (Map.Entry set : this.status.entrySet()) { - if (set.getKey().removeWhenWalking) { + if (set.getKey().isRemoveWhenWalking()) { this.status.remove(set.getKey()); } } @@ -244,12 +241,12 @@ public class RoomUnit { } } - HabboItem item = room.getTopItemAt(next.x, next.y); + HabboItem item = room.getTopItemAt(next.getX(), next.getY()); //if(!(this.path.size() == 0 && canSitNextTile)) { double height = next.getStackHeight() - this.currentLocation.getStackHeight(); - if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.state == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.room = room; this.path.clear(); this.findPath(); @@ -258,12 +255,12 @@ public class RoomUnit { this.status.remove(RoomUnitStatus.MOVE); return false; } - next = (RoomTile) this.path.pop(); + next = this.path.pop(); } } - boolean canSitNextTile = room.canSitAt(next.x, next.y); + boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); if (canSitNextTile) { HabboItem tallestChair = room.getTallestChair(next); @@ -272,7 +269,7 @@ public class RoomUnit { item = tallestChair; } - if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) { + if (next.equals(this.goalLocation) && next.getState() == RoomTileState.SIT && !overrideChecks) { if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT) { this.status.remove(RoomUnitStatus.MOVE); return false; @@ -294,14 +291,14 @@ public class RoomUnit { HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY()); if (habboItem != null) { - if (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.x, next.y)) + if (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.getX(), next.getY())) habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next}); } this.tilesWalked++; RoomUserRotation oldRotation = this.getBodyRotation(); - this.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]); + this.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]); if (item != null) { if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { if (item.canWalkOn(this, room, null)) { @@ -328,13 +325,13 @@ public class RoomUnit { zHeight += Item.getCurrentHeight(item); } } else { - zHeight += room.getLayout().getHeightAtSquare(next.x, next.y); + zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); } this.setPreviousLocation(this.getCurrentLocation()); - this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight); + this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); if (habbo != null) { if (habbo.getHabboInfo().getRiding() != null) { RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit(); @@ -342,10 +339,10 @@ public class RoomUnit { if (ridingUnit != null) { ridingUnit.setPreviousLocationZ(this.getZ()); this.setZ(zHeight - 1.0); - ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]); + ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]); ridingUnit.setPreviousLocation(this.getCurrentLocation()); ridingUnit.setGoalLocation(this.getGoal()); - ridingUnit.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + (zHeight - 1.0)); + ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); room.sendComposer(new UserUpdateComposer(ridingUnit).compose()); //ridingUnit.setZ(zHeight - 1.0); } @@ -354,13 +351,13 @@ public class RoomUnit { //room.sendComposer(new RoomUserStatusComposer(this).compose()); this.setZ(zHeight); - this.setCurrentLocation(room.getLayout().getTile(next.x, next.y)); + this.setCurrentLocation(room.getLayout().getTile(next.getX(), next.getY())); this.resetIdleTimer(); if (habbo != null) { - HabboItem topItem = room.getTopItemAt(next.x, next.y); + HabboItem topItem = room.getTopItemAt(next.getX(), next.getY()); - boolean isAtDoor = next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY(); + boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); boolean invalidated = topItem != null && topItem.invalidatesToRoomKick(); @@ -372,7 +369,7 @@ public class RoomUnit { return false; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return false; } } @@ -400,11 +397,11 @@ public class RoomUnit { } public short getX() { - return this.currentLocation.x; + return this.currentLocation.getX(); } public short getY() { - return this.currentLocation.y; + return this.currentLocation.getY(); } public double getZ() { @@ -559,7 +556,7 @@ public class RoomUnit { } public void findPath() { - if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) { + if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.getX(), this.goalLocation.getY()) || this.canOverrideTile(this.goalLocation))) { Deque path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); if (path != null) this.path = path; } @@ -707,10 +704,10 @@ public class RoomUnit { } if (!this.status.containsKey(RoomUnitStatus.SIT)) { - this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); + this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.getX(), location.getY())]); } - RoomUserRotation rotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); + RoomUserRotation rotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.getX(), location.getY())]); if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) { this.headRotation = rotation; @@ -755,12 +752,12 @@ public class RoomUnit { if (room.getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, room, tile))) return true; - int tileIndex = (tile.x & 0xFF) | (tile.y << 12); + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); return this.overridableTiles.contains(tileIndex); } public void addOverrideTile(RoomTile tile) { - int tileIndex = (tile.x & 0xFF) | (tile.y << 12); + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); if (!this.overridableTiles.contains(tileIndex)) { this.overridableTiles.add(tileIndex); } @@ -769,7 +766,7 @@ public class RoomUnit { public void removeOverrideTile(RoomTile tile) { if (room == null || room.getLayout() == null) return; - int tileIndex = (tile.x & 0xFF) | (tile.y << 12); + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); this.overridableTiles.remove(tileIndex); } @@ -790,7 +787,7 @@ public class RoomUnit { HabboItem topItem = this.room.getTopItemAt(this.getX(), this.getY()); - return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); + return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); } public RoomTile getClosestTile(List tiles) { @@ -819,9 +816,9 @@ public class RoomUnit { return this.getClosestTile( rotations.stream() - .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) - .filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y))) - .collect(Collectors.toList()) + .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) + .filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.getX(), t.getY()))) + .collect(Collectors.toList()) ); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java index 3be40d28..5a95cd3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomUnitEffect { //(\w+)\s(\w+)\s(\w+) //\2\(\1\), @@ -204,11 +209,8 @@ public enum RoomUnitEffect { YELLOWDUCK(198), FLYNGTURTLE(199); - private int id; + private final int id; - RoomUnitEffect(int id) { - this.id = id; - } public static RoomUnitEffect fromId(int id) { for (RoomUnitEffect effect : RoomUnitEffect.values()) { @@ -219,8 +221,4 @@ public enum RoomUnitEffect { return RoomUnitEffect.NONE; } - - public int getId() { - return this.id; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java index 8ff934a6..c77c6326 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomUnitStatus { MOVE("mv", true), @@ -81,18 +86,14 @@ public enum RoomUnitStatus { GROW_6("grw6"), GROW_7("grw7"); - public final String key; - public final boolean removeWhenWalking; + private final String key; + private final boolean removeWhenWalking; RoomUnitStatus(String key) { this.key = key; this.removeWhenWalking = false; } - RoomUnitStatus(String key, boolean removeWhenWalking) { - this.key = key; - this.removeWhenWalking = removeWhenWalking; - } public static RoomUnitStatus fromString(String key) { for (RoomUnitStatus status : values()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java index 83d39029..c12f7a61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomUnitType { USER(1), BOT(4), @@ -8,11 +13,4 @@ public enum RoomUnitType { private final int typeId; - RoomUnitType(int typeId) { - this.typeId = typeId; - } - - public int getTypeId() { - return this.typeId; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java index 03f257b9..12275146 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomUserAction { NONE(0), WAVE(1), @@ -12,9 +17,6 @@ public enum RoomUserAction { private final int action; - RoomUserAction(int action) { - this.action = action; - } public static RoomUserAction fromValue(int value) { for (RoomUserAction action : RoomUserAction.values()) { @@ -25,8 +27,4 @@ public enum RoomUserAction { return NONE; } - - public int getAction() { - return this.action; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java index 11f9f775..624afe34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.rooms; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum RoomUserRotation { NORTH(0), NORTH_EAST(1), @@ -12,9 +17,6 @@ public enum RoomUserRotation { private final int direction; - RoomUserRotation(int direction) { - this.direction = direction; - } public static RoomUserRotation fromValue(int rotation) { rotation %= 8; @@ -40,24 +42,15 @@ public enum RoomUserRotation { } public RoomUserRotation getOpposite() { - switch (this) { - case NORTH: - return RoomUserRotation.SOUTH; - case NORTH_EAST: - return RoomUserRotation.SOUTH_WEST; - case EAST: - return RoomUserRotation.WEST; - case SOUTH_EAST: - return RoomUserRotation.NORTH_WEST; - case SOUTH: - return RoomUserRotation.NORTH; - case SOUTH_WEST: - return RoomUserRotation.NORTH_EAST; - case WEST: - return RoomUserRotation.EAST; - case NORTH_WEST: - return RoomUserRotation.SOUTH_EAST; - } - return null; + return switch (this) { + case NORTH -> RoomUserRotation.SOUTH; + case NORTH_EAST -> RoomUserRotation.SOUTH_WEST; + case EAST -> RoomUserRotation.WEST; + case SOUTH_EAST -> RoomUserRotation.NORTH_WEST; + case SOUTH -> RoomUserRotation.NORTH; + case SOUTH_WEST -> RoomUserRotation.NORTH_EAST; + case WEST -> RoomUserRotation.EAST; + case NORTH_WEST -> RoomUserRotation.SOUTH_EAST; + }; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 76e2cd55..1982f52e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -17,9 +17,8 @@ import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.NowPlayingMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; -import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -29,12 +28,12 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +@Slf4j public class TraxManager implements Disposable { public static int NORMAL_JUKEBOX_LIMIT = 10; public static int LARGE_JUKEBOX_LIMIT = 20; - - private static final Logger LOGGER = LoggerFactory.getLogger(TraxManager.class); private final Room room; + @Getter private InteractionJukeBox jukeBox; private final List songs = new ArrayList<>(0); private int totalLength = 0; @@ -43,6 +42,7 @@ public class TraxManager implements Disposable { private int playingIndex = 0; private int cycleStartedTimestamp = 0; private Habbo starter = null; + @Getter private int songsLimit = 0; private boolean disposed = false; @@ -85,7 +85,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return null; @@ -117,7 +117,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -127,7 +127,7 @@ public class TraxManager implements Disposable { statement.setInt(2, song_id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -138,8 +138,9 @@ public class TraxManager implements Disposable { statement_1.setInt(1, this.room.getId()); statement_1.setInt(2, jukeBox.getId()); statement_1.execute(); - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + } + catch (SQLException e) { + log.error("Caught SQL exception", e); return; } @@ -154,8 +155,9 @@ public class TraxManager implements Disposable { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement_1 = connection.prepareStatement("DELETE FROM room_trax WHERE room_id = ?")) { statement_1.setInt(1, this.room.getId()); statement_1.execute(); - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + } + catch (SQLException e) { + log.error("Caught SQL exception", e); return; } @@ -238,8 +240,8 @@ public class TraxManager implements Disposable { public void addSong(InteractionMusicDisc musicDisc, Habbo habbo) { if (this.jukeBox == null) return; - if (this.songsLimit < this.songs.size() + 1) { - THashMap codes = new THashMap<>(); + if(this.songsLimit < this.songs.size() + 1) + { ServerMessage msg = new NotificationDialogMessageComposer("${playlist.editor.alert.playlist.full.title}", "${playlist.editor.alert.playlist.full}").compose(); habbo.getClient().sendResponse(msg); return; @@ -256,7 +258,7 @@ public class TraxManager implements Disposable { statement.setInt(2, musicDisc.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return; } @@ -340,7 +342,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -416,14 +418,6 @@ public class TraxManager implements Disposable { return this.currentlyPlaying != null; } - public int getSongsLimit() { - return this.songsLimit; - } - - public InteractionJukeBox getJukeBox() { - return this.jukeBox; - } - @Override public void dispose() { this.disposed = true; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java b/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java index 45097b6d..79b91fb5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.users; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum DanceType { NONE(0), HAB_HOP(1), @@ -8,12 +13,4 @@ public enum DanceType { THE_ROLLIE(4); private final int type; - - DanceType(int type) { - this.type = type; - } - - public int getType() { - return this.type; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index d91661b6..47e1811f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.catalog.ClothItem; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.pets.Pet; @@ -21,8 +22,9 @@ import com.eu.habbo.plugin.events.users.UserPointsEvent; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -30,15 +32,21 @@ import java.sql.ResultSet; import java.util.*; import java.util.stream.Collectors; +@Slf4j public class Habbo implements Runnable { - - private static final Logger LOGGER = LoggerFactory.getLogger(Habbo.class); - + @Getter private final HabboInfo habboInfo; + @Getter private final HabboStats habboStats; + @Getter private final Messenger messenger; - private final HabboInventory habboInventory; + @Getter + private final HabboInventory inventory; + @Setter + @Getter private GameClient client; + @Setter + @Getter private RoomUnit roomUnit; private volatile boolean update; @@ -49,7 +57,7 @@ public class Habbo implements Runnable { this.client = null; this.habboInfo = new HabboInfo(set); this.habboStats = HabboStats.load(this.habboInfo); - this.habboInventory = new HabboInventory(this); + this.inventory = new HabboInventory(this); this.messenger = new Messenger(); this.messenger.loadFriends(this); @@ -82,38 +90,6 @@ public class Habbo implements Runnable { return this.update; } - public Messenger getMessenger() { - return this.messenger; - } - - public HabboInfo getHabboInfo() { - return this.habboInfo; - } - - public HabboStats getHabboStats() { - return this.habboStats; - } - - public HabboInventory getInventory() { - return this.habboInventory; - } - - public RoomUnit getRoomUnit() { - return this.roomUnit; - } - - public void setRoomUnit(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } - - public GameClient getClient() { - return this.client; - } - - public void setClient(GameClient client) { - this.client = client; - } - public boolean connect() { String ip = ""; @@ -144,13 +120,13 @@ public class Habbo implements Runnable { this.habboInfo.setMachineID(this.client.getMachineId()); this.isOnline(true); - this.habboStats.cache.put("previousOnline", this.habboInfo.getLastOnline()); + this.habboStats.getCache().put("previousOnline", this.habboInfo.getLastOnline()); this.habboInfo.setLastOnline(Emulator.getIntUnixTimestamp()); this.messenger.connectionChanged(this, true, false); Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); - LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); + log.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); return true; } @@ -177,7 +153,7 @@ public class Habbo implements Runnable { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { @@ -193,13 +169,13 @@ public class Habbo implements Runnable { this.habboStats.dispose(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return; } finally { Emulator.getGameEnvironment().getRoomManager().unloadRoomsForHabbo(this); Emulator.getGameEnvironment().getHabboManager().removeHabbo(this); } - LOGGER.info("{} disconnected.", this.habboInfo.getUsername()); + log.info("{} disconnected.", this.habboInfo.getUsername()); this.client = null; } @@ -270,7 +246,7 @@ public class Habbo implements Runnable { public void whisper(String message) { - this.whisper(message, this.habboStats.chatColor); + this.whisper(message, this.habboStats.getChatColor()); } @@ -282,7 +258,7 @@ public class Habbo implements Runnable { public void talk(String message) { - this.talk(message, this.habboStats.chatColor); + this.talk(message, this.habboStats.getChatColor()); } @@ -294,7 +270,7 @@ public class Habbo implements Runnable { public void shout(String message) { - this.shout(message, this.habboStats.chatColor); + this.shout(message, this.habboStats.getChatColor()); } @@ -330,33 +306,33 @@ public class Habbo implements Runnable { public void addFurniture(HabboItem item) { - this.habboInventory.getItemsComponent().addItem(item); + this.inventory.getItemsComponent().addItem(item); this.client.sendResponse(new UnseenItemsComposer(item)); this.client.sendResponse(new FurniListInvalidateComposer()); } public void addFurniture(THashSet items) { - this.habboInventory.getItemsComponent().addItems(items); + this.inventory.getItemsComponent().addItems(items); this.client.sendResponse(new UnseenItemsComposer(items)); this.client.sendResponse(new FurniListInvalidateComposer()); } public void removeFurniture(HabboItem item) { - this.habboInventory.getItemsComponent().removeHabboItem(item); + this.inventory.getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getId())); } public void addBot(Bot bot) { - this.habboInventory.getBotsComponent().addBot(bot); + this.inventory.getBotsComponent().addBot(bot); this.client.sendResponse(new BotAddedToInventoryComposer(bot)); } public void removeBot(Bot bot) { - this.habboInventory.getBotsComponent().removeBot(bot); + this.inventory.getBotsComponent().removeBot(bot); this.client.sendResponse(new BotRemovedFromInventoryComposer(bot)); } @@ -369,21 +345,21 @@ public class Habbo implements Runnable { public void addPet(Pet pet) { - this.habboInventory.getPetsComponent().addPet(pet); + this.inventory.getPetsComponent().addPet(pet); this.client.sendResponse(new PetAddedToInventoryComposer(pet)); } public void removePet(Pet pet) { - this.habboInventory.getPetsComponent().removePet(pet); + this.inventory.getPetsComponent().removePet(pet); this.client.sendResponse(new PetRemovedFromInventoryComposer(pet)); } public boolean addBadge(String code) { - if (!this.habboInventory.getBadgesComponent().hasBadge(code)) { + if (!this.inventory.getBadgesComponent().hasBadge(code)) { HabboBadge badge = BadgesComponent.createBadge(code, this); - this.habboInventory.getBadgesComponent().addBadge(badge); + this.inventory.getBadgesComponent().addBadge(badge); this.client.sendResponse(new BadgeReceivedComposer(badge)); this.client.sendResponse(new UnseenItemsComposer(badge.getId(), UnseenItemsComposer.AddHabboItemCategory.BADGE)); @@ -391,7 +367,7 @@ public class Habbo implements Runnable { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys)); return true; } @@ -402,7 +378,7 @@ public class Habbo implements Runnable { public void deleteBadge(HabboBadge badge) { if (badge != null) { - this.habboInventory.getBadgesComponent().removeBadge(badge); + this.inventory.getBadgesComponent().removeBadge(badge); BadgesComponent.deleteBadge(this.getHabboInfo().getId(), badge.getCode()); this.client.sendResponse(new BadgesComposer(this)); } @@ -410,7 +386,7 @@ public class Habbo implements Runnable { public void mute(int seconds, boolean isFlood) { if (seconds <= 0) { - LOGGER.warn("Tried to mute user for {} seconds, which is invalid.", seconds); + log.warn("Tried to mute user for {} seconds, which is invalid.", seconds); return; } @@ -444,7 +420,7 @@ public class Habbo implements Runnable { public void clearCaches() { int timestamp = Emulator.getIntUnixTimestamp(); THashMap> newLog = new THashMap<>(); - for (Map.Entry> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) { + for (Map.Entry> ltdLog : this.habboStats.getLtdPurchaseLog().entrySet()) { for (Integer time : ltdLog.getValue()) { if (time > timestamp) { if (!newLog.containsKey(ltdLog.getKey())) { @@ -456,15 +432,15 @@ public class Habbo implements Runnable { } } - this.habboStats.ltdPurchaseLog = newLog; + this.habboStats.setLtdPurchaseLog(newLog); } public void respect(Habbo target) { if (target != null && target != this.client.getHabbo()) { - target.getHabboStats().respectPointsReceived++; - this.client.getHabbo().getHabboStats().respectPointsGiven++; - this.client.getHabbo().getHabboStats().respectPointsToGive--; + target.getHabboStats().setRespectPointsReceived(target.getHabboStats().getRespectPointsReceived()+1); + this.client.getHabbo().getHabboStats().setRespectPointsGiven(this.client.getHabbo().getHabboStats().getRespectPointsGiven()+1); + this.client.getHabbo().getHabboStats().setRespectPointsToGive(this.client.getHabbo().getHabboStats().getRespectPointsToGive()-1); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRespectComposer(target).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ExpressionMessageComposer(this.client.getHabbo().getRoomUnit(), RoomUserAction.THUMB_UP).compose()); @@ -480,8 +456,8 @@ public class Habbo implements Runnable { TIntCollection clothingIDs = this.getInventory().getWardrobeComponent().getClothing(); return Emulator.getGameEnvironment().getCatalogManager().clothing.values().stream() - .filter(c -> !clothingIDs.contains(c.id)) - .map(c -> c.setId) + .filter(c -> !clothingIDs.contains(c.getId())) + .map(ClothItem::getSetId) .flatMap(c -> Arrays.stream(c).boxed()) .collect(Collectors.toSet()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 5903cdc5..e3280894 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -1,15 +1,21 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j public class HabboBadge implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboBadge.class); + @Getter private int id; + @Setter + @Getter private String code; + @Setter + @Getter private int slot; private Habbo habbo; private boolean needsUpdate; @@ -33,26 +39,6 @@ public class HabboBadge implements Runnable { this.needsInsert = true; } - public int getId() { - return this.id; - } - - public String getCode() { - return this.code; - } - - public void setCode(String code) { - this.code = code; - } - - public int getSlot() { - return this.slot; - } - - public void setSlot(int slot) { - this.slot = slot; - } - @Override public void run() { try { @@ -80,7 +66,7 @@ public class HabboBadge implements Runnable { this.needsUpdate = false; } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index b2f6e9f2..92cd5932 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -14,46 +14,71 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import gnu.trove.map.hash.TIntIntHashMap; -import gnu.trove.procedure.TIntIntProcedure; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.ArrayList; import java.util.List; +@Slf4j +@Getter public class HabboInfo implements Runnable { - - private static final Logger LOGGER = LoggerFactory.getLogger(HabboInfo.class); - + public boolean firstVisit = false; + @Setter private String username; + @Setter private String motto; + @Setter private String look; + @Setter private HabboGender gender; + @Setter private String mail; + @Setter private String sso; + @Setter private String ipRegister; + @Setter private String ipLogin; private int id; + @Setter private int accountCreated; + @Setter private Rank rank; private int credits; + @Setter private int lastOnline; + @Setter private int homeRoom; + @Setter private boolean online; + @Setter private int loadingRoom; + @Setter private Room currentRoom; + @Setter private int roomQueueId; + @Setter private RideablePet riding; + @Setter private Class currentGame; private TIntIntHashMap currencies; + @Setter private GamePlayer gamePlayer; + @Setter private int photoRoomId; + @Setter private int photoTimestamp; + @Setter private String photoURL; + @Setter private String photoJSON; + @Setter private int webPublishTimestamp; + @Setter private String machineID; private List savedSearches = new ArrayList<>(); private List messengerCategories = new ArrayList<>(); @@ -72,8 +97,8 @@ public class HabboInfo implements Runnable { this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(set.getInt("rank")); if (this.rank == null) { - LOGGER.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); - LOGGER.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + log.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(1); } @@ -85,7 +110,7 @@ public class HabboInfo implements Runnable { this.online = false; this.currentRoom = null; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.loadCurrencies(); @@ -104,30 +129,27 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } private void saveCurrencies() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_currency (user_id, type, amount) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = ?")) { - this.currencies.forEachEntry(new TIntIntProcedure() { - @Override - public boolean execute(int a, int b) { - try { - statement.setInt(1, HabboInfo.this.getId()); - statement.setInt(2, a); - statement.setInt(3, b); - statement.setInt(4, b); - statement.addBatch(); - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - } - return true; + this.currencies.forEachEntry((a, b) -> { + try { + statement.setInt(1, HabboInfo.this.getId()); + statement.setInt(2, a); + statement.setInt(3, b); + statement.setInt(4, b); + statement.addBatch(); + } catch (SQLException e) { + log.error("Caught SQL exception", e); } + return true; }); statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -142,7 +164,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -167,7 +189,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -178,7 +200,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, search.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -193,7 +215,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -217,7 +239,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -228,7 +250,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, category.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -250,98 +272,10 @@ public class HabboInfo implements Runnable { this.run(); } - public int getId() { - return this.id; - } - - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getMotto() { - return this.motto; - } - - public void setMotto(String motto) { - this.motto = motto; - } - - public Rank getRank() { - return this.rank; - } - - public void setRank(Rank rank) { - this.rank = rank; - } - - public String getLook() { - return this.look; - } - - public void setLook(String look) { - this.look = look; - } - - public HabboGender getGender() { - return this.gender; - } - - public void setGender(HabboGender gender) { - this.gender = gender; - } - - public String getMail() { - return this.mail; - } - - public void setMail(String mail) { - this.mail = mail; - } - - public String getSso() { - return this.sso; - } - - public void setSso(String sso) { - this.sso = sso; - } - - public String getIpRegister() { - return this.ipRegister; - } - - public void setIpRegister(String ipRegister) { - this.ipRegister = ipRegister; - } - - public String getIpLogin() { - return this.ipLogin; - } - - public void setIpLogin(String ipLogin) { - this.ipLogin = ipLogin; - } - - public int getAccountCreated() { - return this.accountCreated; - } - - public void setAccountCreated(int accountCreated) { - this.accountCreated = accountCreated; - } - public boolean canBuy(CatalogItem item) { return this.credits >= item.getCredits() && this.getCurrencies().get(item.getPointsType()) >= item.getPoints(); } - public int getCredits() { - return this.credits; - } - public void setCredits(int credits) { this.credits = credits; this.run(); @@ -366,62 +300,6 @@ public class HabboInfo implements Runnable { this.run(); } - public int getLastOnline() { - return this.lastOnline; - } - - public void setLastOnline(int lastOnline) { - this.lastOnline = lastOnline; - } - - public int getHomeRoom() { - return this.homeRoom; - } - - public void setHomeRoom(int homeRoom) { - this.homeRoom = homeRoom; - } - - public boolean isOnline() { - return this.online; - } - - public void setOnline(boolean value) { - this.online = value; - } - - public int getLoadingRoom() { - return this.loadingRoom; - } - - public void setLoadingRoom(int loadingRoom) { - this.loadingRoom = loadingRoom; - } - - public Room getCurrentRoom() { - return this.currentRoom; - } - - public void setCurrentRoom(Room room) { - this.currentRoom = room; - } - - public int getRoomQueueId() { - return this.roomQueueId; - } - - public void setRoomQueueId(int roomQueueId) { - this.roomQueueId = roomQueueId; - } - - public RideablePet getRiding() { - return this.riding; - } - - public void setRiding(RideablePet riding) { - this.riding = riding; - } - public void dismountPet() { this.dismountPet(false); } @@ -460,80 +338,10 @@ public class HabboInfo implements Runnable { roomUnit.statusUpdate(true); } - public Class getCurrentGame() { - return this.currentGame; - } - - public void setCurrentGame(Class currentGame) { - this.currentGame = currentGame; - } - public boolean isInGame() { return this.currentGame != null; } - public synchronized GamePlayer getGamePlayer() { - return this.gamePlayer; - } - - public synchronized void setGamePlayer(GamePlayer gamePlayer) { - this.gamePlayer = gamePlayer; - } - - public int getPhotoRoomId() { - return this.photoRoomId; - } - - public void setPhotoRoomId(int roomId) { - this.photoRoomId = roomId; - } - - public int getPhotoTimestamp() { - return this.photoTimestamp; - } - - public void setPhotoTimestamp(int photoTimestamp) { - this.photoTimestamp = photoTimestamp; - } - - public String getPhotoURL() { - return this.photoURL; - } - - public void setPhotoURL(String photoURL) { - this.photoURL = photoURL; - } - - public String getPhotoJSON() { - return this.photoJSON; - } - - public void setPhotoJSON(String photoJSON) { - this.photoJSON = photoJSON; - } - - public int getWebPublishTimestamp() { - return this.webPublishTimestamp; - } - - public void setWebPublishTimestamp(int webPublishTimestamp) { - this.webPublishTimestamp = webPublishTimestamp; - } - - public String getMachineID() { - return this.machineID; - } - - public void setMachineID(String machineID) { - this.machineID = machineID; - } - - public List getSavedSearches() { - return this.savedSearches; - } - - public List getMessengerCategories() { return this.messengerCategories; } - @Override public void run() { this.saveCurrencies(); @@ -554,7 +362,7 @@ public class HabboInfo implements Runnable { statement.setInt(13, this.id); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java index 7eaf048d..9ac0e796 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -5,13 +5,14 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceState; import com.eu.habbo.habbohotel.users.inventory.*; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@Getter +@Setter public class HabboInventory { - - private static final Logger LOGGER = LoggerFactory.getLogger(HabboInventory.class); - //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ITEMS = 10000; private final THashSet items; @@ -28,89 +29,43 @@ public class HabboInventory { try { this.badgesComponent = new BadgesComponent(this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.botsComponent = new BotsComponent(this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.effectsComponent = new EffectsComponent(this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.itemsComponent = new ItemsComponent(this, this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.petsComponent = new PetsComponent(this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } try { this.wardrobeComponent = new WardrobeComponent(this.habbo); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.items = MarketPlace.getOwnOffers(this.habbo); } - public WardrobeComponent getWardrobeComponent() { - return this.wardrobeComponent; - } - public void setWardrobeComponent(WardrobeComponent wardrobeComponent) { - this.wardrobeComponent = wardrobeComponent; - } - - public BadgesComponent getBadgesComponent() { - return this.badgesComponent; - } - - public void setBadgesComponent(BadgesComponent badgesComponent) { - this.badgesComponent = badgesComponent; - } - - public BotsComponent getBotsComponent() { - return this.botsComponent; - } - - public void setBotsComponent(BotsComponent botsComponent) { - this.botsComponent = botsComponent; - } - - public EffectsComponent getEffectsComponent() { - return this.effectsComponent; - } - - public void setEffectsComponent(EffectsComponent effectsComponent) { - this.effectsComponent = effectsComponent; - } - - public ItemsComponent getItemsComponent() { - return this.itemsComponent; - } - - public void setItemsComponent(ItemsComponent itemsComponent) { - this.itemsComponent = itemsComponent; - } - - public PetsComponent getPetsComponent() { - return this.petsComponent; - } - - public void setPetsComponent(PetsComponent petsComponent) { - this.petsComponent = petsComponent; - } public void dispose() { this.badgesComponent.dispose(); @@ -161,7 +116,4 @@ public class HabboInventory { return null; } - public Habbo getHabbo() { - return this.habbo; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index 380e4f9c..21e727bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -19,10 +19,11 @@ import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.eu.habbo.messages.outgoing.users.FigureUpdateComposer; import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.math3.util.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -33,28 +34,45 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +@Slf4j public abstract class HabboItem implements Runnable, IEventTriggers { - - private static final Logger LOGGER = LoggerFactory.getLogger(HabboItem.class); - - private static Class[] TOGGLING_INTERACTIONS = new Class[]{ + + private static final Class[] TOGGLING_INTERACTIONS = new Class[]{ InteractionGameTimer.class, InteractionWired.class, InteractionWiredHighscore.class, InteractionMultiHeight.class }; - private int id; + @Getter + private final int id; + @Getter + @Setter private int userId; + @Getter + @Setter private int roomId; - private Item baseItem; + @Getter + private final Item baseItem; + @Getter + @Setter private String wallPosition; + @Setter + @Getter private short x; + @Setter + @Getter private short y; + @Getter private double z; + @Getter private int rotation; + @Setter + @Getter private String extradata; + @Getter private int limitedStack; + @Getter private int limitedSells; private boolean needsUpdate = false; private boolean needsDelete = false; @@ -107,11 +125,11 @@ public abstract class HabboItem implements Runnable, IEventTriggers { serverMessage.appendInt(this.getRotation()); serverMessage.appendString(Double.toString(this.z)); - serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().toLowerCase().equals("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) + "" : "")); + serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().equalsIgnoreCase("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) + "" : "")); //serverMessage.appendString( ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) : "")); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -136,85 +154,21 @@ public abstract class HabboItem implements Runnable, IEventTriggers { serverMessage.appendInt(this.getUserId()); } - public int getId() { - return this.id; - } - public int getGiftAdjustedId() { if (this.isFromGift) return -this.id; return this.id; } - public int getUserId() { - return this.userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public int getRoomId() { - return this.roomId; - } - - public void setRoomId(int roomId) { - this.roomId = roomId; - } - - public Item getBaseItem() { - return this.baseItem; - } - - public String getWallPosition() { - return this.wallPosition; - } - - public void setWallPosition(String wallPosition) { - this.wallPosition = wallPosition; - } - - public short getX() { - return this.x; - } - - public void setX(short x) { - this.x = x; - } - - public short getY() { - return this.y; - } - - public void setY(short y) { - this.y = y; - } - - public double getZ() { - return this.z; - } - public void setZ(double z) { if (z > 9999 || z < -9999) return; this.z = z; } - public int getRotation() { - return this.rotation; - } - public void setRotation(int rotation) { this.rotation = (byte) (rotation % 8); } - public String getExtradata() { - return this.extradata; - } - - public void setExtradata(String extradata) { - this.extradata = extradata; - } - public boolean needsUpdate() { return this.needsUpdate; } @@ -235,14 +189,6 @@ public abstract class HabboItem implements Runnable, IEventTriggers { return this.limitedStack > 0; } - public int getLimitedStack() { - return this.limitedStack; - } - - public int getLimitedSells() { - return this.limitedSells; - } - public int getMaximumRotations() { return this.baseItem.getRotations(); } @Override @@ -270,15 +216,15 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setInt(10, this.id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - LOGGER.error("SQLException trying to save HabboItem: " + this.toString()); + log.error("Caught SQL exception", e); + log.error("SQLException trying to save HabboItem: " + this); } this.needsUpdate = false; } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -413,7 +359,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - HabboItem topItem2 = room.getTopItemAt(oldLocation.x, oldLocation.y, this); + HabboItem topItem2 = room.getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); int nextEffectM = 0; int nextEffectF = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java index 2403d762..3cc136b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -13,8 +13,8 @@ import com.eu.habbo.messages.outgoing.users.UserPerksComposer; import com.eu.habbo.messages.outgoing.users.UserRightsMessageComposer; import com.eu.habbo.plugin.events.users.UserRankChangedEvent; import com.eu.habbo.plugin.events.users.UserRegisteredEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -26,14 +26,14 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +@Slf4j public class HabboManager { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboManager.class); - //Configuration. Loaded from database & updated accordingly. public static String WELCOME_MESSAGE = ""; public static boolean NAMECHANGE_ENABLED = false; + @Getter private final ConcurrentHashMap onlineHabbos; public HabboManager() { @@ -41,7 +41,7 @@ public class HabboManager { this.onlineHabbos = new ConcurrentHashMap<>(); - LOGGER.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static HabboInfo getOfflineHabboInfo(int id) { @@ -54,7 +54,7 @@ public class HabboManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return info; @@ -72,7 +72,7 @@ public class HabboManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return info; @@ -115,7 +115,7 @@ public class HabboManager { } statement.close(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } habbo = this.cloneCheck(userId); @@ -148,15 +148,15 @@ public class HabboManager { stmt.setInt(2, habbo.getHabboInfo().getId()); stmt.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (Exception ex) { - LOGGER.error("Caught exception", ex); + log.error("Caught exception", ex); } return habbo; @@ -187,17 +187,13 @@ public class HabboManager { } } - public ConcurrentHashMap getOnlineHabbos() { - return this.onlineHabbos; - } - public synchronized void dispose() { // - LOGGER.info("Habbo Manager -> Disposed!"); + log.info("Habbo Manager -> Disposed!"); } public ArrayList getCloneAccounts(Habbo habbo, int limit) { @@ -215,7 +211,7 @@ public class HabboManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return habboInfo; @@ -233,7 +229,7 @@ public class HabboManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return nameChanges; @@ -253,7 +249,7 @@ public class HabboManager { habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge())); } if(oldRank.getRoomEffect() > 0) { - habbo.getInventory().getEffectsComponent().effects.remove(oldRank.getRoomEffect()); + habbo.getInventory().getEffectsComponent().getEffects().remove(oldRank.getRoomEffect()); } habbo.getHabboInfo().setRank(newRank); @@ -287,7 +283,7 @@ public class HabboManager { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -304,7 +300,7 @@ public class HabboManager { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java index df103c70..a2b5786f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java @@ -2,18 +2,19 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.habbohotel.navigation.DisplayMode; import com.eu.habbo.habbohotel.navigation.ListMode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; import java.sql.ResultSet; import java.sql.SQLException; +@Getter +@Setter +@AllArgsConstructor public class HabboNavigatorPersonalDisplayMode { - public ListMode listMode; - public DisplayMode displayMode; - - public HabboNavigatorPersonalDisplayMode(ListMode listMode, DisplayMode collapsed) { - this.listMode = listMode; - this.displayMode = collapsed; - } + private ListMode listMode; + private DisplayMode displayMode; public HabboNavigatorPersonalDisplayMode(ResultSet set) throws SQLException { this.listMode = set.getString("list_type").equals("thumbnails") ? ListMode.THUMBNAILS : ListMode.LIST; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java index 36c1c975..abd67166 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java @@ -4,8 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.navigation.DisplayMode; import com.eu.habbo.habbohotel.navigation.ListMode; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,16 +14,18 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; +@Slf4j +@Getter +@Setter public class HabboNavigatorWindowSettings { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboNavigatorWindowSettings.class); public final THashMap displayModes = new THashMap<>(2); private final int userId; - public int x = 100; - public int y = 100; - public int width = 425; - public int height = 535; - public boolean openSearches = false; - public int unknown = 0; + private int x = 100; + private int y = 100; + private int width = 425; + private int height = 535; + private boolean openSearches = false; + private int unknown = 0; public HabboNavigatorWindowSettings(int userId) { this.userId = userId; @@ -56,7 +59,7 @@ public class HabboNavigatorWindowSettings { statement.setString(4, displayMode.name().toLowerCase()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.displayModes.put(category, new HabboNavigatorPersonalDisplayMode(listMode, displayMode)); @@ -67,7 +70,7 @@ public class HabboNavigatorWindowSettings { HabboNavigatorPersonalDisplayMode personalDisplayMode = this.displayModes.get(category); if (personalDisplayMode != null) { - personalDisplayMode.displayMode = displayMode; + personalDisplayMode.setDisplayMode(displayMode); } else { this.insertDisplayMode(category, ListMode.LIST, displayMode); } @@ -77,7 +80,7 @@ public class HabboNavigatorWindowSettings { HabboNavigatorPersonalDisplayMode personalDisplayMode = this.displayModes.get(category); if (personalDisplayMode != null) { - personalDisplayMode.listMode = listMode; + personalDisplayMode.setListMode(listMode); } else { this.insertDisplayMode(category, listMode, DisplayMode.VISIBLE); } @@ -89,7 +92,7 @@ public class HabboNavigatorWindowSettings { public DisplayMode getDisplayModeForCategory(String category, DisplayMode standard) { if (this.displayModes.containsKey(category)) { - return this.displayModes.get(category).displayMode; + return this.displayModes.get(category).getDisplayMode(); } return standard; @@ -101,7 +104,7 @@ public class HabboNavigatorWindowSettings { public ListMode getListModeForCategory(String category, ListMode standard) { if (this.displayModes.containsKey(category)) { - return this.displayModes.get(category).listMode; + return this.displayModes.get(category).getListMode(); } return standard; @@ -110,14 +113,14 @@ public class HabboNavigatorWindowSettings { public void save(Connection connection) { try (PreparedStatement statement = connection.prepareStatement("UPDATE users_navigator_settings SET list_type = ?, display = ? WHERE user_id = ? AND caption = ? LIMIT 1")) { for (Map.Entry set : this.displayModes.entrySet()) { - statement.setString(1, set.getValue().listMode.name().toLowerCase()); - statement.setString(2, set.getValue().displayMode.name().toLowerCase()); + statement.setString(1, set.getValue().getListMode().name().toLowerCase()); + statement.setString(2, set.getValue().getDisplayMode().name().toLowerCase()); statement.setInt(3, this.userId); statement.setString(4, set.getKey()); statement.execute(); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 705ae190..532ae1fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -1,12 +1,12 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.campaign.CalendarRewardClaimed; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.TalentTrackType; +import com.eu.habbo.habbohotel.campaign.CalendarRewardClaimed; import com.eu.habbo.habbohotel.catalog.CatalogItem; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; @@ -19,87 +19,111 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; import gnu.trove.stack.array.TIntArrayStack; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Constructor; import java.sql.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +@Slf4j +@Getter public class HabboStats implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboStats.class); - - public final TIntArrayList secretRecipes; - public final HabboNavigatorWindowSettings navigatorWindowSettings; - public final THashMap cache; - public final ArrayList calendarRewardsClaimed; - public final TIntObjectMap offerCache = new TIntObjectHashMap<>(); + private final TIntArrayList secretRecipes; + private final HabboNavigatorWindowSettings navigatorWindowSettings; + private final THashMap cache; + private final ArrayList calendarRewardsClaimed; + private final TIntObjectMap offerCache = new TIntObjectHashMap<>(); private final AtomicInteger lastOnlineTime = new AtomicInteger(Emulator.getIntUnixTimestamp()); private final THashMap achievementProgress; private final THashMap achievementCache; private final THashMap recentPurchases; private final TIntArrayList favoriteRooms; private final TIntArrayList ignoredUsers; - private TIntArrayList roomsVists; - public int achievementScore; - public int respectPointsReceived; - public int respectPointsGiven; - public int respectPointsToGive; - public int petRespectPointsToGive; - public boolean blockFollowing; - public boolean blockFriendRequests; - public boolean blockRoomInvites; - public boolean blockStaffAlerts; - public boolean preferOldChat; - public boolean blockCameraFollow; - public RoomChatMessageBubbles chatColor; - public int volumeSystem; - public int volumeFurni; - public int volumeTrax; - public int guild; - public List guilds; - public String[] tags; - public TIntArrayStack votedRooms; - public int loginStreak; - public int rentedItemId; - public int rentedTimeEnd; + private final TIntArrayList roomsVists; + private int achievementScore; + @Setter + private int respectPointsReceived; + @Setter + private int respectPointsGiven; + @Setter + private int respectPointsToGive; + @Setter + private int petRespectPointsToGive; + @Setter + private boolean blockFollowing; + @Setter + private boolean blockFriendRequests; + @Setter + private boolean blockRoomInvites; + @Setter + private boolean blockStaffAlerts; + @Setter + private boolean preferOldChat; + @Setter + private boolean blockCameraFollow; + @Setter + private RoomChatMessageBubbles chatColor; + @Setter + private int volumeSystem; + @Setter + private int volumeFurni; + @Setter + private int volumeTrax; + @Setter private int guild; + private final List guilds; + private final String[] tags; + private final TIntArrayStack votedRooms; + @Setter + private int loginStreak; + @Setter + private int rentedItemId; + @Setter + private int rentedTimeEnd; public int hofPoints; - public boolean ignorePets; - public boolean ignoreBots; - public int citizenshipLevel; - public int helpersLevel; - public boolean perkTrade; + @Setter private boolean ignorePets; + @Setter private boolean ignoreBots; + private int citizenshipLevel; + private int helpersLevel; + @Setter private boolean perkTrade; public long roomEnterTimestamp; - public AtomicInteger chatCounter = new AtomicInteger(0); - public long lastChat; - public long lastUsersSearched; - public boolean nux; - public boolean nuxReward; - public int nuxStep = 1; - public int mutedCount = 0; - public boolean mutedBubbleTracker = false; - public String changeNameChecked = ""; - public boolean allowNameChange; - public boolean isPurchasingFurniture = false; - public int forumPostsCount; - public THashMap> ltdPurchaseLog = new THashMap<>(0); - public long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); - public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); - public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); - public int uiFlags; - public boolean hasGottenDefaultSavedSearches; + private final AtomicInteger chatCounter = new AtomicInteger(0); + @Setter private long lastChat; + private long lastUsersSearched; + @Setter private boolean nux; + @Setter private boolean nuxReward; + private int nuxStep = 1; + @Setter private int mutedCount = 0; + @Setter + private boolean mutedBubbleTracker = false; + @Setter private String changeNameChecked = ""; + @Setter private boolean allowNameChange; + @Setter private boolean isPurchasingFurniture = false; + @Setter private int forumPostsCount; + @Setter + private THashMap> ltdPurchaseLog = new THashMap<>(0); + @Setter private long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); + @Setter private long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); + @Setter private long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); + @Setter private int uiFlags; + @Setter private boolean hasGottenDefaultSavedSearches; private HabboInfo habboInfo; + @Setter private boolean allowTrade; - private int clubExpireTimestamp; + private final int clubExpireTimestamp; private int muteEndTime; - public int maxFriends; - public int maxRooms; - public int lastHCPayday; - public int hcGiftsClaimed; - public int hcMessageLastModified = Emulator.getIntUnixTimestamp(); - public THashSet subscriptions; + @Setter private int maxFriends; + @Setter private int maxRooms; + @Setter private int lastHCPayday; + @Setter private int hcGiftsClaimed; + @Setter private int hcMessageLastModified = Emulator.getIntUnixTimestamp(); + private final THashSet subscriptions; private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException { this.cache = new THashMap<>(0); @@ -257,7 +281,7 @@ public class HabboStats implements Runnable { statement.setInt(1, habboInfo.getId()); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return load(habboInfo); @@ -283,10 +307,8 @@ public class HabboStats implements Runnable { statement.setInt(1, habboInfo.getId()); try (ResultSet set = statement.executeQuery()) { - int i = 0; while (set.next()) { stats.guilds.add(set.getInt("guild_id")); - i++; } } } @@ -316,7 +338,7 @@ public class HabboStats implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return stats; @@ -369,16 +391,16 @@ public class HabboStats implements Runnable { statement.setInt(37, this.lastHCPayday); statement.setInt(38, this.hcGiftsClaimed); statement.setInt(39, this.habboInfo.getId()); - + statement.executeUpdate(); } try (PreparedStatement statement = connection.prepareStatement("UPDATE user_window_settings SET x = ?, y = ?, width = ?, height = ?, open_searches = ? WHERE user_id = ? LIMIT 1")) { - statement.setInt(1, this.navigatorWindowSettings.x); - statement.setInt(2, this.navigatorWindowSettings.y); - statement.setInt(3, this.navigatorWindowSettings.width); - statement.setInt(4, this.navigatorWindowSettings.height); - statement.setString(5, this.navigatorWindowSettings.openSearches ? "1" : "0"); + statement.setInt(1, this.navigatorWindowSettings.getX()); + statement.setInt(2, this.navigatorWindowSettings.getY()); + statement.setInt(3, this.navigatorWindowSettings.getWidth()); + statement.setInt(4, this.navigatorWindowSettings.getHeight()); + statement.setString(5, this.navigatorWindowSettings.isOpenSearches() ? "1" : "0"); statement.setInt(6, this.habboInfo.getId()); statement.executeUpdate(); } @@ -400,7 +422,7 @@ public class HabboStats implements Runnable { this.navigatorWindowSettings.save(connection); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -424,10 +446,6 @@ public class HabboStats implements Runnable { return this.guilds.contains(guildId); } - public int getAchievementScore() { - return this.achievementScore; - } - public void addAchievementScore(int achievementScore) { this.achievementScore += achievementScore; } @@ -443,29 +461,13 @@ public class HabboStats implements Runnable { this.achievementProgress.put(achievement, progress); } - public int getRentedTimeEnd() { - return this.rentedTimeEnd; - } - - public void setRentedTimeEnd(int rentedTimeEnd) { - this.rentedTimeEnd = rentedTimeEnd; - } - - public int getRentedItemId() { - return this.rentedItemId; - } - - public void setRentedItemId(int rentedItemId) { - this.rentedItemId = rentedItemId; - } - public boolean isRentingSpace() { return this.rentedTimeEnd >= Emulator.getIntUnixTimestamp(); } public Subscription getSubscription(String subscriptionType) { - for(Subscription subscription : subscriptions) { - if(subscription.getSubscriptionType().equalsIgnoreCase(subscriptionType) && subscription.isActive() && subscription.getRemaining() > 0) { + for (Subscription subscription : subscriptions) { + if (subscription.getSubscriptionType().equalsIgnoreCase(subscriptionType) && subscription.isActive() && subscription.getRemaining() > 0) { return subscription; } } @@ -480,7 +482,7 @@ public class HabboStats implements Runnable { public int getSubscriptionExpireTimestamp(String subscriptionType) { Subscription subscription = getSubscription(subscriptionType); - if(subscription == null) + if (subscription == null) return 0; return subscription.getTimestampEnd(); @@ -489,7 +491,7 @@ public class HabboStats implements Runnable { public Subscription createSubscription(String subscriptionType, int duration) { Subscription subscription = getSubscription(subscriptionType); - if(subscription != null) { + if (subscription != null) { if (!Emulator.getPluginManager().fireEvent(new UserSubscriptionExtendedEvent(this.habboInfo.getId(), subscription, duration)).isCancelled()) { subscription.addDuration(duration); subscription.onExtended(duration); @@ -516,14 +518,13 @@ public class HabboStats implements Runnable { this.subscriptions.add(sub); sub.onCreated(); return sub; - } - catch (Exception e) { - LOGGER.error("Caught exception", e); + } catch (Exception e) { + log.error("Caught exception", e); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -538,11 +539,11 @@ public class HabboStats implements Runnable { Subscription subscription = getSubscription(Subscription.HABBO_CLUB); int duration = clubExpireTimestamp - Emulator.getIntUnixTimestamp(); - if(subscription != null) { + if (subscription != null) { duration = clubExpireTimestamp - subscription.getTimestampStart(); } - if(duration > 0) { + if (duration > 0) { createSubscription(Subscription.HABBO_CLUB, duration); } } @@ -553,8 +554,8 @@ public class HabboStats implements Runnable { public int getPastTimeAsClub() { int pastTimeAsHC = 0; - for(Subscription subs : this.subscriptions) { - if(subs.getSubscriptionType().equalsIgnoreCase(Subscription.HABBO_CLUB)) { + for (Subscription subs : this.subscriptions) { + if (subs.getSubscriptionType().equalsIgnoreCase(Subscription.HABBO_CLUB)) { pastTimeAsHC += subs.getDuration() - (Math.max(subs.getRemaining(), 0)); } } @@ -563,33 +564,21 @@ public class HabboStats implements Runnable { public int getTimeTillNextClubGift() { int pastTimeAsClub = getPastTimeAsClub(); - int totalGifts = (int)Math.ceil(pastTimeAsClub / 2678400.0); + int totalGifts = (int) Math.ceil(pastTimeAsClub / 2678400.0); return (totalGifts * 2678400) - pastTimeAsClub; } public int getRemainingClubGifts() { - int totalGifts = (int)Math.ceil(getPastTimeAsClub() / 2678400.0); + int totalGifts = (int) Math.ceil(getPastTimeAsClub() / 2678400.0); return totalGifts - this.hcGiftsClaimed; } - public THashMap getAchievementProgress() { - return this.achievementProgress; - } - - public THashMap getAchievementCache() { - return this.achievementCache; - } - public void addPurchase(CatalogItem item) { if (!this.recentPurchases.containsKey(item.getId())) { this.recentPurchases.put(item.getId(), item); } } - public THashMap getRecentPurchases() { - return this.recentPurchases; - } - public void disposeRecentPurchases() { this.recentPurchases.clear(); } @@ -606,7 +595,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.favoriteRooms.add(roomId); @@ -620,7 +609,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -629,12 +618,12 @@ public class HabboStats implements Runnable { return this.favoriteRooms.contains(roomId); } - public boolean visitedRoom(int roomId) { return this.roomsVists.contains(roomId); } + public boolean visitedRoom(int roomId) { + return this.roomsVists.contains(roomId); + } - public void addVisitRoom(int roomId) { this.roomsVists.add(roomId); } - - public TIntArrayList getFavoriteRooms() { - return this.favoriteRooms; + public void addVisitRoom(int roomId) { + this.roomsVists.add(roomId); } public boolean hasRecipe(int id) { @@ -650,7 +639,7 @@ public class HabboStats implements Runnable { statement.setInt(2, id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.secretRecipes.add(id); @@ -673,10 +662,6 @@ public class HabboStats implements Runnable { this.helpersLevel = level; } - public int getMuteEndTime() { - return this.muteEndTime; - } - public int addMuteTime(int seconds) { if (this.remainingMuteTime() == 0) { this.muteEndTime = Emulator.getIntUnixTimestamp(); @@ -730,7 +715,7 @@ public class HabboStats implements Runnable { * Ignore an user. * * @param gameClient The client to which this HabboStats instance belongs. - * @param userId The user to ignore. + * @param userId The user to ignore. * @return true if successfully ignored, false otherwise. */ public boolean ignoreUser(GameClient gameClient, int userId) { @@ -755,7 +740,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -772,7 +757,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -790,10 +775,6 @@ public class HabboStats implements Runnable { else return this.allowTrade; } - public void setAllowTrade(boolean allowTrade) { - this.allowTrade = allowTrade; - } - public HabboOfferPurchase getHabboOfferPurchase(int offerId) { return this.offerCache.get(offerId); } @@ -801,4 +782,52 @@ public class HabboStats implements Runnable { public void addHabboOfferPurchase(HabboOfferPurchase offerPurchase) { this.offerCache.put(offerPurchase.getOfferId(), offerPurchase); } + + public void increaseRespectPointsReceived() { + increaseRespectPointsReceived(1); + } + + public void increaseRespectPointsReceived(int amount) { + respectPointsReceived += amount; + } + + public void increaseRespectPointsGiven() { + increaseRespectPointsGiven(1); + } + + public void increaseRespectPointsGiven(int amount) { + respectPointsGiven += amount; + } + + public void increaseRespectPointsToGive() { + increaseRespectPointsToGive(1); + } + + public void increaseRespectPointsToGive(int amount) { + respectPointsToGive += amount; + } + + public void decreasePetRespectPointsToGive() { + decreasePetRespectPointsToGive(1); + } + + public void decreasePetRespectPointsToGive(int amount) { + petRespectPointsToGive -= amount; + } + public void increasePetRespectPointToGive() { + increasePetRespectPointsToGive(1); + } + + public void increasePetRespectPointsToGive(int amount) { + petRespectPointsToGive += amount; + } + + public int increaseNuxStep() { + return increaseNuxStep(1); + } + + public int increaseNuxStep(int amount) { + nuxStep += amount; + return nuxStep; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/SignType.java b/src/main/java/com/eu/habbo/habbohotel/users/SignType.java index 4fc3d094..8ad8622f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/SignType.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/SignType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.users; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum SignType { ZERO(0), ONE(1), @@ -23,11 +28,4 @@ public enum SignType { private final int id; - SignType(int id) { - this.id = id; - } - - public int getId() { - return this.id; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java index e3591750..4da9ffba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java @@ -2,20 +2,24 @@ package com.eu.habbo.habbohotel.users.cache; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class HabboOfferPurchase { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboOfferPurchase.class); private final int userId; + @Getter private final int offerId; + @Getter private int state; + @Getter private int amount; + @Getter private int lastPurchaseTimestamp; private boolean needsUpdate = false; @@ -41,7 +45,7 @@ public class HabboOfferPurchase { statement.setInt(2, offerId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return null; } @@ -52,32 +56,16 @@ public class HabboOfferPurchase { return purchase; } - public int getOfferId() { - return this.offerId; - } - - public int getState() { - return this.state; - } - public void setState(int state) { this.state = state; this.needsUpdate = true; } - public int getAmount() { - return this.amount; - } - public void incrementAmount(int amount) { this.amount += amount; this.needsUpdate = true; } - public int getLastPurchaseTimestamp() { - return this.lastPurchaseTimestamp; - } - public void setLastPurchaseTimestamp(int timestamp) { this.lastPurchaseTimestamp = timestamp; this.needsUpdate = true; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java index 4e470658..7a7fcb4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.TIntHashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.regex.Pattern; +@Slf4j public class ClothingValidationManager { - private static final Logger LOGGER = LoggerFactory.getLogger(ClothingValidationManager.class); - public static String FIGUREDATA_URL = ""; public static boolean VALIDATE_ON_HC_EXPIRE = false; public static boolean VALIDATE_ON_LOGIN = false; @@ -38,7 +36,7 @@ public class ClothingValidationManager { VALIDATE_ON_MIMIC = false; VALIDATE_ON_MANNEQUIN = false; VALIDATE_ON_FBALLGATE = false; - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -115,16 +113,16 @@ public class ClothingValidationManager { { FiguredataSettype settype = x.getValue(); - if(gender.equalsIgnoreCase("M") && !isHC && !settype.mandatoryMale0) + if(gender.equalsIgnoreCase("M") && !isHC && !settype.isMandatoryMale0()) return; - if(gender.equalsIgnoreCase("F") && !isHC && !settype.mandatoryFemale0) + if(gender.equalsIgnoreCase("F") && !isHC && !settype.isMandatoryFemale0()) return; - if(gender.equalsIgnoreCase("M") && isHC && !settype.mandatoryMale1) + if(gender.equalsIgnoreCase("M") && isHC && !settype.isMandatoryMale1()) return; - if(gender.equalsIgnoreCase("F") && isHC && !settype.mandatoryFemale1) + if(gender.equalsIgnoreCase("F") && isHC && !settype.isMandatoryFemale1()) return; parts.put(x.getKey(), new String[] { x.getKey() }); @@ -140,9 +138,9 @@ public class ClothingValidationManager { return; } - FiguredataPalette palette = FIGUREDATA.palettes.get(settype.paletteId); + FiguredataPalette palette = FIGUREDATA.palettes.get(settype.getPaletteId()); if (palette == null) { - throw new Exception("Palette " + settype.paletteId + " does not exist"); + throw new Exception("Palette " + settype.getPaletteId() + " does not exist"); } int setId; @@ -151,21 +149,21 @@ public class ClothingValidationManager { setId = Integer.parseInt(data.length >= 2 ? data[1] : "-1"); set = settype.getSet(setId); - if (set == null || (set.club && !isHC) || !set.selectable || (set.sellable && !ownedClothing.contains(set.id)) || (!set.gender.equalsIgnoreCase("U") && !set.gender.equalsIgnoreCase(gender))) { - if (gender.equalsIgnoreCase("M") && !isHC && !settype.mandatoryMale0) + if (set == null || (set.isClub() && !isHC) || !set.isSelectable() || (set.isSellable() && !ownedClothing.contains(set.getId())) || (!set.getGender().equalsIgnoreCase("U") && !set.getGender().equalsIgnoreCase(gender))) { + if (gender.equalsIgnoreCase("M") && !isHC && !settype.isMandatoryMale0()) return; - if (gender.equalsIgnoreCase("F") && !isHC && !settype.mandatoryFemale0) + if (gender.equalsIgnoreCase("F") && !isHC && !settype.isMandatoryFemale0()) return; - if (gender.equalsIgnoreCase("M") && isHC && !settype.mandatoryMale1) + if (gender.equalsIgnoreCase("M") && isHC && !settype.isMandatoryMale1()) return; - if (gender.equalsIgnoreCase("F") && isHC && !settype.mandatoryFemale1) + if (gender.equalsIgnoreCase("F") && isHC && !settype.isMandatoryFemale1()) return; set = settype.getFirstNonHCSetForGender(gender); - setId = set.id; + setId = set.getId(); } ArrayList dataParts = new ArrayList<>(); @@ -173,23 +171,23 @@ public class ClothingValidationManager { int color1 = -1; int color2 = -1; - if (set.colorable) { + if (set.isColorable()) { color1 = data.length >= 3 ? Integer.parseInt(data[2]) : -1; FiguredataPaletteColor color = palette.getColor(color1); - if (color == null || (color.club && !isHC)) { - color1 = palette.getFirstNonHCColor().id; + if (color == null || (color.isClub() && !isHC)) { + color1 = palette.getFirstNonHCColor().getId(); } } - if (data.length >= 4 && set.colorable) { + if (data.length >= 4 && set.isColorable()) { color2 = Integer.parseInt(data[3]); FiguredataPaletteColor color = palette.getColor(color2); - if (color == null || (color.club && !isHC)) { - color2 = palette.getFirstNonHCColor().id; + if (color == null || (color.isClub() && !isHC)) { + color2 = palette.getFirstNonHCColor().getId(); } } - dataParts.add(settype.type); + dataParts.add(settype.getType()); dataParts.add("" + setId); if (color1 > -1) { @@ -204,7 +202,7 @@ public class ClothingValidationManager { } } catch (Exception e) { //habbo.alert(e.getMessage()); - LOGGER.error("Error in clothing validation", e); + log.error("Error in clothing validation", e); } }); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java index 74eb2260..23936acc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; -import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -84,7 +83,7 @@ public class Figuredata { } } - palettes.put(palette.id, palette); + palettes.put(palette.getId(), palette); } } @@ -120,7 +119,7 @@ public class Figuredata { } } - settypes.put(settype.type, settype); + settypes.put(settype.getType(), settype); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPalette.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPalette.java index 4a1c48d5..a1430895 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPalette.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPalette.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; +import lombok.Getter; + import java.util.TreeMap; public class FiguredataPalette { - public int id; - public TreeMap colors; + @Getter + private final int id; + private final TreeMap colors; public FiguredataPalette(int id) { this.id = id; @@ -12,7 +15,7 @@ public class FiguredataPalette { } public void addColor(FiguredataPaletteColor color) { - this.colors.put(color.id, color); + this.colors.put(color.getId(), color); } public FiguredataPaletteColor getColor(int colorId) { @@ -21,7 +24,7 @@ public class FiguredataPalette { public FiguredataPaletteColor getFirstNonHCColor() { for(FiguredataPaletteColor color : this.colors.values()) { - if(!color.club && color.selectable) + if(!color.isClub() && color.isSelectable()) return color; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPaletteColor.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPaletteColor.java index 7ba0b9a7..e976d278 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPaletteColor.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataPaletteColor.java @@ -1,17 +1,15 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; -public class FiguredataPaletteColor { - public int id; - public int index; - public boolean club; - public boolean selectable; - public String colorHex; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class FiguredataPaletteColor { + private int id; + private int index; + private boolean club; + private boolean selectable; + private String colorHex; - public FiguredataPaletteColor(int id, int index, boolean club, boolean selectable, String colorHex) { - this.id = id; - this.index = index; - this.club = club; - this.selectable = selectable; - this.colorHex = colorHex; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettype.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettype.java index e3698815..90225c0e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettype.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettype.java @@ -1,16 +1,19 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; -import java.util.Map; +import lombok.Getter; + import java.util.TreeMap; +@Getter + public class FiguredataSettype { - public String type; - public int paletteId; - public boolean mandatoryMale0; - public boolean mandatoryFemale0; - public boolean mandatoryMale1; - public boolean mandatoryFemale1; - public TreeMap sets; + private final String type; + private final int paletteId; + private final boolean mandatoryMale0; + private final boolean mandatoryFemale0; + private final boolean mandatoryMale1; + private final boolean mandatoryFemale1; + private final TreeMap sets; public FiguredataSettype(String type, int paletteId, boolean mandatoryMale0, boolean mandatoryFemale0, boolean mandatoryMale1, boolean mandatoryFemale1) { this.type = type; @@ -23,7 +26,7 @@ public class FiguredataSettype { } public void addSet(FiguredataSettypeSet set) { - this.sets.put(set.id, set); + this.sets.put(set.getId(), set); } public FiguredataSettypeSet getSet(int id) { @@ -36,7 +39,7 @@ public class FiguredataSettype { */ public FiguredataSettypeSet getFirstSetForGender(String gender) { for(FiguredataSettypeSet set : this.sets.descendingMap().values()) { - if((set.gender.equalsIgnoreCase(gender) || set.gender.equalsIgnoreCase("u")) && !set.sellable && set.selectable) { + if((set.getGender().equalsIgnoreCase(gender) || set.getGender().equalsIgnoreCase("u")) && !set.isSellable() && set.isSelectable()) { return set; } } @@ -50,7 +53,7 @@ public class FiguredataSettype { */ public FiguredataSettypeSet getFirstNonHCSetForGender(String gender) { for(FiguredataSettypeSet set : this.sets.descendingMap().values()) { - if((set.gender.equalsIgnoreCase(gender) || set.gender.equalsIgnoreCase("u")) && !set.club && !set.sellable && set.selectable) { + if((set.getGender().equalsIgnoreCase(gender) || set.getGender().equalsIgnoreCase("u")) && !set.isClub() && !set.isSellable() && set.isSelectable()) { return set; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettypeSet.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettypeSet.java index a5a15f38..10f358c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettypeSet.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/FiguredataSettypeSet.java @@ -1,21 +1,16 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; -public class FiguredataSettypeSet { - public int id; - public String gender; - public boolean club; - public boolean colorable; - public boolean selectable; - public boolean preselectable; - public boolean sellable; +import lombok.AllArgsConstructor; +import lombok.Getter; - public FiguredataSettypeSet(int id, String gender, boolean club, boolean colorable, boolean selectable, boolean preselectable, boolean sellable) { - this.id = id; - this.gender = gender; - this.club = club; - this.colorable = colorable; - this.selectable = selectable; - this.preselectable = preselectable; - this.sellable = sellable; - } +@Getter +@AllArgsConstructor +public class FiguredataSettypeSet { + private int id; + private String gender; + private boolean club; + private boolean colorable; + private boolean selectable; + private boolean preselectable; + private boolean sellable; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index 49f30136..e26be2df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.permissions.Rank; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,9 +16,10 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Set; +@Slf4j public class BadgesComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(BadgesComponent.class); + @Getter private final THashSet badges = new THashSet<>(); public BadgesComponent(Habbo habbo) { @@ -55,7 +56,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return badgesList; @@ -82,7 +83,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return badgesList; } @@ -100,7 +101,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -114,20 +115,11 @@ public class BadgesComponent { badgesList.add(badge); } - badgesList.sort(new Comparator() { - @Override - public int compare(HabboBadge o1, HabboBadge o2) { - return o1.getSlot() - o2.getSlot(); - } - }); + badgesList.sort(Comparator.comparingInt(HabboBadge::getSlot)); return badgesList; } } - public THashSet getBadges() { - return this.badges; - } - public boolean hasBadge(String badge) { return this.getBadge(badge) != null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index cf9097bf..e97a3f5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,9 +13,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; +@Slf4j public class BotsComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(BotsComponent.class); + @Getter private final THashMap bots = new THashMap<>(); public BotsComponent(Habbo habbo) { @@ -35,7 +36,7 @@ public class BotsComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -56,10 +57,6 @@ public class BotsComponent { } } - public THashMap getBots() { - return this.bots; - } - public void dispose() { synchronized (this.bots) { for (Map.Entry map : this.bots.entrySet()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 9931f348..9a70c1f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -2,24 +2,27 @@ package com.eu.habbo.habbohotel.users.inventory; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.inventory.AvatarEffectAddedMessageComposer; import com.eu.habbo.messages.outgoing.inventory.AvatarEffectActivatedMessageComposer; +import com.eu.habbo.messages.outgoing.inventory.AvatarEffectAddedMessageComposer; import com.eu.habbo.messages.outgoing.inventory.AvatarEffectExpiredMessageComposer; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter public class EffectsComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(EffectsComponent.class); - public final THashMap effects = new THashMap<>(); - public final Habbo habbo; - public int activatedEffect = 0; + private final THashMap effects = new THashMap<>(); + private final Habbo habbo; + @Setter + private int activatedEffect = 0; public EffectsComponent(Habbo habbo) { this.habbo = habbo; @@ -31,7 +34,7 @@ public class EffectsComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } if(habbo.getHabboInfo().getRank().getRoomEffect() > 0) this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect()); @@ -92,7 +95,7 @@ public class EffectsComponent { statement.setInt(5, effect.effect); statement.addBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } return true; @@ -100,7 +103,7 @@ public class EffectsComponent { statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.effects.clear(); @@ -208,7 +211,7 @@ public class EffectsComponent { statement.setInt(4, this.duration); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -218,7 +221,7 @@ public class EffectsComponent { statement.setInt(2, this.effect); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index 613868c4..ee851a8c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -13,10 +13,9 @@ import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -24,9 +23,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.NoSuchElementException; +@Slf4j public class ItemsComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(ItemsComponent.class); + @Getter private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final HabboInventory inventory; @@ -50,15 +50,15 @@ public class ItemsComponent { if (item != null) { itemsList.put(set.getInt("id"), item); } else { - LOGGER.error("Failed to load HabboItem: " + set.getInt("id")); + log.error("Failed to load HabboItem: " + set.getInt("id")); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return itemsList; @@ -103,16 +103,13 @@ public class ItemsComponent { public HabboItem getAndRemoveHabboItem(final Item item) { final HabboItem[] habboItem = {null}; synchronized (this.items) { - this.items.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(HabboItem object) { - if (object.getBaseItem() == item) { - habboItem[0] = object; - return false; - } - - return true; + this.items.forEachValue(object -> { + if (object.getBaseItem() == item) { + habboItem[0] = object; + return false; } + + return true; }); } this.removeHabboItem(habboItem[0]); @@ -134,10 +131,6 @@ public class ItemsComponent { } } - public TIntObjectMap getItems() { - return this.items; - } - public THashSet getItemsAsValueCollection() { THashSet items = new THashSet<>(); items.addAll(this.items.valueCollection()); @@ -154,7 +147,7 @@ public class ItemsComponent { TIntObjectIterator items = this.items.iterator(); if (items == null) { - LOGGER.error("Items is NULL!"); + log.error("Items is NULL!"); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java index cd963297..55abb985 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java @@ -8,8 +8,8 @@ import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -18,8 +18,9 @@ import java.sql.SQLException; import java.util.NoSuchElementException; import java.util.Set; +@Slf4j public class PetsComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(PetsComponent.class); + @Getter private final TIntObjectMap pets = TCollections.synchronizedMap(new TIntObjectHashMap<>()); public PetsComponent(Habbo habbo) { @@ -37,7 +38,7 @@ public class PetsComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } @@ -66,10 +67,6 @@ public class PetsComponent { } } - public TIntObjectMap getPets() { - return this.pets; - } - public int getPetsCount() { return this.pets.size(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java index cd806c24..ee97786c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java @@ -3,12 +3,11 @@ package com.eu.habbo.habbohotel.users.inventory; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.TIntSet; import gnu.trove.set.hash.TIntHashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,8 +15,9 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.regex.Pattern; +@Slf4j +@Getter public class WardrobeComponent { - private static final Logger LOGGER = LoggerFactory.getLogger(WardrobeComponent.class); private final THashMap looks; private final TIntSet clothing; private final TIntSet clothingSets; @@ -48,13 +48,13 @@ public class WardrobeComponent { try { this.clothingSets.add(Integer.parseInt(x)); } - catch (Exception e) { } + catch (Exception ignored) { } } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -62,28 +62,14 @@ public class WardrobeComponent { return new WardrobeItem(habbo.getHabboInfo().getGender(), look, slotId, habbo); } - public THashMap getLooks() { - return this.looks; - } - - public TIntCollection getClothing() { - return this.clothing; - } - - public TIntCollection getClothingSets() { - return this.clothingSets; - } - public void dispose() { - this.looks.values().stream().filter(item -> item.needsInsert || item.needsUpdate).forEach(item -> { - Emulator.getThreading().run(item); - }); + this.looks.values().stream().filter(item -> item.needsInsert || item.needsUpdate).forEach(item -> Emulator.getThreading().run(item)); this.looks.clear(); } public class WardrobeItem implements Runnable { - private int slotId; + private final int slotId; private HabboGender gender; private Habbo habbo; private String look; @@ -165,7 +151,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/HcPayDayLogEntry.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/HcPayDayLogEntry.java index e96d64b3..a95b5320 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/HcPayDayLogEntry.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/HcPayDayLogEntry.java @@ -2,8 +2,8 @@ package com.eu.habbo.habbohotel.users.subscriptions; import com.eu.habbo.Emulator; import com.eu.habbo.core.DatabaseLoggable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -11,32 +11,21 @@ import java.sql.SQLException; /** * @author Beny */ +@Getter +@AllArgsConstructor public class HcPayDayLogEntry implements Runnable, DatabaseLoggable { - - private static final Logger LOGGER = LoggerFactory.getLogger(HcPayDayLogEntry.class); private static final String QUERY = "INSERT INTO `logs_hc_payday` (`timestamp`, `user_id`, `hc_streak`, `total_coins_spent`, `reward_coins_spent`, `reward_streak`, `total_payout`, `currency`, `claimed`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; - public final int timestamp; - public final int userId; - public final int hcStreak; - public final int totalCoinsSpent; - public final int rewardCoinsSpent; - public final int rewardStreak; - public final int totalPayout; - public final String currency; - public final boolean claimed; + private final int timestamp; + private final int userId; + private final int hcStreak; + private final int totalCoinsSpent; + private final int rewardCoinsSpent; + private final int rewardStreak; + private final int totalPayout; + private final String currency; + private final boolean claimed; - public HcPayDayLogEntry(int timestamp, int userId, int hcStreak, int totalCoinsSpent, int rewardCoinsSpent, int rewardStreak, int totalPayout, String currency, boolean claimed) { - this.timestamp = timestamp; - this.userId = userId; - this.hcStreak = hcStreak; - this.totalCoinsSpent = totalCoinsSpent; - this.rewardCoinsSpent = rewardCoinsSpent; - this.rewardStreak = rewardStreak; - this.totalPayout = totalPayout; - this.currency = currency; - this.claimed = claimed; - } @Override public String getQuery() { diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java index 08fba035..9dfd52af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java @@ -1,6 +1,9 @@ package com.eu.habbo.habbohotel.users.subscriptions; import com.eu.habbo.Emulator; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -9,6 +12,9 @@ import java.sql.SQLException; /** * @author Beny */ +@Getter +@Slf4j +@AllArgsConstructor public class Subscription { public static final String HABBO_CLUB = "HABBO_CLUB"; @@ -19,56 +25,6 @@ public class Subscription { private int duration; private boolean active; - /** - * Subscription constructor - * @param id ID of the subscription - * @param userId ID of user who has the subscription - * @param subscriptionType Subscription type name (e.g. HABBO_CLUB) - * @param timestampStart Unix timestamp start of subscription - * @param duration Length of subscription in seconds - * @param active Boolean indicating if subscription is active - */ - public Subscription(Integer id, Integer userId, String subscriptionType, Integer timestampStart, Integer duration, Boolean active) { - this.id = id; - this.userId = userId; - this.subscriptionType = subscriptionType; - this.timestampStart = timestampStart; - this.duration = duration; - this.active = active; - } - - /** - * @return ID of the subscription - */ - public int getSubscriptionId() { - return id; - } - - /** - * @return ID of user who has the subscription - */ - public int getUserId() { - return userId; - } - - /** - * @return Subscription type name (e.g. HABBO_CLUB) - */ - public String getSubscriptionType() { - return subscriptionType; - } - - /** - * @return Length of subscription in seconds - */ - public int getDuration() { - return duration; - } - - /** - * Updates the Subscription record with new duration - * @param amount Length of time to add in seconds - */ public void addDuration(int amount) { this.duration += amount; @@ -79,7 +35,7 @@ public class Subscription { statement.executeUpdate(); } } catch (SQLException e) { - SubscriptionManager.LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -97,7 +53,7 @@ public class Subscription { statement.executeUpdate(); } } catch (SQLException e) { - SubscriptionManager.LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -108,13 +64,6 @@ public class Subscription { return (this.timestampStart + this.duration) - Emulator.getIntUnixTimestamp(); } - /** - * @return Unix timestamp start of subscription - */ - public int getTimestampStart() { - return this.timestampStart; - } - /** * @return Unix timestamp end of subscription */ @@ -122,12 +71,6 @@ public class Subscription { return (this.timestampStart + this.duration); } - /** - * @return Boolean indicating if the subscription is active - */ - public boolean isActive() { - return active; - } /** * Called when the subscription is first created diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java index 9ca8f14f..968ed7f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java @@ -15,8 +15,7 @@ import com.eu.habbo.messages.outgoing.generic.ClubGiftNotificationComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.eu.habbo.messages.outgoing.users.*; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -30,8 +29,8 @@ import java.util.TreeMap; /** * @author Beny */ +@Slf4j public class SubscriptionHabboClub extends Subscription { - private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionHabboClub.class); public static boolean HC_PAYDAY_ENABLED = false; public static int HC_PAYDAY_NEXT_DATE = Integer.MAX_VALUE; // yyyy-MM-dd HH:mm:ss @@ -73,9 +72,9 @@ public class SubscriptionHabboClub extends Subscription { HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(this.getUserId()); HabboStats stats = habboInfo.getHabboStats(); - stats.maxFriends = Messenger.MAXIMUM_FRIENDS_HC; - stats.maxRooms = RoomManager.MAXIMUM_ROOMS_HC; - stats.lastHCPayday = HC_PAYDAY_COINSSPENT_RESET_ON_EXPIRE ? Emulator.getIntUnixTimestamp() : HC_PAYDAY_NEXT_DATE - Emulator.timeStringToSeconds(HC_PAYDAY_INTERVAL); + stats.setMaxFriends(Messenger.MAXIMUM_FRIENDS_HC); + stats.setMaxRooms(RoomManager.MAXIMUM_ROOMS_HC); + stats.setLastHCPayday(HC_PAYDAY_COINSSPENT_RESET_ON_EXPIRE ? Emulator.getIntUnixTimestamp() : HC_PAYDAY_NEXT_DATE - Emulator.timeStringToSeconds(HC_PAYDAY_INTERVAL)); Emulator.getThreading().run(stats); progressAchievement(habboInfo); @@ -87,11 +86,11 @@ public class SubscriptionHabboClub extends Subscription { habbo.getClient().sendResponse(new ClubGiftNotificationComposer(habbo.getHabboStats().getRemainingClubGifts())); } - if ((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().hcMessageLastModified) < 60) { + if ((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().getHcMessageLastModified()) < 60) { Emulator.getThreading().run(() -> { habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo)); habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo)); - }, (Emulator.getIntUnixTimestamp() - habbo.getHabboStats().hcMessageLastModified)); + }, (Emulator.getIntUnixTimestamp() - habbo.getHabboStats().getHcMessageLastModified())); } else { habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL)); habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo)); @@ -152,8 +151,8 @@ public class SubscriptionHabboClub extends Subscription { HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(this.getUserId()); HabboStats stats = habboInfo.getHabboStats(); - stats.maxFriends = Messenger.MAXIMUM_FRIENDS; - stats.maxRooms = RoomManager.MAXIMUM_ROOMS_USER; + stats.setMaxFriends(Messenger.MAXIMUM_FRIENDS); + stats.setMaxRooms(RoomManager.MAXIMUM_ROOMS_USER); Emulator.getThreading().run(stats); if (habbo != null && ClothingValidationManager.VALIDATE_ON_HC_EXPIRE) { @@ -190,7 +189,7 @@ public class SubscriptionHabboClub extends Subscription { int creditRewardForMonthlySpent = 0; int timeUntilPayday = 0; - for (Subscription sub : habbo.getHabboStats().subscriptions) { + for (Subscription sub : habbo.getHabboStats().getSubscriptions()) { if (sub.getSubscriptionType().equalsIgnoreCase(Subscription.HABBO_CLUB)) { if (firstEverSub == null || sub.getTimestampStart() < firstEverSub.getTimestampStart()) { @@ -215,9 +214,9 @@ public class SubscriptionHabboClub extends Subscription { } } - THashMap queryParams = new THashMap(); + THashMap queryParams = new THashMap<>(); queryParams.put("@user_id", habbo.getId()); - queryParams.put("@timestamp_start", habbo.getHabboStats().lastHCPayday); + queryParams.put("@timestamp_start", habbo.getHabboStats().getLastHCPayday()); queryParams.put("@timestamp_end", HC_PAYDAY_NEXT_DATE); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); @@ -230,7 +229,7 @@ public class SubscriptionHabboClub extends Subscription { } } catch (SQLException e) { - SubscriptionManager.LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } creditRewardForMonthlySpent = (int) Math.floor(totalCreditsSpent * HC_PAYDAY_KICKBACK_PERCENTAGE); @@ -270,16 +269,16 @@ public class SubscriptionHabboClub extends Subscription { HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId); HabboStats stats = habboInfo.getHabboStats(); ScrSendKickbackInfoMessageComposer calculated = calculatePayday(habboInfo); - int totalReward = (calculated.creditRewardForMonthlySpent + calculated.creditRewardForStreakBonus); + int totalReward = (calculated.getCreditRewardForMonthlySpent() + calculated.getCreditRewardForStreakBonus()); if (totalReward > 0) { boolean claimed = claimPayDay(Emulator.getGameEnvironment().getHabboManager().getHabbo(userId), totalReward, HC_PAYDAY_CURRENCY); - HcPayDayLogEntry le = new HcPayDayLogEntry(timestampNow, userId, calculated.currentHcStreak, calculated.totalCreditsSpent, calculated.creditRewardForMonthlySpent, calculated.creditRewardForStreakBonus, totalReward, HC_PAYDAY_CURRENCY, claimed); + HcPayDayLogEntry le = new HcPayDayLogEntry(timestampNow, userId, calculated.getCurrentHcStreak(), calculated.getTotalCreditsSpent(), calculated.getCreditRewardForMonthlySpent(), calculated.getCreditRewardForStreakBonus(), totalReward, HC_PAYDAY_CURRENCY, claimed); Emulator.getThreading().run(le); } - stats.lastHCPayday = timestampNow; + stats.setLastHCPayday(timestampNow); Emulator.getThreading().run(stats); } catch (Exception e) { - SubscriptionManager.LOGGER.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); + log.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); } } } @@ -303,7 +302,7 @@ public class SubscriptionHabboClub extends Subscription { } } catch (SQLException e) { - SubscriptionManager.LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } isExecuting = false; } @@ -340,13 +339,13 @@ public class SubscriptionHabboClub extends Subscription { } } } catch (Exception e) { - SubscriptionManager.LOGGER.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); + log.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); } } } } catch (SQLException e) { - SubscriptionManager.LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -370,45 +369,36 @@ public class SubscriptionHabboClub extends Subscription { return false; int pointCurrency; - switch(currency.toLowerCase()) { - case "credits": - case "coins": - case "credit": - case "coin": - habbo.getClient().getHabbo().getHabboInfo().addCredits(amount); + switch (currency.toLowerCase()) { + case "credits", "coins", "credit", "coin" -> { + habbo.getClient().getHabbo().giveCredits(amount); habbo.getClient().sendResponse(new CreditBalanceComposer(habbo.getClient().getHabbo())); - break; - - case "diamonds": - case "diamond": + } + case "diamonds", "diamond" -> { pointCurrency = 5; - habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); + habbo.getClient().getHabbo().givePoints(pointCurrency, amount); habbo.getClient().sendResponse(new HabboActivityPointNotificationMessageComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); - break; - case "duckets": - case "ducket": - case "pixels": - case "pixel": + } + case "duckets", "ducket", "pixels", "pixel" -> { pointCurrency = 0; - habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); + habbo.getClient().getHabbo().givePoints(pointCurrency, amount); habbo.getClient().sendResponse(new HabboActivityPointNotificationMessageComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); - break; - default: + } + default -> { pointCurrency = -1; try { pointCurrency = Integer.parseInt(currency); + } catch (NumberFormatException ex) { + log.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); } - catch (NumberFormatException ex) { - LOGGER.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); - } - if (pointCurrency >= 0) { - habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); + habbo.getClient().getHabbo().givePoints(pointCurrency, amount); habbo.getClient().sendResponse(new HabboActivityPointNotificationMessageComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); + } - break; + } } habbo.alert(Emulator.getTexts().getValue("subscriptions.hc.payday.message", "Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!").replace("%amount%", "" + amount)); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java index b39d9d52..e688e839 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.users.subscriptions; import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -16,11 +16,11 @@ import java.sql.SQLException; /** * @author Beny */ +@Slf4j +@Getter public class SubscriptionManager { - public static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionManager.class); - - public THashMap> types; + private THashMap> types; public SubscriptionManager() { this.types = new THashMap<>(); @@ -44,7 +44,7 @@ public class SubscriptionManager { public Class getSubscriptionClass(String type) { if(!this.types.containsKey(type)) { - LOGGER.debug("Can't find subscription class: {}", type); + log.debug("Can't find subscription class: {}", type); return Subscription.class; } @@ -71,17 +71,17 @@ public class SubscriptionManager { subscriptions.add(subscription); } } catch (IllegalAccessException e) { - LOGGER.error("IllegalAccessException", e); + log.error("IllegalAccessException", e); } catch (InstantiationException e) { - LOGGER.error("InstantiationException", e); + log.error("InstantiationException", e); } catch (InvocationTargetException e) { - LOGGER.error("InvocationTargetException", e); + log.error("InvocationTargetException", e); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } catch (NoSuchMethodException e) { - LOGGER.error("Caught NoSuchMethodException", e); + log.error("Caught NoSuchMethodException", e); } return subscriptions; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java index 9f18a449..311fef37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java @@ -4,18 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.Scheduler; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.subscriptions.UserSubscriptionExpiredEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.Map; /** * @author Beny */ +@Slf4j public class SubscriptionScheduler extends Scheduler { - - private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionScheduler.class); - public SubscriptionScheduler() { super(Emulator.getConfig().getInt("subscriptions.scheduler.interval", 10)); this.reloadConfig(); @@ -45,7 +42,7 @@ public class SubscriptionScheduler extends Scheduler { try { if (habbo != null) { - for(Subscription subscription : habbo.getHabboStats().subscriptions) { + for(Subscription subscription : habbo.getHabboStats().getSubscriptions()) { if(subscription.isActive() && subscription.getRemaining() < 0) { if (!Emulator.getPluginManager().fireEvent(new UserSubscriptionExpiredEvent(habbo.getHabboInfo().getId(), subscription)).isCancelled()) { subscription.onExpired(); @@ -55,7 +52,7 @@ public class SubscriptionScheduler extends Scheduler { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java index 748bff4f..de585d1d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java @@ -1,15 +1,15 @@ package com.eu.habbo.habbohotel.wired; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +@Getter +@AllArgsConstructor public class WiredChangeDirectionSetting { - public final int item_id; - public int rotation; - public RoomUserRotation direction; + private final int item_id; + private int rotation; + @Setter private RoomUserRotation direction; - public WiredChangeDirectionSetting(int itemId, int rotation, RoomUserRotation direction) { - this.item_id = itemId; - this.rotation = rotation; - this.direction = direction; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java index 86ffa573..95c29d23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.wired; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum WiredConditionType { MATCH_SSHOT(0), FURNI_HAVE_HABBO(1), @@ -26,9 +31,5 @@ public enum WiredConditionType { DATE_RANGE(24), ACTOR_HAS_HANDITEM(25); - public final int code; - - WiredConditionType(int code) { - this.code = code; - } + private final int code; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java index 951e4d0c..7e6b1089 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.wired; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum WiredEffectType { TOGGLE_STATE(0), RESET_TIMERS(1), @@ -28,9 +33,5 @@ public enum WiredEffectType { BOT_CLOTHES(26), BOT_TALK_TO_AVATAR(27); - public final int code; - - WiredEffectType(int code) { - this.code = code; - } + private final int code; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java index dd6ac237..8f45c239 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java @@ -1,25 +1,24 @@ package com.eu.habbo.habbohotel.wired; -public class WiredGiveRewardItem { - public final int id; - public final boolean badge; - public final String data; - public final int probability; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class WiredGiveRewardItem { + private final int id; + private final boolean badge; + private final String data; + private final int probability; - public WiredGiveRewardItem(int id, boolean badge, String data, int probability) { - this.id = id; - this.badge = badge; - this.data = data; - this.probability = probability; - } public WiredGiveRewardItem(String dataString) { String[] data = dataString.split(","); - this.id = Integer.valueOf(data[0]); + this.id = Integer.parseInt(data[0]); this.badge = data[1].equalsIgnoreCase("0"); this.data = data[2]; - this.probability = Integer.valueOf(data[3]); + this.probability = Integer.parseInt(data[3]); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index c510352a..e60a2085 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -19,8 +19,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import com.eu.habbo.messages.outgoing.wired.WiredRewardResultMessageComposer; import com.eu.habbo.plugin.events.furniture.wired.WiredConditionFailedEvent; @@ -29,8 +29,7 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceived; import com.google.gson.GsonBuilder; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -40,8 +39,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +@Slf4j public class WiredHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredHandler.class); //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_FURNI_SELECTION = 5; @@ -119,7 +118,7 @@ public class WiredHandler { return false; long millis = System.currentTimeMillis(); - THashSet effectsToExecute = new THashSet(); + THashSet effectsToExecute = new THashSet<>(); List triggeredTiles = new ArrayList<>(); for (InteractionWiredTrigger trigger : triggers) { @@ -130,7 +129,7 @@ public class WiredHandler { if (triggeredTiles.contains(tile)) continue; - THashSet tEffectsToExecute = new THashSet(); + THashSet tEffectsToExecute = new THashSet<>(); if (handle(trigger, roomUnit, room, stuff, tEffectsToExecute)) { effectsToExecute.addAll(tEffectsToExecute); @@ -147,7 +146,7 @@ public class WiredHandler { public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) { long millis = System.currentTimeMillis(); - THashSet effectsToExecute = new THashSet(); + THashSet effectsToExecute = new THashSet<>(); if(handle(trigger, roomUnit, room, stuff, effectsToExecute)) { for (InteractionWiredEffect effect : effectsToExecute) { @@ -239,7 +238,7 @@ public class WiredHandler { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } effect.activateBox(room, roomUnit, millis); @@ -281,7 +280,7 @@ public class WiredHandler { statement.setInt(1, wiredId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -292,15 +291,15 @@ public class WiredHandler { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wired_rewards_given (wired_item, user_id, reward_id, timestamp) VALUES ( ?, ?, ?, ?)")) { statement.setInt(1, wiredBox.getId()); statement.setInt(2, habbo.getHabboInfo().getId()); - statement.setInt(3, reward.id); + statement.setInt(3, reward.getId()); statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - if (reward.badge) { - UserWiredRewardReceived rewardReceived = new UserWiredRewardReceived(habbo, wiredBox, "badge", reward.data); + if (reward.isBadge()) { + UserWiredRewardReceived rewardReceived = new UserWiredRewardReceived(habbo, wiredBox, "badge", reward.getData()); if (Emulator.getPluginManager().fireEvent(rewardReceived).isCancelled()) return; @@ -316,7 +315,7 @@ public class WiredHandler { habbo.getClient().sendResponse(new BadgeReceivedComposer(badge)); habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_BADGE)); } else { - String[] data = reward.data.split("#"); + String[] data = reward.getData().split("#"); if (data.length == 2) { UserWiredRewardReceived rewardReceived = new UserWiredRewardReceived(habbo, wiredBox, data[0], data[1]); @@ -356,7 +355,7 @@ public class WiredHandler { } } } else if (rewardReceived.type.equalsIgnoreCase("respect")) { - habbo.getHabboStats().respectPointsReceived += Integer.parseInt(rewardReceived.value); + habbo.getHabboStats().increaseRespectPointsReceived(Integer.parseInt(rewardReceived.value)); } else if (rewardReceived.type.equalsIgnoreCase("cata")) { CatalogItem item = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(Integer.parseInt(rewardReceived.value)); @@ -428,7 +427,7 @@ public class WiredHandler { boolean found = false; while (set.next()) { - if (set.getInt("reward_id") == item.id) + if (set.getInt("reward_id") == item.getId()) found = true; } @@ -442,18 +441,18 @@ public class WiredHandler { int count = 0; for (WiredGiveRewardItem item : wiredBox.rewardItems) { - if (randomNumber >= count && randomNumber <= (count + item.probability)) { + if (randomNumber >= count && randomNumber <= (count + item.getProbability())) { giveReward(habbo, wiredBox, item); return true; } - count += item.probability; + count += item.getProbability(); } } } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java index 7771450b..2e45f17a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java @@ -1,11 +1,14 @@ package com.eu.habbo.habbohotel.wired; +import lombok.Getter; + +@Getter public class WiredMatchFurniSetting { - public final int item_id; - public final String state; - public final int rotation; - public final int x; - public final int y; + private final int item_id; + private final String state; + private final int rotation; + private final int x; + private final int y; public WiredMatchFurniSetting(int itemId, String state, int rotation, int x, int y) { this.item_id = itemId; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java index e1286fa1..2a85990b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java @@ -1,5 +1,10 @@ package com.eu.habbo.habbohotel.wired; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum WiredTriggerType { SAY_SOMETHING(0), WALKS_ON_FURNI(1), @@ -22,9 +27,5 @@ public enum WiredTriggerType { STARTS_DANCING(11), STOPS_DANCING(11); - public final int code; - - WiredTriggerType(int code) { - this.code = code; - } + private final int code; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java index 602daa09..64192a2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java @@ -1,14 +1,17 @@ package com.eu.habbo.habbohotel.wired.highscores; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum WiredHighscoreClearType { ALLTIME(0), DAILY(1), WEEKLY(2), MONTHLY(3); - public final int type; + private final int type; + - WiredHighscoreClearType(int type) { - this.type = type; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java index e063d05e..659119ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java @@ -1,11 +1,16 @@ package com.eu.habbo.habbohotel.wired.highscores; +import lombok.AllArgsConstructor; +import lombok.Getter; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +@AllArgsConstructor +@Getter public class WiredHighscoreDataEntry { private final int itemId; private final List userIds; @@ -13,13 +18,6 @@ public class WiredHighscoreDataEntry { private final boolean isWin; private final int timestamp; - public WiredHighscoreDataEntry(int itemId, List userIds, int score, boolean isWin, int timestamp) { - this.itemId = itemId; - this.userIds = userIds; - this.score = score; - this.isWin = isWin; - this.timestamp = timestamp; - } public WiredHighscoreDataEntry(ResultSet set) throws SQLException { this.itemId = set.getInt("item_id"); @@ -28,24 +26,4 @@ public class WiredHighscoreDataEntry { this.isWin = set.getInt("is_win") == 1; this.timestamp = set.getInt("timestamp"); } - - public int getItemId() { - return itemId; - } - - public List getUserIds() { - return userIds; - } - - public int getScore() { - return score; - } - - public boolean isWin() { - return isWin; - } - - public int getTimestamp() { - return timestamp; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index e7cf9cef..1baa7ad6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -3,24 +3,28 @@ package com.eu.habbo.habbohotel.wired.highscores; import com.eu.habbo.Emulator; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.time.*; +import java.time.DayOfWeek; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.time.temporal.TemporalAdjusters; import java.time.temporal.WeekFields; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; import java.util.concurrent.ScheduledFuture; import java.util.stream.Collectors; import java.util.stream.Stream; +@Slf4j public class WiredHighscoreManager { - private static final Logger LOGGER = LoggerFactory.getLogger(WiredHighscoreManager.class); - private final HashMap> data = new HashMap<>(); private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en"); @@ -38,7 +42,7 @@ public class WiredHighscoreManager { this.data.clear(); this.loadHighscoreData(); - LOGGER.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + log.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); } @EventHandler @@ -72,7 +76,7 @@ public class WiredHighscoreManager { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -85,14 +89,14 @@ public class WiredHighscoreManager { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `items_highscore_data` (`item_id`, `user_ids`, `score`, `is_win`, `timestamp`) VALUES (?, ?, ?, ?, ?)")) { statement.setInt(1, entry.getItemId()); - statement.setString(2, String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList()))); + statement.setString(2, entry.getUserIds().stream().map(Object::toString).collect(Collectors.joining(","))); statement.setInt(3, entry.getScore()); statement.setInt(4, entry.isWin() ? 1 : 0); statement.setInt(5, entry.getTimestamp()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } @@ -115,11 +119,10 @@ public class WiredHighscoreManager { if (scoreType == WiredHighscoreScoreType.PERTEAM) { return highscores .collect(Collectors.groupingBy(h -> h.getUsers().hashCode())) - .entrySet() + .values() .stream() - .map(e -> e.getValue().stream() - .sorted(WiredHighscoreRow::compareTo) - .collect(Collectors.toList()) + .map(wiredHighscoreRows -> wiredHighscoreRows.stream() + .sorted(WiredHighscoreRow::compareTo).toList() .get(0) ) .sorted(WiredHighscoreRow::compareTo) @@ -129,9 +132,9 @@ public class WiredHighscoreManager { if (scoreType == WiredHighscoreScoreType.MOSTWIN) { return highscores .collect(Collectors.groupingBy(h -> h.getUsers().hashCode())) - .entrySet() + .values() .stream() - .map(e -> new WiredHighscoreRow(e.getValue().get(0).getUsers(), e.getValue().size())) + .map(wiredHighscoreRows -> new WiredHighscoreRow(wiredHighscoreRows.get(0).getUsers(), wiredHighscoreRows.size())) .sorted(WiredHighscoreRow::compareTo) .collect(Collectors.toList()); } @@ -140,18 +143,16 @@ public class WiredHighscoreManager { } private boolean timeMatchesEntry(WiredHighscoreDataEntry entry, WiredHighscoreClearType timeType) { - switch (timeType) { - case DAILY: - return entry.getTimestamp() > this.getTodayStartTimestamp() && entry.getTimestamp() < this.getTodayEndTimestamp(); - case WEEKLY: - return entry.getTimestamp() > this.getWeekStartTimestamp() && entry.getTimestamp() < this.getWeekEndTimestamp(); - case MONTHLY: - return entry.getTimestamp() > this.getMonthStartTimestamp() && entry.getTimestamp() < this.getMonthEndTimestamp(); - case ALLTIME: - return true; - } + return switch (timeType) { + case DAILY -> + entry.getTimestamp() > this.getTodayStartTimestamp() && entry.getTimestamp() < this.getTodayEndTimestamp(); + case WEEKLY -> + entry.getTimestamp() > this.getWeekStartTimestamp() && entry.getTimestamp() < this.getWeekEndTimestamp(); + case MONTHLY -> + entry.getTimestamp() > this.getMonthStartTimestamp() && entry.getTimestamp() < this.getMonthEndTimestamp(); + case ALLTIME -> true; + }; - return false; } private long getTodayStartTimestamp() { diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java index d70e07ed..1b549957 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java @@ -1,13 +1,14 @@ package com.eu.habbo.habbohotel.wired.highscores; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum WiredHighscoreScoreType { PERTEAM(0), MOSTWIN(1), CLASSIC(2); - public final int type; - - WiredHighscoreScoreType(int type) { - this.type = type; - } + private final int type; } diff --git a/src/main/java/com/eu/habbo/messages/ClientMessage.java b/src/main/java/com/eu/habbo/messages/ClientMessage.java index 55fdae44..0e546f37 100644 --- a/src/main/java/com/eu/habbo/messages/ClientMessage.java +++ b/src/main/java/com/eu/habbo/messages/ClientMessage.java @@ -3,39 +3,28 @@ package com.eu.habbo.messages; import com.eu.habbo.util.PacketUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import lombok.Getter; +@Getter public class ClientMessage { - private final int header; + private final int messageId; private final ByteBuf buffer; public ClientMessage(int messageId, ByteBuf buffer) { - this.header = messageId; + this.messageId = messageId; this.buffer = ((buffer == null) || (buffer.readableBytes() == 0) ? Unpooled.EMPTY_BUFFER : buffer); } - public ByteBuf getBuffer() { - return this.buffer; - } - public int getMessageId() { - return this.header; - } - - - /** - * - * @return - * @throws CloneNotSupportedException - */ @Override - public ClientMessage clone() throws CloneNotSupportedException { - return new ClientMessage(this.header, this.buffer.duplicate()); + public ClientMessage clone() { + return new ClientMessage(this.messageId, this.buffer.duplicate()); } public int readShort() { try { return this.buffer.readShort(); - } catch (Exception e) { + } catch (Exception ignored) { } return 0; @@ -44,7 +33,7 @@ public class ClientMessage { public Integer readInt() { try { return this.buffer.readInt(); - } catch (Exception e) { + } catch (Exception ignored) { } return 0; @@ -53,7 +42,7 @@ public class ClientMessage { public boolean readBoolean() { try { return this.buffer.readByte() == 1; - } catch (Exception e) { + } catch (Exception ignored) { } return false; diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 565b4da3..a4dfcb55 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.incoming.achievements.RequestAchievementConfigurationEvent; import com.eu.habbo.messages.incoming.achievements.GetAchievementsEvent; +import com.eu.habbo.messages.incoming.achievements.RequestAchievementConfigurationEvent; import com.eu.habbo.messages.incoming.ambassadors.AmbassadorAlertEvent; import com.eu.habbo.messages.incoming.ambassadors.FollowFriendEvent; import com.eu.habbo.messages.incoming.camera.*; @@ -13,10 +13,10 @@ import com.eu.habbo.messages.incoming.campaign.OpenCampaignCalendarDoorAsStaffEv import com.eu.habbo.messages.incoming.campaign.OpenCampaignCalendarDoorEvent; import com.eu.habbo.messages.incoming.catalog.*; import com.eu.habbo.messages.incoming.catalog.marketplace.*; +import com.eu.habbo.messages.incoming.catalog.recycler.GetRecyclerPrizesEvent; +import com.eu.habbo.messages.incoming.catalog.recycler.GetRecyclerStatusEvent; import com.eu.habbo.messages.incoming.catalog.recycler.PresentOpenEvent; import com.eu.habbo.messages.incoming.catalog.recycler.RecycleItemsEvent; -import com.eu.habbo.messages.incoming.catalog.recycler.GetRecyclerStatusEvent; -import com.eu.habbo.messages.incoming.catalog.recycler.GetRecyclerPrizesEvent; import com.eu.habbo.messages.incoming.crafting.*; import com.eu.habbo.messages.incoming.floorplaneditor.GetOccupiedTilesEvent; import com.eu.habbo.messages.incoming.floorplaneditor.GetRoomEntryTileEvent; @@ -33,54 +33,48 @@ import com.eu.habbo.messages.incoming.handshake.*; import com.eu.habbo.messages.incoming.helper.GetCfhStatusEvent; import com.eu.habbo.messages.incoming.helper.GetTalentTrackEvent; import com.eu.habbo.messages.incoming.hotelview.*; -import com.eu.habbo.messages.incoming.inventory.GetBadgesEvent; -import com.eu.habbo.messages.incoming.inventory.GetBotInventoryEvent; -import com.eu.habbo.messages.incoming.inventory.RequestFurniInventoryWhenNotInRoomEvent; -import com.eu.habbo.messages.incoming.inventory.GetPetInventoryEvent; +import com.eu.habbo.messages.incoming.inventory.*; import com.eu.habbo.messages.incoming.modtool.*; import com.eu.habbo.messages.incoming.navigator.*; import com.eu.habbo.messages.incoming.polls.AnswerPollEvent; import com.eu.habbo.messages.incoming.polls.PollRejectEvent; import com.eu.habbo.messages.incoming.polls.PollStartEvent; import com.eu.habbo.messages.incoming.rooms.*; -import com.eu.habbo.messages.incoming.rooms.bots.RemoveBotFromFlatEvent; -import com.eu.habbo.messages.incoming.rooms.bots.PlaceBotEvent; import com.eu.habbo.messages.incoming.rooms.bots.CommandBotEvent; import com.eu.habbo.messages.incoming.rooms.bots.GetBotCommandConfigurationDataEvent; +import com.eu.habbo.messages.incoming.rooms.bots.PlaceBotEvent; +import com.eu.habbo.messages.incoming.rooms.bots.RemoveBotFromFlatEvent; import com.eu.habbo.messages.incoming.rooms.items.*; import com.eu.habbo.messages.incoming.rooms.items.jukebox.*; import com.eu.habbo.messages.incoming.rooms.items.lovelock.FriendFurniConfirmLockEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentableSpaceCancelRentEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentableSpaceRentEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.SetYoutubeDisplayPlaylistEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.GetYoutubeDisplayStatusEvent; import com.eu.habbo.messages.incoming.rooms.items.youtube.ControlYoutubeDisplayPlaybackEvent; +import com.eu.habbo.messages.incoming.rooms.items.youtube.GetYoutubeDisplayStatusEvent; +import com.eu.habbo.messages.incoming.rooms.items.youtube.SetYoutubeDisplayPlaylistEvent; import com.eu.habbo.messages.incoming.rooms.pets.*; -import com.eu.habbo.messages.incoming.rooms.promotions.PurchaseRoomAdEvent; -import com.eu.habbo.messages.incoming.rooms.promotions.GetRoomAdPurchaseInfoEvent; import com.eu.habbo.messages.incoming.rooms.promotions.EditEventEvent; +import com.eu.habbo.messages.incoming.rooms.promotions.GetRoomAdPurchaseInfoEvent; +import com.eu.habbo.messages.incoming.rooms.promotions.PurchaseRoomAdEvent; import com.eu.habbo.messages.incoming.rooms.users.*; import com.eu.habbo.messages.incoming.trading.*; import com.eu.habbo.messages.incoming.unknown.GetResolutionAchievementsEvent; -import com.eu.habbo.messages.incoming.inventory.GetBadgePointLimitsEvent; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.ApplySnapshotEvent; -import com.eu.habbo.messages.incoming.wired.UpdateConditionEvent; import com.eu.habbo.messages.incoming.wired.UpdateActionEvent; +import com.eu.habbo.messages.incoming.wired.UpdateConditionEvent; import com.eu.habbo.messages.incoming.wired.UpdateTriggerEvent; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.List; +@Slf4j public class PacketManager { - private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); - private static final List logList = new ArrayList<>(); public static boolean DEBUG_SHOW_PACKETS = false; public static boolean MULTI_THREADED_PACKET_HANDLING = false; @@ -129,7 +123,7 @@ public class PacketManager { for (String s : Emulator.getConfig().getValue("debug.show.headers").split(";")) { try { - logList.add(Integer.valueOf(s)); + logList.add(Integer.parseInt(s)); } catch (NumberFormatException ignored) { } @@ -176,7 +170,7 @@ public class PacketManager { if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { if (DEBUG_SHOW_PACKETS) { - LOGGER.warn("Client packet {} requires an authenticated session.", packet.getMessageId()); + log.warn("Client packet {} requires an authenticated session.", packet.getMessageId()); } return; @@ -187,7 +181,7 @@ public class PacketManager { if (handler.getRatelimit() > 0) { if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) { if (PacketManager.DEBUG_SHOW_PACKETS) { - LOGGER.warn("Client packet {} was ratelimited.", packet.getMessageId()); + log.warn("Client packet {} was ratelimited.", packet.getMessageId()); } return; @@ -197,7 +191,7 @@ public class PacketManager { } if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) { - LOGGER.info("User {} sent packet {} with body {}", client.getHabbo().getHabboInfo().getUsername(), packet.getMessageId(), packet.getMessageBody()); + log.info("User {} sent packet {} with body {}", client.getHabbo().getHabboInfo().getUsername(), packet.getMessageId(), packet.getMessageBody()); } handler.client = client; @@ -214,7 +208,7 @@ public class PacketManager { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/PacketNames.java b/src/main/java/com/eu/habbo/messages/PacketNames.java index 4fa159ec..5028fe3a 100644 --- a/src/main/java/com/eu/habbo/messages/PacketNames.java +++ b/src/main/java/com/eu/habbo/messages/PacketNames.java @@ -2,16 +2,15 @@ package com.eu.habbo.messages; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; +@Slf4j public class PacketNames { - private static final Logger LOGGER = LoggerFactory.getLogger(PacketNames.class); private final HashMap incoming; private final HashMap outgoing; @@ -42,14 +41,14 @@ public class PacketNames { int packetId = field.getInt(null); if (packetId > 0) { if (target.containsKey(packetId)) { - LOGGER.warn("Duplicate packet id found {} for {}.", packetId, clazz.getSimpleName()); + log.warn("Duplicate packet id found {} for {}.", packetId, clazz.getSimpleName()); continue; } target.put(packetId, field.getName()); } } catch (IllegalAccessException e) { - LOGGER.error("Failed to read field integer.", e); + log.error("Failed to read field integer.", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/ServerMessage.java b/src/main/java/com/eu/habbo/messages/ServerMessage.java index 91f52457..fbf3c17c 100644 --- a/src/main/java/com/eu/habbo/messages/ServerMessage.java +++ b/src/main/java/com/eu/habbo/messages/ServerMessage.java @@ -4,15 +4,14 @@ import com.eu.habbo.util.PacketUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; +@Slf4j public class ServerMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class); private boolean initialized; private int header; diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/PublishPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/PublishPhotoEvent.java index af447f3d..0412a8cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/PublishPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/PublishPhotoEvent.java @@ -6,15 +6,14 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPublishStatusMessageComposer; import com.eu.habbo.messages.outgoing.catalog.NotEnoughBalanceMessageComposer; import com.eu.habbo.plugin.events.users.UserPublishPictureEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class PublishPhotoEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(PublishPhotoEvent.class); public static int CAMERA_PUBLISH_POINTS = 5; public static int CAMERA_PUBLISH_POINTS_TYPE = 0; @@ -54,7 +53,7 @@ public class PublishPhotoEvent extends MessageHandler { isOk = true; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java index 32acc489..b16eebda 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPurchaseOKMessageComposer; import com.eu.habbo.messages.outgoing.catalog.NotEnoughBalanceMessageComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent; public class PurchasePhotoEvent extends MessageHandler { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java index f201dfe1..ebbf4ecc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java @@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory; public class BuildersClubPlaceWallItemEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(BuildersClubPlaceWallItemEvent.class); - @Override public void handle() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java index d0661aea..982df6cf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java @@ -16,18 +16,17 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.*; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.users.HabboActivityPointNotificationMessageComposer; import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -35,24 +34,23 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; +@Slf4j public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseFromCatalogAsGiftEvent.class); - @Override public void handle() throws Exception { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastGiftTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { - this.client.getHabbo().getHabboStats().lastGiftTimestamp = Emulator.getIntUnixTimestamp(); + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().getLastGiftTimestamp() >= CatalogManager.PURCHASE_COOLDOWN) { + this.client.getHabbo().getHabboStats().setLastGiftTimestamp(Emulator.getIntUnixTimestamp()); if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose()); return; } - if (this.client.getHabbo().getHabboStats().isPurchasingFurniture) { + if (this.client.getHabbo().getHabboStats().isPurchasingFurniture()) { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose()); return; } else { - this.client.getHabbo().getHabboStats().isPurchasingFurniture = true; + this.client.getHabbo().getHabboStats().setPurchasingFurniture(true); } try { @@ -67,7 +65,6 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { int ribbonId = this.packet.readInt(); boolean showName = this.packet.readBoolean(); - int count = 1; int userId = 0; if (!Emulator.getGameEnvironment().getCatalogManager().giftWrappers.containsKey(spriteId) && !Emulator.getGameEnvironment().getCatalogManager().giftFurnis.containsKey(spriteId)) { @@ -118,7 +115,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } else { userId = habbo.getHabboInfo().getId(); @@ -180,7 +177,6 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { int limitedStack = 0; int limitedNumber = 0; if (item.isLimited()) { - count = 1; if (Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item).available() == 0 && habbo != null) { habbo.getClient().sendResponse(new LimitedEditionSoldOutComposer()); return; @@ -294,7 +290,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { try { guildId = Integer.parseInt(extraData); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -344,7 +340,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { if (showName) { keys.put("message", Emulator.getTexts().getValue("generic.gift.received").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); + habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys)); } if (this.client.getHabbo().getHabboInfo().getId() != userId) { @@ -358,20 +354,20 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { } if (totalPoints > 0) { if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_PIXELS)) { - this.client.getHabbo().getHabboInfo().addPixels(-totalPoints); + this.client.getHabbo().givePixels(-totalPoints); } else if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) { - this.client.getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -totalPoints); + this.client.getHabbo().givePoints(item.getPointsType(), -totalPoints); } this.client.sendResponse(new HabboActivityPointNotificationMessageComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -totalPoints, item.getPointsType())); } this.client.sendResponse(new PurchaseOKMessageComposer(item)); } catch (Exception e) { - LOGGER.error("Exception caught", e); + log.error("Exception caught", e); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); } } finally { - this.client.getHabbo().getHabboStats().isPurchasingFurniture = false; + this.client.getHabbo().getHabboStats().setPurchasingFurniture(false); } } else { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java index 2269e249..ce67f7ab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java @@ -15,15 +15,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseNotAllowedMessageComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; -import com.eu.habbo.messages.outgoing.users.*; +import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer; +import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; +import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TObjectProcedure; import org.apache.commons.lang3.StringUtils; import static com.eu.habbo.messages.incoming.catalog.ApproveNameEvent.PET_NAME_LENGTH_MAXIMUM; @@ -34,8 +35,8 @@ public class PurchaseFromCatalogEvent extends MessageHandler { @Override public void handle() throws Exception { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().getLastPurchaseTimestamp() >= CatalogManager.PURCHASE_COOLDOWN) { + this.client.getHabbo().getHabboStats().setLastPurchaseTimestamp(Emulator.getIntUnixTimestamp()); if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); return; @@ -83,12 +84,9 @@ public class PurchaseFromCatalogEvent extends MessageHandler { if (page instanceof RoomBundleLayout) { final CatalogItem[] item = new CatalogItem[1]; - page.getCatalogItems().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogItem object) { - item[0] = object; - return false; - } + page.getCatalogItems().forEachValue(object -> { + item[0] = object; + return false; }); CatalogItem roomBundleItem = item[0]; @@ -126,7 +124,7 @@ public class PurchaseFromCatalogEvent extends MessageHandler { keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); //:test 1992 s:npc.gift.received i:2 s:npc_name s:Admin s:image s:${image.library.url}album1584/ADM.gif); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys)); //:test 1992 s:npc.gift.received i:2 s:npc_name s:Admin s:image s:${image.library.url}album1584/ADM.gif); } else { badgeFound[0] = true; } @@ -176,10 +174,10 @@ public class PurchaseFromCatalogEvent extends MessageHandler { return; if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) - this.client.getHabbo().getHabboInfo().addCredits(-totalCredits); + this.client.getHabbo().giveCredits(-totalCredits); if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) - this.client.getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -totalDuckets); + this.client.getHabbo().givePoints(item.getPointsType(), -totalDuckets); if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetedOfferEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetedOfferEvent.java index c7666a5d..9038fc36 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetedOfferEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetedOfferEvent.java @@ -17,8 +17,8 @@ public class PurchaseTargetedOfferEvent extends MessageHandler { if (amount <= 0) return; - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().getLastPurchaseTimestamp() >= CatalogManager.PURCHASE_COOLDOWN) { + this.client.getHabbo().getHabboStats().setLastPurchaseTimestamp(Emulator.getIntUnixTimestamp()); TargetOffer offer = Emulator.getGameEnvironment().getCatalogManager().getTargetOffer(offerId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java index eb5eceb2..903e4c31 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java @@ -9,15 +9,10 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; -import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; public class PurchaseVipMembershipExtensionEvent extends MessageHandler { - - private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseVipMembershipExtensionEvent.class); - @Override public void handle() throws Exception { @@ -56,10 +51,10 @@ public class PurchaseVipMembershipExtensionEvent extends MessageHandler { return; if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) - this.client.getHabbo().getHabboInfo().addCredits(-totalCredits); + this.client.getHabbo().giveCredits(-totalCredits); if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) - this.client.getHabbo().getHabboInfo().addCurrencyAmount(deal.getPointsType(), -totalDuckets); + this.client.getHabbo().givePoints(deal.getPointsType(), -totalDuckets); if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubDataEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/SelectClubGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/SelectClubGiftEvent.java index 82bc662c..555f8e7a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/SelectClubGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/SelectClubGiftEvent.java @@ -6,29 +6,27 @@ import com.eu.habbo.habbohotel.catalog.CatalogPage; import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.catalog.*; +import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.users.ClubGiftSelectedComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class SelectClubGiftEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(SelectClubGiftEvent.class); - @Override public void handle() throws Exception { String itemName = this.packet.readString(); if(itemName.isEmpty()) { - LOGGER.error("itemName is empty"); + log.error("itemName is empty"); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } if(this.client.getHabbo().getHabboStats().getRemainingClubGifts() < 1) { - LOGGER.error("User has no remaining club gifts"); + log.error("User has no remaining club gifts"); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -36,7 +34,7 @@ public class SelectClubGiftEvent extends MessageHandler { CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPageByLayout(CatalogPageLayouts.club_gift.name().toLowerCase()); if(page == null) { - LOGGER.error("Catalog page not found"); + log.error("Catalog page not found"); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -44,7 +42,7 @@ public class SelectClubGiftEvent extends MessageHandler { CatalogItem catalogItem = page.getCatalogItems().valueCollection().stream().filter(x -> x.getName().equalsIgnoreCase(itemName)).findAny().orElse(null); if(catalogItem == null) { - LOGGER.error("Catalog item not found"); + log.error("Catalog item not found"); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -56,7 +54,7 @@ public class SelectClubGiftEvent extends MessageHandler { catch (NumberFormatException ignored) { } if(daysRequired > (int) Math.floor(this.client.getHabbo().getHabboStats().getPastTimeAsClub() / 86400.0)) { - LOGGER.error("Not been member for long enough"); + log.error("Not been member for long enough"); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -68,7 +66,7 @@ public class SelectClubGiftEvent extends MessageHandler { } } - this.client.getHabbo().getHabboStats().hcGiftsClaimed++; + this.client.getHabbo().getHabboStats().setHcGiftsClaimed(this.client.getHabbo().getHabboStats().getHcGiftsClaimed()+1); Emulator.getThreading().run(this.client.getHabbo().getHabboStats()); this.client.sendResponse(new ClubGiftSelectedComposer(itemName, itemsGiven)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/GetMarketplaceOffersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/GetMarketplaceOffersEvent.java index be8c5714..c20a7a74 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/GetMarketplaceOffersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/GetMarketplaceOffersEvent.java @@ -20,10 +20,7 @@ public class GetMarketplaceOffersEvent extends MessageHandler { String query = this.packet.readString(); int type = this.packet.readInt(); - boolean tryCache = false; - if (min == -1 && max == -1 && query.isEmpty()) { - tryCache = true; - } + boolean tryCache = min == -1 && max == -1 && query.isEmpty(); if (tryCache) { ServerMessage message = cachedResults.get(type); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java index fe30a729..a7cca996 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java @@ -7,11 +7,10 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceMakeOfferResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class MakeOfferEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(MakeOfferEvent.class); @Override public void handle() throws Exception { @@ -30,7 +29,7 @@ public class MakeOfferEvent extends MessageHandler { if (!item.getBaseItem().allowMarketplace()) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } @@ -38,7 +37,7 @@ public class MakeOfferEvent extends MessageHandler { if (credits < 0) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.negative").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index a6ba8f88..4e416596 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.PresentOpenedMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; @@ -61,7 +61,7 @@ public class PresentOpenEvent extends MessageHandler { if(roomLayout != null) { RoomTile roomTile = roomLayout.getTile(item.getX(), item.getY()); if(roomTile != null) { - z = roomTile.z; + z = roomTile.getZ(); } } room.sendComposer(new HeightMapUpdateMessageComposer(item.getX(), item.getY(), z, room.getStackHeight(item.getX(), item.getY(), true)).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java index bf8db8f4..2524ba0b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java @@ -8,9 +8,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.RecyclerFinishedComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java index aa482a04..4c0f1a8e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java @@ -9,9 +9,9 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.LimitedEditionSoldOutComposer; import com.eu.habbo.messages.outgoing.crafting.CraftingResultComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; import gnu.trove.map.hash.TIntObjectHashMap; diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java index b1df8ee4..4cafc26a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java @@ -9,9 +9,9 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.LimitedEditionSoldOutComposer; import com.eu.habbo.messages.outgoing.crafting.CraftingResultComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index ad098356..42ba1143 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -6,13 +6,16 @@ import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.rooms.RoomForwardMessageComposer; import gnu.trove.set.hash.THashSet; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.StringJoiner; public class UpdateFloorPropertiesEvent extends MessageHandler { public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64; @@ -51,15 +54,15 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); } - if (map.length() > 64 * 64) { + if (map.length() > MAXIMUM_FLOORPLAN_SIZE) { errors.add("${notification.floorplan_editor.error.message.too_large_area}"); } - if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}"); - else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}"); + if (mapRows.length > MAXIMUM_FLOORPLAN_WIDTH_LENGTH) errors.add("${notification.floorplan_editor.error.message.too_large_height}"); + else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > MAXIMUM_FLOORPLAN_WIDTH_LENGTH || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}"); if (errors.length() > 0) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString())); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.getKey(), errors.toString())); return; } } @@ -121,7 +124,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { } } - if (tile != null && tile.state != RoomTileState.INVALID && height != tile.z && room.getTopItemAt(x, y) != null) { + if (tile != null && tile.getState() != RoomTileState.INVALID && height != tile.getZ() && room.getTopItemAt(x, y) != null) { errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); break blockingRoomItemScan; } @@ -136,7 +139,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { if (errors.length() > 0) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString())); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.getKey(), errors.toString())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java index beceef58..6ce732b1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java @@ -6,8 +6,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.MessengerErrorComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,8 +15,8 @@ import java.sql.SQLException; import static com.eu.habbo.habbohotel.users.HabboManager.getOfflineHabboInfo; +@Slf4j public class AcceptFriendEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AcceptFriendEvent.class); @Override public void handle() throws Exception { @@ -54,7 +53,7 @@ public class AcceptFriendEvent extends MessageHandler { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return; } } @@ -65,12 +64,12 @@ public class AcceptFriendEvent extends MessageHandler { continue; } - if(this.client.getHabbo().getMessenger().getFriends().size() >= this.client.getHabbo().getHabboStats().maxFriends && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { + if(this.client.getHabbo().getMessenger().getFriends().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_OWN_FULL)); break; } - if(target.getMessenger().getFriends().size() >= target.getHabboStats().maxFriends && !target.hasPermission("acc_infinite_friends")) { + if(target.getMessenger().getFriends().size() >= target.getHabboStats().getMaxFriends() && !target.hasPermission("acc_infinite_friends")) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_TARGET_FULL)); continue; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/HabboSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/HabboSearchEvent.java index 224df864..fe5bad75 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/HabboSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/HabboSearchEvent.java @@ -13,7 +13,7 @@ public class HabboSearchEvent extends MessageHandler { @Override public void handle() throws Exception { - if (System.currentTimeMillis() - this.client.getHabbo().getHabboStats().lastUsersSearched < 3000) + if (System.currentTimeMillis() - this.client.getHabbo().getHabboStats().getLastUsersSearched() < 3000) return; String username = this.packet.readString().replace(" ", "").toLowerCase(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java index 591a7949..ae22d45e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java @@ -4,11 +4,10 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.friends.NewFriendRequestComposer; import com.eu.habbo.messages.outgoing.friends.MessengerErrorComposer; +import com.eu.habbo.messages.outgoing.friends.NewFriendRequestComposer; import com.eu.habbo.plugin.events.users.friends.UserRequestFriendshipEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,9 +15,8 @@ import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class RequestFriendEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(RequestFriendEvent.class); - @Override public void handle() throws Exception { String username = this.packet.readString(); @@ -40,7 +38,7 @@ public class RequestFriendEvent extends MessageHandler { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return; } } @@ -51,7 +49,7 @@ public class RequestFriendEvent extends MessageHandler { } int targetId = targetHabbo.getHabboInfo().getId(); - boolean targetBlocksFriendRequests = targetHabbo.getHabboStats().blockFriendRequests; + boolean targetBlocksFriendRequests = targetHabbo.getHabboStats().isBlockFriendRequests(); // Making friends with yourself would be very pathetic, we try to avoid that if (targetId == this.client.getHabbo().getHabboInfo().getId()) @@ -65,13 +63,13 @@ public class RequestFriendEvent extends MessageHandler { } // You can only have x friends - if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().maxFriends && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { + if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_OWN_FULL)); return; } // Check if targets friendlist is full - if (targetHabbo.getMessenger().getFriends().values().size() >= targetHabbo.getHabboStats().maxFriends && !targetHabbo.hasPermission("acc_infinite_friends")) { + if (targetHabbo.getMessenger().getFriends().values().size() >= targetHabbo.getHabboStats().getMaxFriends() && !targetHabbo.hasPermission("acc_infinite_friends")) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_TARGET_FULL)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/SendMsgEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/SendMsgEvent.java index 6878e48d..9ea0321f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/SendMsgEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/SendMsgEvent.java @@ -16,10 +16,10 @@ public class SendMsgEvent extends MessageHandler { } long millis = System.currentTimeMillis(); - if (millis - this.client.getHabbo().getHabboStats().lastChat < 750) { + if (millis - this.client.getHabbo().getHabboStats().getLastChat() < 750) { return; } - this.client.getHabbo().getHabboStats().lastChat = millis; + this.client.getHabbo().getHabboStats().setLastChat(millis); MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(userId); if (buddy == null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/SendRoomInviteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/SendRoomInviteEvent.java index 63dc2969..f4aa8bf8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/SendRoomInviteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/SendRoomInviteEvent.java @@ -26,7 +26,7 @@ public class SendRoomInviteEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(i); if (habbo != null) { - if (!habbo.getHabboStats().blockRoomInvites) { + if (!habbo.getHabboStats().isBlockRoomInvites()) { habbo.getClient().sendResponse(new RoomInviteComposer(this.client.getHabbo().getHabboInfo().getId(), message)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java index 6715a728..c7bd9988 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java @@ -29,7 +29,7 @@ public class VisitUserEvent extends MessageHandler { return; } - if (habbo.getHabboStats().blockFollowing && !this.client.getHabbo().hasPermission("acc_can_stalk")) { + if (habbo.getHabboStats().isBlockFollowing() && !this.client.getHabbo().hasPermission("acc_can_stalk")) { this.client.sendResponse(new FollowFriendFailedComposer(FollowFriendFailedComposer.FRIEND_BLOCKED_STALKING)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guardians/ChatReviewGuideVoteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guardians/ChatReviewGuideVoteEvent.java index ad61a031..f186b37f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guardians/ChatReviewGuideVoteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guardians/ChatReviewGuideVoteEvent.java @@ -4,11 +4,10 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuardianTicket; import com.eu.habbo.habbohotel.guides.GuardianVoteType; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ChatReviewGuideVoteEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ChatReviewGuideVoteEvent.class); @Override public void handle() throws Exception { @@ -26,7 +25,7 @@ public class ChatReviewGuideVoteEvent extends MessageHandler { } else if (voteType == 2) { type = GuardianVoteType.AWFULLY; } else { - LOGGER.error("Uknown vote type: " + voteType); + log.error("Uknown vote type: " + voteType); } ticket.vote(this.client.getHabbo(), type); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java index bc5ca6cb..c3c68791 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java @@ -41,7 +41,7 @@ public class ApproveMembershipRequestEvent extends MessageHandler { if (!Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true)) return; GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId); - if (member == null || member.getRank().type != GuildRank.REQUESTED.type) { + if (member == null || member.getRank().getType() != GuildRank.REQUESTED.getType()) { this.client.sendResponse(new GuildMemberMgmtFailedMessageComposer(guild.getId(), GuildMemberMgmtFailedMessageComposer.NO_LONGER_MEMBER)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java index 36c16df6..eb8b2d2b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java @@ -13,11 +13,10 @@ import com.eu.habbo.messages.outgoing.guilds.GuildCreatedMessageComposer; import com.eu.habbo.messages.outgoing.guilds.GuildEditFailedMessageComposer; import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.plugin.events.guilds.GuildPurchasedEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CreateGuildEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CreateGuildEvent.class); @Override public void handle() throws Exception { @@ -59,7 +58,7 @@ public class CreateGuildEvent extends MessageHandler { int count = this.packet.readInt(); - String badge = ""; + StringBuilder badge = new StringBuilder(); byte base = 1; @@ -69,26 +68,19 @@ public class CreateGuildEvent extends MessageHandler { int pos = this.packet.readInt(); if (base == 1) { - badge += "b"; + badge.append("b"); } else { - badge += "s"; + badge.append("s"); } - badge += (id < 100 ? "0" : "") + (id < 10 ? "0" : "") + id + (color < 10 ? "0" : "") + color + "" + pos; + badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos); base += 3; } - if(name.length() > 29){ - this.client.sendResponse(new GuildEditFailedMessageComposer(GuildEditFailedMessageComposer.INVALID_GUILD_NAME)); - return; - } - if(description.length() > 254){ - return; - } - Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge, colorOne, colorTwo); + Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge.toString(), colorOne, colorTwo); - r.setGuild(guild.getId()); + r.setGuildId(guild.getId()); r.removeAllRights(); r.setNeedsUpdate(true); @@ -110,7 +102,7 @@ public class CreateGuildEvent extends MessageHandler { } else { String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName())); ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java index d74170e4..0fb88538 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java @@ -19,7 +19,7 @@ public class DeselectFavouriteHabboGroupEvent extends MessageHandler { if (favoriteEvent.isCancelled()) return; - this.client.getHabbo().getHabboStats().guild = 0; + this.client.getHabbo().getHabboStats().setGuild(0); if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(this.client.getHabbo().getRoomUnit(), null).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java index 18b90188..16c9210f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java @@ -13,7 +13,7 @@ public class GetGuildCreationInfoEvent extends MessageHandler { public void handle() throws Exception { List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()); - THashSet roomList = new THashSet(); + THashSet roomList = new THashSet<>(); for (Room room : rooms) { if (room.getGuildId() == 0) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java index 04bbc1c1..f15e85cf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java @@ -25,7 +25,7 @@ public class GetGuildMembersEvent extends MessageHandler { isAdmin = member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN)); } - this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query))); + this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, levelId, query))); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembershipsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembershipsEvent.java index e494e237..99c2cf5e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembershipsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembershipsEvent.java @@ -9,9 +9,9 @@ import gnu.trove.set.hash.THashSet; public class GetGuildMembershipsEvent extends MessageHandler { @Override public void handle() throws Exception { - THashSet guilds = new THashSet(); + THashSet guilds = new THashSet<>(); - for (int i : this.client.getHabbo().getHabboStats().guilds) { + for (int i : this.client.getHabbo().getHabboStats().getGuilds()) { if (i == 0) continue; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java index cf5e9b98..1a25180b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java @@ -9,8 +9,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.FavoriteMembershipUpdateMessageComposer; -import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMembershipRejectedMessageComposer; +import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent; public class KickMemberEvent extends MessageHandler { @@ -42,8 +42,8 @@ public class KickMemberEvent extends MessageHandler { if (habbo != null) { habbo.getHabboStats().removeGuild(guild.getId()); - if (habbo.getHabboStats().guild == guildId) - habbo.getHabboStats().guild = 0; + if (habbo.getHabboStats().getGuild() == guildId) + habbo.getHabboStats().setGuild(0); if (room != null) { if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java index a21621cd..595e2617 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java @@ -8,9 +8,9 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMembersComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMembershipRejectedMessageComposer; +import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.plugin.events.guilds.GuildDeclinedMembershipEvent; public class RejectMembershipRequestEvent extends MessageHandler { @@ -26,7 +26,7 @@ public class RejectMembershipRequestEvent extends MessageHandler { if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)|| member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { guild.decreaseRequestCount(); Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); - this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, ""))); + this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, ""))); this.client.sendResponse(new GuildMembershipRejectedMessageComposer(guild, userId)); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java index 613fbfd9..0f205b01 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMembershipUpdatedMessageComposer; +import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedAdminEvent; public class RemoveAdminRightsFromMemberEvent extends MessageHandler { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java index 7fbd920d..4ab0ed58 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java @@ -22,7 +22,7 @@ public class SelectFavouriteHabboGroupEvent extends MessageHandler { if (favoriteSetEvent.isCancelled()) return; - this.client.getHabbo().getHabboStats().guild = guildId; + this.client.getHabbo().getHabboStats().setGuild(guildId); if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { if (guild != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java index 9412d3a3..92c7bbb2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java @@ -22,7 +22,7 @@ public class UpdateGuildBadgeEvent extends MessageHandler { int count = this.packet.readInt(); - String badge = ""; + StringBuilder badge = new StringBuilder(); byte base = 1; @@ -32,20 +32,20 @@ public class UpdateGuildBadgeEvent extends MessageHandler { int pos = this.packet.readInt(); if (base == 1) { - badge += "b"; + badge.append("b"); } else { - badge += "s"; + badge.append("s"); } - badge += (id < 100 ? "0" : "") + (id < 10 ? "0" : "") + id + (color < 10 ? "0" : "") + color + "" + pos; + badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos); base += 3; } - if (guild.getBadge().toLowerCase().equals(badge.toLowerCase())) + if (guild.getBadge().equalsIgnoreCase(badge.toString())) return; - GuildChangedBadgeEvent badgeEvent = new GuildChangedBadgeEvent(guild, badge); + GuildChangedBadgeEvent badgeEvent = new GuildChangedBadgeEvent(guild, badge.toString()); Emulator.getPluginManager().fireEvent(badgeEvent); if (badgeEvent.isCancelled()) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetForumsListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetForumsListEvent.java index 1500cec3..f13eb6be 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetForumsListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetForumsListEvent.java @@ -6,8 +6,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.forums.ForumsListMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,8 +14,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Set; +@Slf4j public class GetForumsListEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(GetForumsListEvent.class); @Override public void handle() throws Exception { @@ -24,20 +23,15 @@ public class GetForumsListEvent extends MessageHandler { int offset = this.packet.readInt(); int amount = this.packet.readInt(); - Set guilds = null; - switch (mode) { - case 0: // most active - guilds = getActiveForums(); - break; - - case 1: // most viewed - guilds = Emulator.getGameEnvironment().getGuildManager().getMostViewed(); - break; - - case 2: // my groups - guilds = getMyForums(this.client.getHabbo().getHabboInfo().getId()); - break; - } + Set guilds = switch (mode) { + case 0 -> // most active + getActiveForums(); + case 1 -> // most viewed + Emulator.getGameEnvironment().getGuildManager().getMostViewed(); + case 2 -> // my groups + getMyForums(this.client.getHabbo().getHabboInfo().getId()); + default -> null; + }; if (guilds != null) { this.client.sendResponse(new ForumsListMessageComposer(guilds, this.client.getHabbo(), mode, offset)); @@ -45,7 +39,7 @@ public class GetForumsListEvent extends MessageHandler { } private THashSet getActiveForums() { - THashSet guilds = new THashSet(); + THashSet guilds = new THashSet<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT `guilds`.`id`, SUM(`guilds_forums_threads`.`posts_count`) AS `post_count` " + "FROM `guilds_forums_threads` " + @@ -64,7 +58,7 @@ public class GetForumsListEvent extends MessageHandler { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); this.client.sendResponse(new ErrorReportComposer(500)); } @@ -72,7 +66,7 @@ public class GetForumsListEvent extends MessageHandler { } private THashSet getMyForums(int userId) { - THashSet guilds = new THashSet(); + THashSet guilds = new THashSet<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT `guilds`.`id` FROM `guilds_members` " + "LEFT JOIN `guilds` ON `guilds`.`id` = `guilds_members`.`guild_id` " + @@ -88,7 +82,7 @@ public class GetForumsListEvent extends MessageHandler { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); this.client.sendResponse(new ErrorReportComposer(500)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java index 0c710c36..2b70f354 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java @@ -9,9 +9,9 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -import com.eu.habbo.messages.outgoing.guilds.forums.ThreadMessagesMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.guilds.forums.ForumDataMessageComposer; +import com.eu.habbo.messages.outgoing.guilds.forums.ThreadMessagesMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; @@ -39,9 +39,9 @@ public class GetMessagesEvent extends MessageHandler { if (thread.getState() != ForumThreadState.HIDDEN_BY_GUILD_ADMIN || hasStaffPermissions || isGuildAdministrator) { this.client.sendResponse(new ThreadMessagesMessageComposer(guildId, threadId, index, thread.getComments(limit, index))); this.client.sendResponse(new ForumDataMessageComposer(guild, this.client.getHabbo())); - - } else { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose()); + } + else { + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.getKey()).compose()); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java index b38c92c8..5696c418 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java @@ -9,8 +9,8 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThreadComment; import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.guilds.forums.UpdateMessageMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; @@ -64,13 +64,10 @@ public class ModerateMessageEvent extends MessageHandler { Emulator.getThreading().run(comment); switch (state) { - case 10: - case 20: - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_MESSAGE_HIDDEN.key).compose()); - break; - case 1: - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_MESSAGE_RESTORED.key).compose()); - break; + case 10, 20 -> + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_MESSAGE_HIDDEN.getKey()).compose()); + case 1 -> + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_MESSAGE_RESTORED.getKey()).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java index 02b07e2d..75001eee 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java @@ -8,10 +8,10 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -import com.eu.habbo.messages.outgoing.guilds.forums.PostThreadMessageComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; +import com.eu.habbo.messages.outgoing.guilds.forums.PostThreadMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; @@ -50,13 +50,10 @@ public class ModerateThreadEvent extends MessageHandler { thread.run(); switch (state) { - case 10: - case 20: - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_THREAD_HIDDEN.key).compose()); - break; - case 1: - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_THREAD_RESTORED.key).compose()); - break; + case 10, 20 -> + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_THREAD_HIDDEN.getKey()).compose()); + case 1 -> + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_THREAD_RESTORED.getKey()).compose()); } this.client.sendResponse(new PostThreadMessageComposer(thread)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java index a22e6f27..2eb813e7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java @@ -46,10 +46,10 @@ public class PostMessageEvent extends MessageHandler { ForumThread thread = ForumThread.getById(threadId); if (threadId == 0) { - if (!((guild.canPostThreads().state == 0) - || (guild.canPostThreads().state == 1 && member != null) - || (guild.canPostThreads().state == 2 && member != null && (member.getRank().type < GuildRank.MEMBER.type)) - || (guild.canPostThreads().state == 3 && guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) + if (!((guild.canPostThreads().getState() == 0) + || (guild.canPostThreads().getState() == 1 && member != null) + || (guild.canPostThreads().getState() == 2 && member != null && (member.getRank().getType() < GuildRank.MEMBER.getType())) + || (guild.canPostThreads().getState() == 3 && guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) || isStaff)) { this.client.sendResponse(new ErrorReportComposer(403)); return; @@ -63,7 +63,7 @@ public class PostMessageEvent extends MessageHandler { return; } - this.client.getHabbo().getHabboStats().forumPostsCount += 1; + this.client.getHabbo().getHabboStats().setForumPostsCount(this.client.getHabbo().getHabboStats().getForumPostsCount()+1); thread.setPostsCount(thread.getPostsCount() + 1); this.client.sendResponse(new PostThreadMessageComposer(thread)); return; @@ -75,10 +75,10 @@ public class PostMessageEvent extends MessageHandler { } - if (!((guild.canPostMessages().state == 0) - || (guild.canPostMessages().state == 1 && member != null) - || (guild.canPostMessages().state == 2 && member != null && (member.getRank().type < GuildRank.MEMBER.type)) - || (guild.canPostMessages().state == 3 && guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) + if (!((guild.canPostMessages().getState() == 0) + || (guild.canPostMessages().getState() == 1 && member != null) + || (guild.canPostMessages().getState() == 2 && member != null && (member.getRank().getType() < GuildRank.MEMBER.getType())) + || (guild.canPostMessages().getState() == 3 && guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) || isStaff)) { this.client.sendResponse(new ErrorReportComposer(403)); return; @@ -89,7 +89,7 @@ public class PostMessageEvent extends MessageHandler { if (comment != null) { thread.addComment(comment); thread.setUpdatedAt(Emulator.getIntUnixTimestamp()); - this.client.getHabbo().getHabboStats().forumPostsCount += 1; + this.client.getHabbo().getHabboStats().setForumPostsCount(this.client.getHabbo().getHabboStats().getForumPostsCount()+1); thread.setPostsCount(thread.getPostsCount() + 1); this.client.sendResponse(new PostMessageMessageComposer(comment)); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateForumSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateForumSettingsEvent.java index 222612bd..5aa9bd8a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateForumSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateForumSettingsEvent.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.SettingsState; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.guilds.forums.ForumDataMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; @@ -39,7 +39,7 @@ public class UpdateForumSettingsEvent extends MessageHandler { Emulator.getThreading().run(guild); - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_FORUM_SETTINGS_UPDATED.key).compose()); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FORUMS_FORUM_SETTINGS_UPDATED.getKey()).compose()); this.client.sendResponse(new ForumDataMessageComposer(guild, this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java index ab9c8376..32b95f60 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.guilds.SettingsState; import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.UpdateThreadMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; @@ -38,7 +38,7 @@ public class UpdateThreadEvent extends MessageHandler { return; } - boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().type < GuildRank.MEMBER.type); + boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().getType() < GuildRank.MEMBER.getType()); if ((guild.canModForum() == SettingsState.OWNER && guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() && !isStaff) || (guild.canModForum() == SettingsState.ADMINS && !isAdmin && !isStaff)) { this.client.sendResponse(new ErrorReportComposer(403)); @@ -47,11 +47,11 @@ public class UpdateThreadEvent extends MessageHandler { boolean pinChanged = isPinned != thread.isPinned(); if (pinChanged) { - this.client.sendResponse(new NotificationDialogMessageComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.key : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.key).compose()); + this.client.sendResponse(new NotificationDialogMessageComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.getKey() : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.getKey()).compose()); } if (isLocked != thread.isLocked()) { - this.client.sendResponse(new NotificationDialogMessageComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.key : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.key).compose()); + this.client.sendResponse(new NotificationDialogMessageComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.getKey() : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.getKey()).compose()); } thread.setPinned(isPinned); diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/CompleteDiffieHandshakeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/CompleteDiffieHandshakeEvent.java index f4c218eb..66f3cb2d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/CompleteDiffieHandshakeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/CompleteDiffieHandshakeEvent.java @@ -5,9 +5,9 @@ import com.eu.habbo.crypto.HabboRC4; import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.CompleteDiffieHandshakeComposer; +import com.eu.habbo.networking.gameserver.GameServerAttributes; import com.eu.habbo.networking.gameserver.decoders.GameByteDecryption; import com.eu.habbo.networking.gameserver.encoders.GameByteEncryption; -import com.eu.habbo.networking.gameserver.GameServerAttributes; @NoAuthMessage public class CompleteDiffieHandshakeEvent extends MessageHandler { diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java index 013c1e77..9180e8b4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java @@ -23,17 +23,17 @@ import com.eu.habbo.messages.outgoing.gamecenter.Game2AccountGameStatusMessageCo import com.eu.habbo.messages.outgoing.gamecenter.GameListMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.MOTDNotificationComposer; -import com.eu.habbo.messages.outgoing.habboway.nux.NoobnessLevelMessageComposer; import com.eu.habbo.messages.outgoing.habboway.nux.InClientLinkMessageComposer; +import com.eu.habbo.messages.outgoing.habboway.nux.NoobnessLevelMessageComposer; import com.eu.habbo.messages.outgoing.handshake.*; -import com.eu.habbo.messages.outgoing.inventory.BadgePointLimitsComposer; import com.eu.habbo.messages.outgoing.inventory.AvatarEffectsMessageComposer; +import com.eu.habbo.messages.outgoing.inventory.BadgePointLimitsComposer; import com.eu.habbo.messages.outgoing.modtool.CfhTopicsInitComposer; import com.eu.habbo.messages.outgoing.modtool.ModeratorInitMessageComposer; import com.eu.habbo.messages.outgoing.modtool.SanctionStatusComposer; -import com.eu.habbo.messages.outgoing.navigator.*; -import com.eu.habbo.messages.outgoing.unknown.BuildersClubSubscriptionStatusMessageComposer; import com.eu.habbo.messages.outgoing.mysterybox.MysteryBoxKeysMessageComposer; +import com.eu.habbo.messages.outgoing.navigator.NavigatorSavedSearchesComposer; +import com.eu.habbo.messages.outgoing.unknown.BuildersClubSubscriptionStatusMessageComposer; import com.eu.habbo.messages.outgoing.users.*; import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent; @@ -128,9 +128,9 @@ public class SSOTicketEvent extends MessageHandler { int roomIdToEnter = 0; - if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) + if (!this.client.getHabbo().getHabboStats().isNux() || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) roomIdToEnter = this.client.getHabbo().getHabboInfo().getHomeRoom(); - else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) + else if (!this.client.getHabbo().getHabboStats().isNux() || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) roomIdToEnter = RoomManager.HOME_ROOM_ID; boolean calendar = false; @@ -138,7 +138,7 @@ public class SSOTicketEvent extends MessageHandler { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")); calendar = true; } else { - int previousOnline = (int)this.client.getHabbo().getHabboStats().cache.get("previousOnline"); + int previousOnline = (int) this.client.getHabbo().getHabboStats().getCache().get("previousOnline"); long daysBetween = ChronoUnit.DAYS.between(new Date((long) previousOnline * 1000L).toInstant(), new Date().toInstant()); Date lastLogin = new Date(previousOnline); @@ -149,16 +149,16 @@ public class SSOTicketEvent extends MessageHandler { c2.setTime(lastLogin); if (daysBetween == 1) { - if (this.client.getHabbo().getHabboStats().getAchievementProgress().get(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")) == this.client.getHabbo().getHabboStats().loginStreak) { + if (this.client.getHabbo().getHabboStats().getAchievementProgress().get(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")) == this.client.getHabbo().getHabboStats().getLoginStreak()) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")); } - this.client.getHabbo().getHabboStats().loginStreak++; + this.client.getHabbo().getHabboStats().setLoginStreak(client.getHabbo().getHabboStats().getLoginStreak()+1); calendar = true; } else if (daysBetween >= 1) { calendar = true; } else { if (((lastLogin.getTime() / 1000) - Emulator.getIntUnixTimestamp()) > 86400) { - this.client.getHabbo().getHabboStats().loginStreak = 0; + this.client.getHabbo().getHabboStats().setLoginStreak(0); } } } @@ -198,7 +198,7 @@ public class SSOTicketEvent extends MessageHandler { } messages.add(new NavigatorSettingsComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), roomIdToEnter).compose()); - messages.add(new AvatarEffectsMessageComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); + messages.add(new AvatarEffectsMessageComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().getEffects().values()).compose()); messages.add(new FigureSetIdsComposer(this.client.getHabbo()).compose()); messages.add(new NoobnessLevelMessageComposer(habbo).compose()); messages.add(new UserRightsMessageComposer(this.client.getHabbo()).compose()); @@ -226,7 +226,7 @@ public class SSOTicketEvent extends MessageHandler { if (campaign != null) { long daysBetween = DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); if (daysBetween >= 0) { - messages.add(new CampaignCalendarDataMessageComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()).compose()); + messages.add(new CampaignCalendarDataMessageComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().getCalendarRewardsClaimed(), campaign.getLockExpired()).compose()); if(Emulator.getConfig().getBoolean("hotel.login.show.calendar", false)) { messages.add(new InClientLinkMessageComposer("openView/calendar").compose()); } @@ -256,24 +256,24 @@ public class SSOTicketEvent extends MessageHandler { if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { + if (item.getSanctionLevel() > 0 && item.getProbationTimestamp() != 0 && item.getProbationTimestamp() > Emulator.getIntUnixTimestamp()) { this.client.sendResponse(new SanctionStatusComposer(this.client.getHabbo())); - } else if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateSanction(item.id, 0); + } else if (item.getSanctionLevel() > 0 && item.getProbationTimestamp() != 0 && item.getProbationTimestamp() <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateSanction(item.getId(), 0); } - if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateTradeLockedUntil(item.id, 0); + if (item.getTradeLockedUntil() > 0 && item.getTradeLockedUntil() <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateTradeLockedUntil(item.getId(), 0); habbo.getHabboStats().setAllowTrade(true); - } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) { + } else if (item.getTradeLockedUntil() > 0 && item.getTradeLockedUntil() > Emulator.getIntUnixTimestamp()) { habbo.getHabboStats().setAllowTrade(false); } - if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateMuteDuration(item.id, 0); + if (item.isMuted() && item.getMuteDuration() <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateMuteDuration(item.getId(), 0); habbo.unMute(); - } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { - Date muteDuration = new Date((long) item.muteDuration * 1000); + } else if (item.isMuted() && item.getMuteDuration() > Emulator.getIntUnixTimestamp()) { + Date muteDuration = new Date((long) item.getMuteDuration() * 1000); long diff = muteDuration.getTime() - Emulator.getDate().getTime(); habbo.mute(Math.toIntExact(diff), false); } @@ -301,8 +301,8 @@ public class SSOTicketEvent extends MessageHandler { Messenger.checkFriendSizeProgress(habbo); - if (!habbo.getHabboStats().hasGottenDefaultSavedSearches) { - habbo.getHabboStats().hasGottenDefaultSavedSearches = true; + if (!habbo.getHabboStats().isHasGottenDefaultSavedSearches()) { + habbo.getHabboStats().setHasGottenDefaultSavedSearches(true); Emulator.getThreading().run(habbo.getHabboStats()); habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("official-root", "")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/GetCurrentTimingCodeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/GetCurrentTimingCodeEvent.java index 39caa82d..a561ce20 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/GetCurrentTimingCodeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/GetCurrentTimingCodeEvent.java @@ -2,13 +2,10 @@ package com.eu.habbo.messages.incoming.hotelview; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.CurrentTimingCodeMessageComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class GetCurrentTimingCodeEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(GetCurrentTimingCodeEvent.class); - - @Override public void handle() { @@ -31,7 +28,7 @@ public class GetCurrentTimingCodeEvent extends MessageHandler { this.client.sendResponse(new CurrentTimingCodeMessageComposer(data, data.split(",")[data.split(",").length - 1])); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java index ba073557..070cb761 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; public class HotelViewRequestSecondsUntilEvent extends MessageHandler { - private static DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm"); + private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); @Override public void handle() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java index 423561f0..3fe39c44 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java @@ -6,13 +6,12 @@ import com.eu.habbo.messages.outgoing.inventory.FurniListComposer; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.NoSuchElementException; +@Slf4j public class RequestFurniInventoryWhenNotInRoomEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(RequestFurniInventoryWhenNotInRoomEvent.class); @Override public void handle() throws Exception { @@ -48,7 +47,7 @@ public class RequestFurniInventoryWhenNotInRoomEvent extends MessageHandler { items.put(iterator.key(), iterator.value()); count++; } catch (NoSuchElementException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); break; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java index 761e7987..4000d629 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java @@ -41,7 +41,7 @@ public class CallForHelpEvent extends MessageHandler { Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (reported != null) { - if (cfhTopic != null && cfhTopic.action == CfhActionType.GUARDIANS && Emulator.getGameEnvironment().getGuideManager().activeGuardians()) { + if (cfhTopic != null && cfhTopic.getAction() == CfhActionType.GUARDIANS && Emulator.getGameEnvironment().getGuideManager().activeGuardians()) { GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getOpenReportedHabboTicket(reported); if (ticket != null) { @@ -68,17 +68,17 @@ public class CallForHelpEvent extends MessageHandler { Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); if (cfhTopic != null) { - this.client.sendResponse(new CallForHelpResultMessageComposer(CallForHelpResultMessageComposer.REPORT_RECEIVED, cfhTopic.reply)); - if (cfhTopic.action != CfhActionType.MODS) { + this.client.sendResponse(new CallForHelpResultMessageComposer(CallForHelpResultMessageComposer.REPORT_RECEIVED, cfhTopic.getReply())); + if (cfhTopic.getAction() != CfhActionType.MODS) { Emulator.getThreading().run(() -> { if (issue.state == ModToolTicketState.OPEN) { - if (cfhTopic.action == CfhActionType.AUTO_IGNORE) { + if (cfhTopic.getAction() == CfhActionType.AUTO_IGNORE) { if (CallForHelpEvent.this.client.getHabbo().getHabboStats().ignoreUser(CallForHelpEvent.this.client, reported.getHabboInfo().getId())) { CallForHelpEvent.this.client.sendResponse(new IgnoreResultMessageComposer(reported, IgnoreResultMessageComposer.IGNORED)); } } - CallForHelpEvent.this.client.sendResponse(new IssueCloseNotificationMessageComposer(cfhTopic.reply).compose()); + CallForHelpEvent.this.client.sendResponse(new IssueCloseNotificationMessageComposer(cfhTopic.getReply()).compose()); Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null); } }, (long) 30 * 1000); @@ -96,10 +96,10 @@ public class CallForHelpEvent extends MessageHandler { Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); if (cfhTopic != null) { - if (cfhTopic.action != CfhActionType.MODS) { + if (cfhTopic.getAction() != CfhActionType.MODS) { Emulator.getThreading().run(() -> { if (issue.state == ModToolTicketState.OPEN) { - if (cfhTopic.action == CfhActionType.AUTO_IGNORE) { + if (cfhTopic.getAction() == CfhActionType.AUTO_IGNORE) { if (CallForHelpEvent.this.client.getHabbo().getHabboStats().ignoreUser(CallForHelpEvent.this.client, issue.reportedId)) { Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId); if (reported != null) { @@ -108,7 +108,7 @@ public class CallForHelpEvent extends MessageHandler { } } - CallForHelpEvent.this.client.sendResponse(new IssueCloseNotificationMessageComposer(cfhTopic.reply).compose()); + CallForHelpEvent.this.client.sendResponse(new IssueCloseNotificationMessageComposer(cfhTopic.getReply()).compose()); Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null); } }, (long) 30 * 1000); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java index dadb4e9c..74239953 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java @@ -38,7 +38,7 @@ public class CallForHelpFromPhotoEvent extends MessageHandler { HabboItem item = room.getHabboItem(itemId); - if (item == null || !(item instanceof InteractionExternalImage)) return; + if (!(item instanceof InteractionExternalImage)) return; HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getUserId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java index dd68ace6..833f276b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.modtool.ModToolChatLog; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.modtool.GuideTicketCreationResultMessageComposer; import com.eu.habbo.messages.outgoing.modtool.CallForHelpDisabledNotifyMessageComposer; +import com.eu.habbo.messages.outgoing.modtool.GuideTicketCreationResultMessageComposer; import java.util.ArrayList; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java index b2787605..dded06ba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java @@ -20,17 +20,17 @@ public class CloseIssueDefaultActionEvent extends MessageHandler { CfhTopic modToolCategory = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(category); if (modToolCategory != null) { - ModToolPreset defaultSanction = modToolCategory.defaultSanction; + ModToolPreset defaultSanction = modToolCategory.getDefaultSanction(); if (defaultSanction != null) { Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId); - if (defaultSanction.banLength > 0) { - Emulator.getGameEnvironment().getModToolManager().ban(issue.reportedId, this.client.getHabbo(), defaultSanction.message, defaultSanction.banLength * 86400, ModToolBanType.ACCOUNT, modToolCategory.id); - } else if (defaultSanction.muteLength > 0) { + if (defaultSanction.getBanLength() > 0) { + Emulator.getGameEnvironment().getModToolManager().ban(issue.reportedId, this.client.getHabbo(), defaultSanction.getMessage(), defaultSanction.getBanLength() * 86400, ModToolBanType.ACCOUNT, modToolCategory.getId()); + } else if (defaultSanction.getMuteLength() > 0) { if (target != null) { - target.mute(defaultSanction.muteLength * 86400, false); + target.mute(defaultSanction.getMuteLength() * 86400, false); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java index 67620358..154c0566 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java @@ -23,17 +23,9 @@ public class CloseIssuesEvent extends MessageHandler { Habbo sender = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.senderId); switch (state) { - case 1: - Emulator.getGameEnvironment().getModToolManager().closeTicketAsUseless(issue, sender); - break; - - case 2: - Emulator.getGameEnvironment().getModToolManager().closeTicketAsAbusive(issue, sender); - break; - - case 3: - Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, sender); - break; + case 1 -> Emulator.getGameEnvironment().getModToolManager().closeTicketAsUseless(issue, sender); + case 2 -> Emulator.getGameEnvironment().getModToolManager().closeTicketAsAbusive(issue, sender); + case 3 -> Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, sender); } } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ticket.close").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java index 73af83bf..d8b1c1e1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java @@ -41,7 +41,7 @@ public class ModAlertEvent extends MessageHandler { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); if (item == null) return; - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + modToolSanctions.run(userId, this.client.getHabbo(), item.getSanctionLevel(), cfhTopic, message, 0, false, 0); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java index 6cb5b35d..93d1b3a7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java @@ -29,7 +29,13 @@ public class ModBanEvent extends MessageHandler { int banType = this.packet.readInt(); boolean unknown = this.packet.readBoolean(); - int duration = 0; + int duration = switch (banType) { + case BAN_18_HOURS -> 18 * 60 * 60; + case BAN_7_DAYS -> 7 * this.DAY_IN_SECONDS; + case BAN_30_DAYS_STEP_1, BAN_30_DAYS_STEP_2 -> 30 * this.DAY_IN_SECONDS; + case BAN_100_YEARS, BAN_AVATAR_ONLY_100_YEARS -> Emulator.getIntUnixTimestamp(); + default -> 0; + }; switch (banType) { case BAN_18_HOURS: @@ -66,7 +72,7 @@ public class ModBanEvent extends MessageHandler { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); if (item == null) return; - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + modToolSanctions.run(userId, this.client.getHabbo(), item.getSanctionLevel(), cfhTopic, message, 0, false, 0); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java index f6edd10e..a80dd7f5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java @@ -47,10 +47,10 @@ public class ModMuteEvent extends MessageHandler { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); if (item == null) return; - if (item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { - ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); - int muteDurationTimestamp = Math.toIntExact(new Date(System.currentTimeMillis() + ((long) modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000); - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp); + if (item.getProbationTimestamp() >= Emulator.getIntUnixTimestamp()) { + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.getSanctionLevel()); + int muteDurationTimestamp = Math.toIntExact(new Date(System.currentTimeMillis() + ((long) modToolSanctionLevelItem.getSanctionHourLength() * 60 * 60)).getTime() / 1000); + modToolSanctions.run(userId, this.client.getHabbo(), item.getSanctionLevel(), cfhTopic, message, 0, true, muteDurationTimestamp); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java index 198b308f..27acd550 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java @@ -31,7 +31,7 @@ public class ModTradingLockEvent extends MessageHandler { if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); + modToolSanctions.run(userId, this.client.getHabbo(), item.getSanctionLevel(), cfhTopic, message, duration, false, 0); } else { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java index ca8551c8..8eb41a1f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java @@ -7,12 +7,10 @@ import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; import com.eu.habbo.messages.outgoing.navigator.FlatCreatedComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CreateFlatEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CreateFlatEvent.class); - @Override public void handle() throws Exception { @@ -24,14 +22,14 @@ public class CreateFlatEvent extends MessageHandler { int tradeType = this.packet.readInt(); if (!Emulator.getGameEnvironment().getRoomManager().layoutExists(modelName)) { - LOGGER.error("[SCRIPTER] Incorrect layout name \"" + modelName + "\". " + this.client.getHabbo().getHabboInfo().getUsername()); + log.error("[SCRIPTER] Incorrect layout name \"" + modelName + "\". " + this.client.getHabbo().getHabboInfo().getUsername()); return; } RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId); if (category == null || category.getMinRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) { - LOGGER.error("[SCRIPTER] Incorrect rank or non existing category ID: \"" + categoryId + "\"." + this.client.getHabbo().getHabboInfo().getUsername()); + log.error("[SCRIPTER] Incorrect rank or non existing category ID: \"" + categoryId + "\"." + this.client.getHabbo().getHabboInfo().getUsername()); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index 279fcce2..0b64e4c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -11,8 +11,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.plugin.events.navigator.NavigatorRoomDeletedEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,8 +19,9 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +@Slf4j public class DeleteRoomEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(DeleteRoomEvent.class); + @Override public void handle() throws Exception { @@ -49,8 +49,7 @@ public class DeleteRoomEvent extends MessageHandler { List pets = new ArrayList<>(room.getCurrentPets().valueCollection()); for (Pet pet : pets) { - if (pet instanceof RideablePet) { - RideablePet rideablePet = (RideablePet) pet; + if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { rideablePet.getRider().getHabboInfo().dismountPet(true); } @@ -109,12 +108,12 @@ public class DeleteRoomEvent extends MessageHandler { filter.execute(); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } else { String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getName()).replace("%roomowner%", room.getOwnerName()); ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/GetUserEventCatsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/GetUserEventCatsEvent.java index e7df39eb..0e247dc3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/GetUserEventCatsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/GetUserEventCatsEvent.java @@ -8,7 +8,7 @@ public class GetUserEventCatsEvent extends MessageHandler { public void handle() throws Exception { - this.client.sendResponse(new NewNavigatorPreferencesComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); + this.client.sendResponse(new NewNavigatorPreferencesComposer(this.client.getHabbo().getHabboStats().getNavigatorWindowSettings())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/MyGuildBasesSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/MyGuildBasesSearchEvent.java index 23a0d742..da6f9ba8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/MyGuildBasesSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/MyGuildBasesSearchEvent.java @@ -7,6 +7,6 @@ import com.eu.habbo.messages.outgoing.navigator.GuestRoomSearchResultComposer; public class MyGuildBasesSearchEvent extends MessageHandler { @Override public void handle() throws Exception { - this.client.sendResponse(new GuestRoomSearchResultComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsInGroup(this.client.getHabbo()))); + this.client.sendResponse(new GuestRoomSearchResultComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsInGroup())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorAddCollapsedCategoryEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorAddCollapsedCategoryEvent.java index 3e74b3e8..e0fc09b5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorAddCollapsedCategoryEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorAddCollapsedCategoryEvent.java @@ -7,6 +7,6 @@ public class NavigatorAddCollapsedCategoryEvent extends MessageHandler { @Override public void handle() throws Exception { String category = this.packet.readString(); - this.client.getHabbo().getHabboStats().navigatorWindowSettings.setDisplayMode(category, DisplayMode.COLLAPSED); + this.client.getHabbo().getHabboStats().getNavigatorWindowSettings().setDisplayMode(category, DisplayMode.COLLAPSED); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorRemoveCollapsedCategoryEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorRemoveCollapsedCategoryEvent.java index a233270d..053e62a3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorRemoveCollapsedCategoryEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorRemoveCollapsedCategoryEvent.java @@ -7,6 +7,6 @@ public class NavigatorRemoveCollapsedCategoryEvent extends MessageHandler { @Override public void handle() throws Exception { String category = this.packet.readString(); - this.client.getHabbo().getHabboStats().navigatorWindowSettings.setDisplayMode(category, DisplayMode.VISIBLE); + this.client.getHabbo().getHabboStats().getNavigatorWindowSettings().setDisplayMode(category, DisplayMode.VISIBLE); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorSetSearchCodeViewModeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorSetSearchCodeViewModeEvent.java index 431ef393..b227a574 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorSetSearchCodeViewModeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorSetSearchCodeViewModeEvent.java @@ -12,7 +12,7 @@ public class NavigatorSetSearchCodeViewModeEvent extends MessageHandler { int viewMode = this.packet.readInt(); RoomCategory roomCategory = Emulator.getGameEnvironment().getRoomManager().getCategory(category); - this.client.getHabbo().getHabboStats().navigatorWindowSettings.setListMode( + this.client.getHabbo().getHabboStats().getNavigatorWindowSettings().setListMode( roomCategory != null ? roomCategory.getCaptionSave() : category, viewMode == 1 ? ListMode.THUMBNAILS : ListMode.LIST); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorInitEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorInitEvent.java index 5e269f7b..9588e290 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorInitEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorInitEvent.java @@ -6,7 +6,7 @@ import com.eu.habbo.messages.outgoing.navigator.*; public class NewNavigatorInitEvent extends MessageHandler { @Override public void handle() throws Exception { - this.client.sendResponse(new NewNavigatorPreferencesComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); + this.client.sendResponse(new NewNavigatorPreferencesComposer(this.client.getHabbo().getHabboStats().getNavigatorWindowSettings())); this.client.sendResponse(new NavigatorMetaDataComposer()); this.client.sendResponse(new NavigatorLiftedRoomsComposer()); this.client.sendResponse(new CollapsedCategoriesComposer()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java index fd2b495d..6b3c5d4b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java @@ -8,14 +8,14 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.NavigatorSearchResultBlocksComposer; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +@Slf4j public class NewNavigatorSearchEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(NewNavigatorSearchEvent.class); - @Override public void handle() throws Exception { String view = this.packet.readString(); @@ -32,7 +32,7 @@ public class NewNavigatorSearchEvent extends MessageHandler { if (rooms != null) { List resultLists = new ArrayList<>(); - resultLists.add(new SearchResultList(0, view, query, SearchAction.NONE, this.client.getHabbo().getHabboStats().navigatorWindowSettings.getListModeForCategory(view, ListMode.LIST), this.client.getHabbo().getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(view, DisplayMode.VISIBLE), rooms, true, true, DisplayOrder.ACTIVITY, -1)); + resultLists.add(new SearchResultList(0, view, query, SearchAction.NONE, this.client.getHabbo().getHabboStats().getNavigatorWindowSettings().getListModeForCategory(view, ListMode.LIST), this.client.getHabbo().getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory(view, DisplayMode.VISIBLE), rooms, true, true, DisplayOrder.ACTIVITY, -1)); this.client.sendResponse(new NavigatorSearchResultBlocksComposer(view, query, resultLists)); return; } @@ -88,12 +88,17 @@ public class NewNavigatorSearchEvent extends MessageHandler { return; try { - List resultLists = new ArrayList<>(filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1)); - filter.filter(field.field, part, resultLists); + List resultLists2 = filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1); + List resultLists = new ArrayList<>(); + for(SearchResultList searchResultList : resultLists2) { + List rooms = new ArrayList<>(searchResultList.getRooms()); + resultLists.add(new SearchResultList(searchResultList.getOrder(), searchResultList.getCode(), searchResultList.getQuery(), searchResultList.getAction(), searchResultList.getMode(), searchResultList.getHidden(), rooms, searchResultList.isFilter(), searchResultList.isShowInvisible(), searchResultList.getDisplayOrder(), searchResultList.getCategoryOrder())); + } + filter.filter(field.getField(), part, resultLists); resultLists = toQueryResults(resultLists); this.client.sendResponse(new NavigatorSearchResultBlocksComposer(view, query, resultLists)); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } /* @@ -108,7 +113,7 @@ public class NewNavigatorSearchEvent extends MessageHandler { } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } */ } @@ -118,50 +123,13 @@ public class NewNavigatorSearchEvent extends MessageHandler { THashMap searchRooms = new THashMap<>(); for (SearchResultList li : resultLists) { - for (Room room : li.rooms) { + for (Room room : li.getRooms()) { searchRooms.put(room.getId(), room); } } - SearchResultList list = new SearchResultList(0, "query", "", SearchAction.NONE, ListMode.LIST, DisplayMode.VISIBLE, new ArrayList(searchRooms.values()), true, this.client.getHabbo().hasPermission(Permission.ACC_ENTERANYROOM) || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER), DisplayOrder.ACTIVITY, -1); + SearchResultList list = new SearchResultList(0, "query", "", SearchAction.NONE, ListMode.LIST, DisplayMode.VISIBLE, new ArrayList<>(searchRooms.values()), true, this.client.getHabbo().hasPermission(Permission.ACC_ENTERANYROOM) || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER), DisplayOrder.ACTIVITY, -1); nList.add(list); return nList; } - - private void filter(List resultLists, NavigatorFilter filter, String part) { - List toRemove = new ArrayList<>(); - Map> filteredRooms = new HashMap<>(); - - for (NavigatorFilterField field : Emulator.getGameEnvironment().getNavigatorManager().filterSettings.values()) { - for (SearchResultList result : resultLists) { - if (result.filter) { - List rooms = new ArrayList<>(result.rooms.subList(0, result.rooms.size())); - filter.filterRooms(field.field, part, rooms); - - if (!filteredRooms.containsKey(result.order)) { - filteredRooms.put(result.order, new HashMap<>()); - } - - for (Room room : rooms) { - filteredRooms.get(result.order).put(room.getId(), room); - } - } - } - } - - for (Map.Entry> set : filteredRooms.entrySet()) { - for (SearchResultList resultList : resultLists) { - if (resultList.filter) { - resultList.rooms.clear(); - resultList.rooms.addAll(set.getValue().values()); - - if (resultList.rooms.isEmpty()) { - toRemove.add(resultList); - } - } - } - } - - resultLists.removeAll(toRemove); - } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNavigatorSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNavigatorSettingsEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsInGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsInGroupEvent.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SetNewNavigatorWindowPreferencesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SetNewNavigatorWindowPreferencesEvent.java index 08351f7e..961d0273 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SetNewNavigatorWindowPreferencesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SetNewNavigatorWindowPreferencesEvent.java @@ -6,18 +6,17 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class SetNewNavigatorWindowPreferencesEvent extends MessageHandler { @Override public void handle() throws Exception { - HabboNavigatorWindowSettings windowSettings = this.client.getHabbo().getHabboStats().navigatorWindowSettings; + HabboNavigatorWindowSettings windowSettings = this.client.getHabbo().getHabboStats().getNavigatorWindowSettings(); - windowSettings.x = this.packet.readInt(); - windowSettings.y = this.packet.readInt(); + windowSettings.setX(this.packet.readInt()); + windowSettings.setY(this.packet.readInt()); - windowSettings.width = this.packet.readInt(); - windowSettings.height = this.packet.readInt(); + windowSettings.setWidth(this.packet.readInt()); + windowSettings.setHeight(this.packet.readInt()); boolean openSearches = this.packet.readBoolean(); - windowSettings.openSearches = openSearches; + windowSettings.setOpenSearches(openSearches); int unknownVar = this.packet.readInt(); - int unknown = unknownVar; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index 945288fd..24c7c078 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -6,16 +6,14 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer; import com.eu.habbo.messages.outgoing.wired.WiredRewardResultMessageComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class AnswerPollEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AnswerPollEvent.class); - @Override public void handle() throws Exception { int pollId = this.packet.readInt(); @@ -47,13 +45,13 @@ public class AnswerPollEvent extends MessageHandler { statement.setString(4, answer.toString()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - if (poll.lastQuestionId == questionId) { - if (poll.badgeReward.length() > 0) { - if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(poll.badgeReward)) { - HabboBadge badge = new HabboBadge(0, poll.badgeReward, 0, this.client.getHabbo()); + if (poll.getLastQuestionId() == questionId) { + if (poll.getBadgeReward().length() > 0) { + if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(poll.getBadgeReward())) { + HabboBadge badge = new HabboBadge(0, poll.getBadgeReward(), 0, this.client.getHabbo()); Emulator.getThreading().run(badge); this.client.getHabbo().getInventory().getBadgesComponent().addBadge(badge); this.client.sendResponse(new BadgeReceivedComposer(badge)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/PollRejectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/PollRejectEvent.java index 1860a019..bb064b91 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/PollRejectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/PollRejectEvent.java @@ -3,15 +3,14 @@ package com.eu.habbo.messages.incoming.polls; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class PollRejectEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(PollRejectEvent.class); @Override public void handle() throws Exception { @@ -28,7 +27,7 @@ public class PollRejectEvent extends MessageHandler { statement.setString(4, ""); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java index 36b43f5e..b00b1d28 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java @@ -13,11 +13,7 @@ public class GetGuestRoomEvent extends MessageHandler { int something = this.packet.readInt(); int something2 = this.packet.readInt(); if (room != null) { - boolean unknown = true; - - if (something == 0 && something2 == 1) { - unknown = false; - } + boolean unknown = something != 0 || something2 != 1; //this.client.getHabbo().getHabboInfo().getCurrentRoom() != room this.client.sendResponse(new GetGuestRoomResultComposer(room, this.client.getHabbo(), true, unknown)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java index 3e5f5ef9..494dc37b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; import com.eu.habbo.messages.outgoing.rooms.FlatAccessDeniedMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; public class LetUserInEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java index cb6c4102..85b26f9d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.YouAreControllerMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.NoSuchFlatComposer; -import gnu.trove.procedure.TIntProcedure; public class RemoveAllRightsEvent extends MessageHandler { @Override @@ -19,10 +18,8 @@ public class RemoveAllRightsEvent extends MessageHandler { return; if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { - room.getRights().forEach(new TIntProcedure() { - @Override - public boolean execute(int value) { - Habbo habbo = room.getHabbo(value); + room.getRights().forEach(value -> { + Habbo habbo = room.getHabbo(value); if (habbo != null) { room.sendComposer(new NoSuchFlatComposer(room, value).compose()); @@ -30,8 +27,7 @@ public class RemoveAllRightsEvent extends MessageHandler { habbo.getClient().sendResponse(new YouAreControllerMessageComposer(RoomRightLevels.NONE)); } - return true; - } + return true; }); room.removeAllRights(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 240312f9..16eb8b57 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -26,20 +26,25 @@ public class RequestRoomPropertySet extends MessageHandler { return; } - if (item.getBaseItem().getName().equals("floor")) { - room.setFloorPaint(item.getExtradata()); + switch (item.getBaseItem().getName()) { + case "floor": + room.setFloorPaint(item.getExtradata()); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFloor")); - } else if (item.getBaseItem().getName().equals("wallpaper")) { - room.setWallPaint(item.getExtradata()); + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFloor")); + break; + case "wallpaper": + room.setWallPaint(item.getExtradata()); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoWallpaper")); - } else if (item.getBaseItem().getName().equals("landscape")) { - room.setBackgroundPaint(item.getExtradata()); + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoWallpaper")); + break; + case "landscape": + room.setBackgroundPaint(item.getExtradata()); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoLandscape")); - } else - return; + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoLandscape")); + break; + default: + return; + } this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); room.setNeedsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java index 5ee705fd..6baaa589 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java @@ -7,11 +7,11 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.habbohotel.rooms.RoomState; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class SaveRoomSettingsEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(SaveRoomSettingsEvent.class); + @Override public void handle() throws Exception { @@ -102,7 +102,7 @@ public class SaveRoomSettingsEvent extends MessageHandler { } ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index d42adbdb..6a0472d2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -26,7 +26,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { int saturation = this.packet.readInt(); int brightness = this.packet.readInt(); - FurnitureRoomTonerEvent event = (FurnitureRoomTonerEvent) Emulator.getPluginManager().fireEvent(new FurnitureRoomTonerEvent(item, this.client.getHabbo(), hue, saturation, brightness)); + FurnitureRoomTonerEvent event = Emulator.getPluginManager().fireEvent(new FurnitureRoomTonerEvent(item, this.client.getHabbo(), hue, saturation, brightness)); if (event.isCancelled()) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java index f50f4c65..bcab8ff4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java @@ -9,8 +9,8 @@ import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; +import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer; import com.eu.habbo.plugin.events.bots.BotSavedChatEvent; import com.eu.habbo.plugin.events.bots.BotSavedLookEvent; import com.eu.habbo.plugin.events.bots.BotSavedNameEvent; @@ -37,30 +37,24 @@ public class CommandBotEvent extends MessageHandler { int settingId = this.packet.readInt(); switch (settingId) { - case 1: + case 1 -> { BotSavedLookEvent lookEvent = new BotSavedLookEvent(bot, this.client.getHabbo().getHabboInfo().getGender(), this.client.getHabbo().getHabboInfo().getLook(), this.client.getHabbo().getRoomUnit().getEffectId()); Emulator.getPluginManager().fireEvent(lookEvent); - if (lookEvent.isCancelled()) break; - bot.setFigure(lookEvent.newLook); bot.setGender(lookEvent.gender); bot.setEffect(lookEvent.effect, -1); bot.needsUpdate(true); - break; - - case 2: + } + case 2 -> { String messageString = this.packet.readString(); - if (messageString.length() > 5112) break; - String[] data = messageString.split(";#;"); - ArrayList chat = new ArrayList<>(); int totalChatLength = 0; for (int i = 0; i < data.length - 3 && totalChatLength <= 120; i++) { @@ -90,44 +84,36 @@ public class CommandBotEvent extends MessageHandler { } } } - int chatSpeed = 7; - try { - chatSpeed = Integer.valueOf(data[data.length - 2]); + chatSpeed = Integer.parseInt(data[data.length - 2]); if (chatSpeed < BotManager.MINIMUM_CHAT_SPEED) { chatSpeed = BotManager.MINIMUM_CHAT_SPEED; } } catch (Exception e) { //Invalid chatspeed. Use 7. } - - BotSavedChatEvent chatEvent = new BotSavedChatEvent(bot, Boolean.valueOf(data[data.length - 3]), Boolean.valueOf(data[data.length - 1]), chatSpeed, chat); + BotSavedChatEvent chatEvent = new BotSavedChatEvent(bot, Boolean.parseBoolean(data[data.length - 3]), Boolean.parseBoolean(data[data.length - 1]), chatSpeed, chat); Emulator.getPluginManager().fireEvent(chatEvent); - if (chatEvent.isCancelled()) break; - bot.setChatAuto(chatEvent.autoChat); bot.setChatRandom(chatEvent.randomChat); bot.setChatDelay((short) chatEvent.chatDelay); bot.clearChat(); bot.addChatLines(chat); bot.needsUpdate(true); - break; - - case 3: + } + case 3 -> { bot.setCanWalk(!bot.canWalk()); bot.needsUpdate(true); - break; - - case 4: + } + case 4 -> { bot.getRoomUnit().setDanceType(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) % DanceType.values().length]); room.sendComposer(new DanceMessageComposer(bot.getRoomUnit()).compose()); bot.needsUpdate(true); - break; - - case 5: + } + case 5 -> { String name = this.packet.readString(); boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH || name.contains("<") || name.contains(">"); if (!invalidName) { @@ -146,20 +132,17 @@ public class CommandBotEvent extends MessageHandler { room.sendComposer(new UserNameChangedMessageComposer(bot.getRoomUnit().getId(), bot.getRoomUnit().getId(), nameEvent.name).compose()); } } - if (invalidName) { this.client.sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_NAME_NOT_ACCEPT)); } - break; - case 9: + } + case 9 -> { String motto = this.packet.readString(); - - if(motto.length() > Emulator.getConfig().getInt("motto.max_length", 38)) break; - + if (motto.length() > Emulator.getConfig().getInt("motto.max_length", 38)) break; bot.setMotto(motto); bot.needsUpdate(true); room.sendComposer(new RoomUsersComposer(bot).compose()); - break; + } } if (bot.needsUpdate()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index 7ce3bdc6..3d04cee2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -7,13 +7,13 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.time.LocalDate; +@Slf4j public class AddSpamWallPostItEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AddSpamWallPostItEvent.class); + @Override public void handle() throws Exception { @@ -30,7 +30,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { CommandHandler.handleCommand(this.client, command); } } else { - LOGGER.info("Scripter Alert! " + this.client.getHabbo().getHabboInfo().getUsername() + " | " + this.packet.readString()); + log.info("Scripter Alert! " + this.client.getHabbo().getHabboInfo().getUsername() + " | " + this.packet.readString()); } } else { String text = this.packet.readString(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java index 14814846..a9a46858 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java @@ -7,15 +7,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; -import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer; +import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; import com.eu.habbo.plugin.events.furniture.FurnitureRedeemedEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CreditFurniRedeemEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CreditFurniRedeemEvent.class); @Override public void handle() throws Exception { @@ -34,9 +33,9 @@ public class CreditFurniRedeemEvent extends MessageHandler { if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { int credits; try { - credits = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + credits = Integer.parseInt(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - LOGGER.error("Failed to parse redeemable furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_"); + log.error("Failed to parse redeemable furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_"); return; } @@ -45,9 +44,9 @@ public class CreditFurniRedeemEvent extends MessageHandler { int pixels; try { - pixels = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + pixels = Integer.parseInt(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - LOGGER.error("Failed to parse redeemable pixel furniture: " + item.getBaseItem().getName() + ". Must be in format of PF_"); + log.error("Failed to parse redeemable pixel furniture: " + item.getBaseItem().getName() + ". Must be in format of PF_"); return; } @@ -57,16 +56,16 @@ public class CreditFurniRedeemEvent extends MessageHandler { int points; try { - pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + pointsType = Integer.parseInt(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - LOGGER.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); + log.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } try { - points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + points = Integer.parseInt(item.getBaseItem().getName().split("_")[2]); } catch (Exception e) { - LOGGER.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); + log.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } @@ -75,9 +74,9 @@ public class CreditFurniRedeemEvent extends MessageHandler { int points; try { - points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + points = Integer.parseInt(item.getBaseItem().getName().split("_")[2]); } catch (Exception e) { - LOGGER.error("Failed to parse redeemable diamonds furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_diamond_"); + log.error("Failed to parse redeemable diamonds furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_diamond_"); return; } @@ -102,27 +101,22 @@ public class CreditFurniRedeemEvent extends MessageHandler { RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); t.setStackHeight(room.getStackHeight(item.getX(), item.getY(), false)); room.updateTile(t); - room.sendComposer(new HeightMapUpdateMessageComposer(item.getX(), item.getY(), t.z, t.relativeHeight()).compose()); + room.sendComposer(new HeightMapUpdateMessageComposer(item.getX(), item.getY(), t.getZ(), t.relativeHeight()).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); switch (furniRedeemEvent.currencyID) { - case FurnitureRedeemedEvent.CREDITS: + case FurnitureRedeemedEvent.CREDITS -> { this.client.getHabbo().getHabboInfo().addCredits(furniRedeemEvent.amount); this.client.sendResponse(new CreditBalanceComposer(this.client.getHabbo())); - break; - - case FurnitureRedeemedEvent.DIAMONDS: - this.client.getHabbo().givePoints(furniRedeemEvent.amount); - break; - - case FurnitureRedeemedEvent.PIXELS: + } + case FurnitureRedeemedEvent.DIAMONDS -> + this.client.getHabbo().givePoints(furniRedeemEvent.amount); + case FurnitureRedeemedEvent.PIXELS -> { this.client.getHabbo().getHabboInfo().addPixels(furniRedeemEvent.amount); this.client.sendResponse(new ActivityPointsMessageComposer(this.client.getHabbo())); - break; - default: - this.client.getHabbo().givePoints(furniRedeemEvent.currencyID, furniRedeemEvent.amount); - break; + } default -> + this.client.getHabbo().givePoints(furniRedeemEvent.currencyID, furniRedeemEvent.amount); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index 4e48d5de..5dd07465 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -6,21 +6,21 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionClothing; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.users.FigureSetIdsComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class CustomizeAvatarWithFurniEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CustomizeAvatarWithFurniEvent.class); + @Override public void handle() throws Exception { @@ -35,33 +35,33 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { ClothItem clothing = Emulator.getGameEnvironment().getCatalogManager().getClothing(item.getBaseItem().getName()); if (clothing != null) { - if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.id)) { + if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) { item.setRoomId(0); RoomTile tile = this.client.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(item.getX(), item.getY()); this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_clothing (user_id, clothing_id) VALUES (?, ?)")) { statement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); - statement.setInt(2, clothing.id); + statement.setInt(2, clothing.getId()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } - this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().add(clothing.id); - this.client.getHabbo().getInventory().getWardrobeComponent().getClothingSets().addAll(clothing.setId); + this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().add(clothing.getId()); + this.client.getHabbo().getInventory().getWardrobeComponent().getClothingSets().addAll(clothing.getSetId()); this.client.sendResponse(new FigureSetIdsComposer(this.client.getHabbo())); - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FIGURESET_REDEEMED.key)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FIGURESET_REDEEMED.getKey())); } else { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FIGURESET_OWNED_ALREADY.key)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FIGURESET_OWNED_ALREADY.getKey())); } } else { - LOGGER.error("[Catalog] No definition in catalog_clothing found for clothing name " + item.getBaseItem().getName() + ". Could not redeem clothing!"); + log.error("[Catalog] No definition in catalog_clothing found for clothing name " + item.getBaseItem().getName() + ". Could not redeem clothing!"); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java index 2769ce62..c17d563b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectUpdateMessageComposer; public class MoveObjectEvent extends MessageHandler { @@ -28,14 +28,14 @@ public class MoveObjectEvent extends MessageHandler { FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); this.client.sendResponse(new ObjectUpdateMessageComposer(item)); return; } error = room.moveFurniTo(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); this.client.sendResponse(new ObjectUpdateMessageComposer(item)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index 65a11a8f..01095935 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomRightLevels; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; public class MoveWallItemEvent extends MessageHandler { @Override @@ -18,7 +18,7 @@ public class MoveWallItemEvent extends MessageHandler { return; if (!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasPermission(Permission.ACC_PLACEFURNI) && !(room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java index b64b19a7..c75a5a66 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java @@ -3,11 +3,14 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.modtool.ScripterManager; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; public class PlaceObjectEvent extends MessageHandler { @@ -20,7 +23,7 @@ public class PlaceObjectEvent extends MessageHandler { if (values.length != 0) itemId = Integer.parseInt(values[0]); if (!this.client.getHabbo().getRoomUnit().isInRoom()) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } @@ -31,7 +34,7 @@ public class PlaceObjectEvent extends MessageHandler { HabboItem rentSpace = null; if (this.client.getHabbo().getHabboStats().isRentingSpace()) { - rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().rentedItemId); + rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); } HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); @@ -44,11 +47,11 @@ public class PlaceObjectEvent extends MessageHandler { //TODO move this to canStackAt() though find a way to handle the different bubble alert keys if (item instanceof InteractionMoodLight && !room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_DIMMERS.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_DIMMERS.getErrorCode())); return; } if (item instanceof InteractionJukeBox && !room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_SOUNDFURNI.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_SOUNDFURNI.getErrorCode())); return; } @@ -83,30 +86,30 @@ public class PlaceObjectEvent extends MessageHandler { item instanceof InteractionCannon || item instanceof InteractionPuzzleBox || item.getBaseItem().getType() == FurnitureType.WALL) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } if (rentSpace != null && !RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(x, y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } } FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; } error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; } } else { FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index 9fc605d9..cd1d7e99 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.items.ItemAddMessageComposer; @@ -46,7 +46,7 @@ public class PlacePostItEvent extends MessageHandler { } else { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_STICKIES.errorCode)); + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_STICKIES.getErrorCode())); } //this.client.sendResponse(new PostItStickyPoleOpenComposer(item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java index 9a1aac59..8c4fb012 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java @@ -21,16 +21,14 @@ public class SetClothingChangeDataEvent extends MessageHandler { String look = this.packet.readString(); switch (gender.toLowerCase()) { - default: - case "m": + case "m" -> { ((InteractionFootballGate) item).setFigureM(look); room.updateItem(item); - break; - - case "f": + } + case "f" -> { ((InteractionFootballGate) item).setFigureF(look); room.updateItem(item); - break; + } } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 7958b0e0..b5b0fcfc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -28,13 +28,13 @@ public class SetCustomStackingHeightEvent extends MessageHandler { THashSet tiles = room.getLayout().getTilesAt(itemTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); if (stackerHeight == -100) { for (RoomTile tile : tiles) { - double stackheight = room.getStackHeight(tile.x, tile.y, false, item) * 100; + double stackheight = room.getStackHeight(tile.getX(), tile.getY(), false, item) * 100; if (stackheight > stackerHeight) { stackerHeight = stackheight; } } } else { - stackerHeight = Math.min(Math.max(stackerHeight, itemTile.z * 100.0), Room.MAXIMUM_FURNI_HEIGHT * 100); + stackerHeight = Math.min(Math.max(stackerHeight, itemTile.getZ() * 100.0), Room.MAXIMUM_FURNI_HEIGHT * 100); } double height = 0; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index f6b44696..3913e7d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -12,7 +12,7 @@ import java.util.Arrays; import java.util.List; public class SetItemDataEvent extends MessageHandler { - private static List COLORS = Arrays.asList("9CCEFF", "FF9CFF", "9CFF9C", "FFFF33"); + private static final List COLORS = Arrays.asList("9CCEFF", "FF9CFF", "9CFF9C", "FFFF33"); @Override public void handle() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java index ba5280eb..c4c7c2b0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java @@ -4,11 +4,10 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRandomState; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class SetRandomStateEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(SetRandomStateEvent.class); @Override public void handle() throws Exception { @@ -20,13 +19,12 @@ public class SetRandomStateEvent extends MessageHandler { HabboItem item = room.getHabboItem(itemId); - if (item == null || !(item instanceof InteractionRandomState)) + if (!(item instanceof InteractionRandomState randomStateItem)) return; - InteractionRandomState randomStateItem = (InteractionRandomState)item; - randomStateItem.onRandomStateClick(this.client, room); + randomStateItem.onRandomStateClick(room); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index c64182a6..25534e3e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -14,11 +14,11 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class UseFurnitureEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(UseFurnitureEvent.class); + @Override public void handle() throws Exception { @@ -96,13 +96,13 @@ public class UseFurnitureEvent extends MessageHandler { boolean isRare = item.getBaseItem().getName().contains("rare"); - if ((!item.getExtradata().isEmpty() && Integer.valueOf(item.getExtradata()) - 1 < 0) || item.getExtradata().isEmpty()) { + if (item.getExtradata().isEmpty() || Integer.parseInt(item.getExtradata()) - 1 < 0) { rarity = isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel(); } else { try { - rarity = Integer.valueOf(item.getExtradata()) - 1; - } catch (Exception e) { + rarity = Integer.parseInt(item.getExtradata()) - 1; + } catch (Exception ignored) { } } MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity); @@ -132,7 +132,7 @@ public class UseFurnitureEvent extends MessageHandler { this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java index 3e04eccf..48719216 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java @@ -2,8 +2,8 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.rooms.TraxManager; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; public class GetJukeboxPlayListEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java index 6eb7dd21..c284ed03 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java @@ -2,8 +2,8 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.rooms.TraxManager; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; public class GetNowPlayingEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java index 59d48048..81f67513 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java @@ -2,8 +2,8 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.rooms.TraxManager; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; public class JukeBoxEventOne extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java index 6c5bac12..d80ca722 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java @@ -10,8 +10,13 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeControlVideoMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; +import lombok.AllArgsConstructor; +import lombok.Getter; + public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler { + @Getter + @AllArgsConstructor public enum YoutubeState { PREVIOUS(0), NEXT(1), @@ -20,27 +25,14 @@ public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler { private final int state; - YoutubeState(int state) { - this.state = state; - } - - public int getState() { - return state; - } - public static YoutubeState getByState(int state) { - switch (state) { - case 0: - return PREVIOUS; - case 1: - return NEXT; - case 2: - return PAUSE; - case 3: - return RESUME; - default: - return null; - } + return switch (state) { + case 0 -> PREVIOUS; + case 1 -> NEXT; + case 2 -> PAUSE; + case 3 -> RESUME; + default -> null; + }; } } @@ -64,35 +56,33 @@ public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (!(item instanceof InteractionYoutubeTV)) return; - - InteractionYoutubeTV tv = (InteractionYoutubeTV) item; + if (!(item instanceof InteractionYoutubeTV tv)) return; if(tv.currentPlaylist == null || tv.currentPlaylist.getVideos().isEmpty()) return; switch (state) { - case PAUSE: + case PAUSE -> { tv.playing = false; tv.offset += Emulator.getIntUnixTimestamp() - tv.startedWatchingAt; if (tv.autoAdvance != null) tv.autoAdvance.cancel(true); room.sendComposer(new YoutubeControlVideoMessageComposer(tv.getId(), 2).compose()); - break; - case RESUME: + } + case RESUME -> { tv.playing = true; tv.startedWatchingAt = Emulator.getIntUnixTimestamp(); - tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), (tv.currentVideo.getDuration() - tv.offset) * 1000L); + tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), (tv.currentVideo.getDuration() - tv.offset) * 1000); room.sendComposer(new YoutubeControlVideoMessageComposer(tv.getId(), 1).compose()); - break; - case PREVIOUS: + } + case PREVIOUS -> { int previousIndex = tv.currentPlaylist.getVideos().indexOf(tv.currentVideo) - 1; if (previousIndex < 0) previousIndex = tv.currentPlaylist.getVideos().size() - 1; tv.currentVideo = tv.currentPlaylist.getVideos().get(previousIndex); - break; - case NEXT: + } + case NEXT -> { int nextIndex = tv.currentPlaylist.getVideos().indexOf(tv.currentVideo) + 1; if (nextIndex >= tv.currentPlaylist.getVideos().size()) nextIndex = 0; tv.currentVideo = tv.currentPlaylist.getVideos().get(nextIndex); - break; + } } if (state == YoutubeState.PREVIOUS || state == YoutubeState.NEXT) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java index d3be1f19..baf1e880 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java @@ -7,13 +7,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayPlaylistsComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; +@Slf4j public class GetYoutubeDisplayStatusEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(GetYoutubeDisplayStatusEvent.class); + @Override public void handle() throws Exception { @@ -22,13 +22,12 @@ public class GetYoutubeDisplayStatusEvent extends MessageHandler { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item instanceof InteractionYoutubeTV) { - InteractionYoutubeTV tv = (InteractionYoutubeTV) item; + if (item instanceof InteractionYoutubeTV tv) { ArrayList playlists = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()); if (playlists == null) { - LOGGER.error("No YouTube playlists set for base item #" + item.getBaseItem().getId()); + log.error("No YouTube playlists set for base item #" + item.getBaseItem().getId()); this.client.sendResponse(new ErrorReportComposer(1000)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java index 6718fdb1..3e0af6fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java @@ -8,15 +8,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class CompostPlantEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CompostPlantEvent.class); + @Override public void handle() throws Exception { @@ -46,7 +46,7 @@ public class CompostPlantEvent extends MessageHandler { statement.setInt(1, pet.getId()); statement.executeUpdate(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java index 13a1e200..00bfa4a3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java @@ -16,7 +16,7 @@ public class ConfirmPetBreedingEvent extends MessageHandler { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); if (item instanceof InteractionPetBreedingNest) { - ((InteractionPetBreedingNest) item).breed(this.client.getHabbo(), name, petOneId, petTwoId); + ((InteractionPetBreedingNest) item).breed(this.client.getHabbo(), name); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index a0703c3a..831dff09 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -10,8 +10,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; -import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetFigureUpdateComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -34,7 +34,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { if (pet instanceof HorsePet) { if (item.getBaseItem().getName().toLowerCase().startsWith("horse_dye")) { - int race = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + int race = Integer.parseInt(item.getBaseItem().getName().split("_")[2]); int raceType = (race * 4) - 2; if (race >= 13 && race <= 17) @@ -44,9 +44,9 @@ public class CustomizePetWithFurniEvent extends MessageHandler { raceType = 0; pet.setRace(raceType); - ((HorsePet) pet).needsUpdate = true; + pet.needsUpdate = true; } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairdye")) { - int splittedHairdye = Integer.valueOf(item.getBaseItem().getName().toLowerCase().split("_")[2]); + int splittedHairdye = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairdye = 48; if (splittedHairdye == 0) { @@ -60,9 +60,9 @@ public class CustomizePetWithFurniEvent extends MessageHandler { } ((HorsePet) pet).setHairColor(newHairdye); - ((HorsePet) pet).needsUpdate = true; + pet.needsUpdate = true; } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairstyle")) { - int splittedHairstyle = Integer.valueOf(item.getBaseItem().getName().toLowerCase().split("_")[2]); + int splittedHairstyle = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairstyle = 100; if (splittedHairstyle == 0) { @@ -72,14 +72,14 @@ public class CustomizePetWithFurniEvent extends MessageHandler { } ((HorsePet) pet).setHairStyle(newHairstyle); - ((HorsePet) pet).needsUpdate = true; + pet.needsUpdate = true; } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) { ((HorsePet) pet).hasSaddle(true); ((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId()); - ((HorsePet) pet).needsUpdate = true; + pet.needsUpdate = true; } - if (((HorsePet) pet).needsUpdate) { + if (pet.needsUpdate) { Emulator.getThreading().run(pet); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose()); @@ -94,7 +94,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { ((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive); pet.getRoomUnit().clearStatus(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev"); - ((MonsterplantPet) pet).packetUpdate = true; + pet.packetUpdate = true; this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index 0ccef83f..3560895b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -23,11 +23,9 @@ public class MountPetEvent extends MessageHandler { Pet pet = room.getPet(petId); - if (!(pet instanceof RideablePet)) + if (!(pet instanceof RideablePet rideablePet)) return; - RideablePet rideablePet = (RideablePet) pet; - //dismount if (habbo.getHabboInfo().getRiding() != null) { habbo.getHabboInfo().dismountPet(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index 9c6fcb81..1e442e13 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -24,7 +24,7 @@ public class MovePetEvent extends MessageHandler { if (tile != null) { pet.getRoomUnit().setLocation(tile); pet.getRoomUnit().setPreviousLocation(tile); - pet.getRoomUnit().setZ(tile.z); + pet.getRoomUnit().setZ(tile.getZ()); pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.packet.readInt())); pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getZ()); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index b1ae1f62..26502132 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -62,7 +62,7 @@ public class OpenPetPackageEvent extends MessageHandler { room.sendComposer(new RemoveFloorItemComposer(item).compose()); RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); - room.sendComposer(new HeightMapUpdateMessageComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose()); + room.sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); item.setUserId(0); } else { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java index b9266e8b..4cf1be9d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java @@ -29,8 +29,7 @@ public class RemovePetFromFlatEvent extends MessageHandler { return; } - if (pet instanceof RideablePet) { - RideablePet rideablePet = (RideablePet) pet; + if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { rideablePet.getRider().getHabboInfo().dismountPet(true); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java index cd391176..8b3a1d87 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java @@ -7,28 +7,26 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetFigureUpdateComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class RemoveSaddleFromPetEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(RemoveSaddleFromPetEvent.class); + @Override public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); Pet pet = room.getPet(this.packet.readInt()); - if (pet == null || !(pet instanceof HorsePet) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; - - HorsePet horse = (HorsePet) pet; + if (!(pet instanceof HorsePet horse) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; if (!horse.hasSaddle()) return; @@ -40,12 +38,12 @@ public class RemoveSaddleFromPetEvent extends MessageHandler { if (set.next()) { saddleItemId = set.getInt("id"); } else { - LOGGER.error("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId()); + log.error("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId()); return; } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java index fd742cc2..3ca3fa26 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java @@ -21,7 +21,7 @@ public class RespectPetEvent extends MessageHandler { return; } - if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) { + if (this.client.getHabbo().getHabboStats().getPetRespectPointsToGive() > 0 || pet instanceof MonsterplantPet) { pet.scratched(this.client.getHabbo()); // Update the stats to the database. diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java index 3d974c42..f90c0680 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java @@ -16,11 +16,9 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); - if (pet == null || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId() || !(pet instanceof RideablePet)) + if (pet == null || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId() || !(pet instanceof RideablePet rideablePet)) return; - RideablePet rideablePet = ((RideablePet) pet); - rideablePet.setAnyoneCanRide(!rideablePet.anyoneCanRide()); rideablePet.needsUpdate = true; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java index f369c4d8..52d74b2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java @@ -7,11 +7,11 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ChatEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ChatEvent.class); + @Override @@ -40,7 +40,7 @@ public class ChatEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - LOGGER.info(reportMessage); + log.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 9e13a1a2..e16ce5e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -12,11 +12,11 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class MoveAvatarEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(MoveAvatarEvent.class); + @Override public int getRatelimit() { @@ -102,23 +102,18 @@ public class MoveAvatarEvent extends MessageHandler { if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) return; } - if (room.canLayAt(tile.x, tile.y)) { - HabboItem bed = room.getTopItemAt(tile.x, tile.y); + if (room.canLayAt(tile.getX(), tile.getY())) { + HabboItem bed = room.getTopItemAt(tile.getX(), tile.getY()); if (bed != null && bed.getBaseItem().allowLay()) { - RoomTile pillow = room.getLayout().getTile(bed.getX(), bed.getY()); - switch (bed.getRotation()) { - case 0: - case 4: - pillow = room.getLayout().getTile((short) x, bed.getY()); - break; - case 2: - case 8: - pillow = room.getLayout().getTile(bed.getX(), (short) y); - break; - } + room.getLayout().getTile(bed.getX(), bed.getY()); + RoomTile pillow = switch (bed.getRotation()) { + case 0, 4 -> room.getLayout().getTile((short) x, bed.getY()); + case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y); + default -> room.getLayout().getTile(bed.getX(), bed.getY()); + }; - if (pillow != null && room.canLayAt(pillow.x, pillow.y)) { + if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) { roomUnit.setGoalLocation(pillow); return; } @@ -143,7 +138,7 @@ public class MoveAvatarEvent extends MessageHandler { } // This is where we set the end location and begin finding a path - if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { + if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get(); roomUnit.setGoalLocation(tile); @@ -158,7 +153,7 @@ public class MoveAvatarEvent extends MessageHandler { } } } catch (InterruptedException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); Thread.currentThread().interrupt(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java index 9cca2fb5..085e814f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java @@ -13,8 +13,7 @@ public class RespectUserEvent extends MessageHandler { if (userId == client.getHabbo().getHabboInfo().getId()) { return; } - - if (this.client.getHabbo().getHabboStats().respectPointsToGive > 0) { + if (this.client.getHabbo().getHabboStats().getRespectPointsToGive() > 0) { Habbo target = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); if (Emulator.getPluginManager().isRegistered(UserRespectedEvent.class, false)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java index db555d07..58341211 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java @@ -6,11 +6,10 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ShoutEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ShoutEvent.class); @Override public void handle() throws Exception { @@ -38,7 +37,7 @@ public class ShoutEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - LOGGER.info(reportMessage); + log.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java index 9c582fd4..1875abe7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java @@ -6,11 +6,10 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class WhisperEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(WhisperEvent.class); @Override public void handle() throws Exception { @@ -35,7 +34,7 @@ public class WhisperEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", chatMessage.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - LOGGER.info(reportMessage); + log.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java index a7e827e7..0e26abbb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java @@ -10,7 +10,7 @@ public class ConfirmAcceptTradingEvent extends MessageHandler { Habbo habbo = this.client.getHabbo(); RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); - if (trade == null || !trade.getRoomTradeUserForHabbo(habbo).getAccepted()) + if (trade == null || !trade.getRoomTradeUserForHabbo(habbo).isAccepted()) return; trade.confirm(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java index f5697edf..3772f070 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java @@ -12,8 +12,8 @@ import com.eu.habbo.messages.outgoing.trading.TradingOpenFailedComposer; public class OpenTradingEvent extends MessageHandler { @Override public void handle() throws Exception { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastTradeTimestamp > 10) { - this.client.getHabbo().getHabboStats().lastTradeTimestamp = Emulator.getIntUnixTimestamp(); + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().getLastTradeTimestamp() > 10) { + this.client.getHabbo().getHabboStats().setLastTradeTimestamp(Emulator.getIntUnixTimestamp()); int userId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java index 67a02791..4be70a95 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java @@ -13,7 +13,7 @@ public class RemoveItemFromTradeEvent extends MessageHandler { if (trade != null) { HabboItem item = trade.getRoomTradeUserForHabbo(this.client.getHabbo()).getItem(itemId); - if (!trade.getRoomTradeUserForHabbo(this.client.getHabbo()).getAccepted() && item != null) { + if (!trade.getRoomTradeUserForHabbo(this.client.getHabbo()).isAccepted() && item != null) { trade.removeItem(this.client.getHabbo(), item); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java index 07af6e6f..9831d9a6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java @@ -12,7 +12,7 @@ public class AvatarEffectSelectedEvent extends MessageHandler { this.client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); } } else { - this.client.getHabbo().getInventory().getEffectsComponent().activatedEffect = 0; + this.client.getHabbo().getInventory().getEffectsComponent().setActivatedEffect(0); if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(this.client.getHabbo().getRoomUnit(), 0, -1); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java index 2d62abd4..0a4a35b1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java @@ -10,8 +10,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer import com.eu.habbo.messages.outgoing.users.CheckUserNameResultMessageComposer; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import com.eu.habbo.plugin.events.users.UserNameChangedEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -19,27 +18,27 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +@Slf4j public class ChangeUserNameEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ChangeUserNameEvent.class); public static final List changingUsernames = new ArrayList<>(2); @Override public void handle() throws Exception { - if (!this.client.getHabbo().getHabboStats().allowNameChange) + if (!this.client.getHabbo().getHabboStats().isAllowNameChange()) return; String name = this.packet.readString(); if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) { - this.client.getHabbo().getHabboStats().allowNameChange = false; + this.client.getHabbo().getHabboStats().setAllowNameChange(false); this.client.sendResponse(new ChangeUserNameResultMessageEvent(this.client.getHabbo())); this.client.sendResponse(new UserNameChangedMessageComposer(this.client.getHabbo()).compose()); this.client.sendResponse(new UserObjectComposer(this.client.getHabbo())); return; } - if (name.equals(this.client.getHabbo().getHabboStats().changeNameChecked)) { + if (name.equals(this.client.getHabbo().getHabboStats().getChangeNameChecked())) { HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(name); if (habboInfo == null) { @@ -51,7 +50,7 @@ public class ChangeUserNameEvent extends MessageHandler { } String oldName = this.client.getHabbo().getHabboInfo().getUsername(); - this.client.getHabbo().getHabboStats().allowNameChange = false; + this.client.getHabbo().getHabboStats().setAllowNameChange(false); this.client.getHabbo().getHabboInfo().setUsername(name); this.client.getHabbo().getHabboInfo().run(); @@ -84,7 +83,7 @@ public class ChangeUserNameEvent extends MessageHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } else { this.client.sendResponse(new CheckUserNameResultMessageComposer(CheckUserNameResultMessageComposer.TAKEN_WITH_SUGGESTIONS, name, new ArrayList<>())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java index 8efc04cf..ccc093cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java @@ -13,7 +13,7 @@ public class CheckUserNameEvent extends MessageHandler { @Override public void handle() throws Exception { - if (!this.client.getHabbo().getHabboStats().allowNameChange) + if (!this.client.getHabbo().getHabboStats().isAllowNameChange()) return; String name = this.packet.readString(); @@ -42,7 +42,7 @@ public class CheckUserNameEvent extends MessageHandler { if (!checkName.isEmpty()) { errorCode = CheckUserNameResultMessageComposer.NOT_VALID; } else { - this.client.getHabbo().getHabboStats().changeNameChecked = name; + this.client.getHabbo().getHabboStats().setChangeNameChecked(name); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/EventLogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/EventLogEvent.java index 890f55bc..3add342b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/EventLogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/EventLogEvent.java @@ -11,41 +11,31 @@ public class EventLogEvent extends MessageHandler { String value = this.packet.readString(); String action = this.packet.readString(); - switch (type) { - case "Quiz": - if (value.equalsIgnoreCase("7")) { - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SafetyQuizGraduate")); - } + if ("Quiz".equals(type)) { + if (value.equalsIgnoreCase("7")) { + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SafetyQuizGraduate")); + } } switch (action) { - case "forum.can.read.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanReadSeen")); - break; - case "forum.can.post.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanPostSeen")); - break; - case "forum.can.start.thread.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanPostThrdSeen")); - break; - case "forum.can.moderate.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanModerateSeen")); - break; - case "room.settings.doormode.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModDoorModeSeen")); - break; - case "room.settings.walkthrough.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModWalkthroughSeen")); - break; - case "room.settings.chat.scrollspeed.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatScrollSpeedSeen")); - break; - case "room.settings.chat.hearrange.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatHearRangeSeen")); - break; - case "room.settings.chat.floodfilter.seen": - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatFloodFilterSeen")); - break; + case "forum.can.read.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanReadSeen")); + case "forum.can.post.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanPostSeen")); + case "forum.can.start.thread.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanPostThrdSeen")); + case "forum.can.moderate.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModForumCanModerateSeen")); + case "room.settings.doormode.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModDoorModeSeen")); + case "room.settings.walkthrough.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModWalkthroughSeen")); + case "room.settings.chat.scrollspeed.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatScrollSpeedSeen")); + case "room.settings.chat.hearrange.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatHearRangeSeen")); + case "room.settings.chat.floodfilter.seen" -> + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatFloodFilterSeen")); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/GetCreditsInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/GetCreditsInfoEvent.java index 7c8ad15a..475a4d81 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/GetCreditsInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/GetCreditsInfoEvent.java @@ -1,8 +1,8 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer; +import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer; public class GetCreditsInfoEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/InfoRetrieveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/InfoRetrieveEvent.java index add32f4e..606e6ef5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/InfoRetrieveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/InfoRetrieveEvent.java @@ -6,13 +6,13 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.AccountPreferencesComposer; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import com.eu.habbo.messages.outgoing.users.UserPerksComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; +@Slf4j public class InfoRetrieveEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(InfoRetrieveEvent.class); + @Override public void handle() throws Exception { @@ -56,7 +56,7 @@ public class InfoRetrieveEvent extends MessageHandler { } else { - LOGGER.debug("Attempted to request user data where Habbo was null."); + log.debug("Attempted to request user data where Habbo was null."); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceGetGiftsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceGetGiftsEvent.java index bc83bc9a..08844c00 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceGetGiftsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceGetGiftsEvent.java @@ -14,8 +14,8 @@ public class NewUserExperienceGetGiftsEvent extends MessageHandler { int index = this.packet.readInt(); if (!Emulator.getPluginManager().fireEvent(new UserPickGiftEvent(this.client.getHabbo(), keyA, keyB, index)).isCancelled()) { - if (!this.client.getHabbo().getHabboStats().nuxReward && Emulator.getConfig().getBoolean("hotel.nux.gifts.enabled")){ - this.client.getHabbo().getHabboStats().nuxReward = true; + if (!this.client.getHabbo().getHabboStats().isNuxReward() && Emulator.getConfig().getBoolean("hotel.nux.gifts.enabled")){ + this.client.getHabbo().getHabboStats().setNuxReward(true); NewUserGift gift = Emulator.getGameEnvironment().getItemManager().getNewUserGift(index + 1); if (gift != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceScriptProceedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceScriptProceedEvent.java index e3921e38..8761b713 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceScriptProceedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/NewUserExperienceScriptProceedEvent.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.Map; public class NewUserExperienceScriptProceedEvent extends MessageHandler { - public static Map keys = new HashMap() { + public static Map keys = new HashMap<>() { { this.put(1, "BOTTOM_BAR_RECEPTION"); this.put(2, "BOTTOM_BAR_NAVIGATOR"); @@ -26,12 +26,12 @@ public class NewUserExperienceScriptProceedEvent extends MessageHandler { }; public static void handle(Habbo habbo) { - habbo.getHabboStats().nux = true; - int step = habbo.getHabboStats().nuxStep++; + habbo.getHabboStats().setNux(true); + int step = habbo.getHabboStats().increaseNuxStep(); if (keys.containsKey(step)) { habbo.getClient().sendResponse(new InClientLinkMessageComposer("helpBubble/add/" + keys.get(step) + "/" + Emulator.getTexts().getValue("nux.step." + step))); - } else if (!habbo.getHabboStats().nuxReward) { + } else if (!habbo.getHabboStats().isNuxReward()) { } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatPreferencesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatPreferencesEvent.java index 330efe55..e796b26a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatPreferencesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatPreferencesEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; public class SetChatPreferencesEvent extends MessageHandler { @Override public void handle() throws Exception { - this.client.getHabbo().getHabboStats().preferOldChat = this.packet.readBoolean(); + this.client.getHabbo().getHabboStats().setPreferOldChat(this.packet.readBoolean()); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java index dee4661d..af668572 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java @@ -12,12 +12,12 @@ public class SetChatStylePreferenceEvent extends MessageHandler { if (!this.client.getHabbo().hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { - if (Integer.valueOf(s) == chatBubble) { + if (Integer.parseInt(s) == chatBubble) { return; } } } - this.client.getHabbo().getHabboStats().chatColor = RoomChatMessageBubbles.getBubble(chatBubble); + this.client.getHabbo().getHabboStats().setChatColor(RoomChatMessageBubbles.getBubble(chatBubble)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetIgnoreRoomInvitesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetIgnoreRoomInvitesEvent.java index d272b9b5..e3f02753 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetIgnoreRoomInvitesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetIgnoreRoomInvitesEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; public class SetIgnoreRoomInvitesEvent extends MessageHandler { @Override public void handle() throws Exception { - this.client.getHabbo().getHabboStats().blockRoomInvites = this.packet.readBoolean(); + this.client.getHabbo().getHabboStats().setBlockRoomInvites(this.packet.readBoolean()); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetRoomCameraPreferencesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetRoomCameraPreferencesEvent.java index bc948c70..34e98531 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetRoomCameraPreferencesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetRoomCameraPreferencesEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; public class SetRoomCameraPreferencesEvent extends MessageHandler { @Override public void handle() throws Exception { - this.client.getHabbo().getHabboStats().blockCameraFollow = this.packet.readBoolean(); + this.client.getHabbo().getHabboStats().setBlockCameraFollow(this.packet.readBoolean()); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetSoundSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetSoundSettingsEvent.java index 4c2108fe..e3aa16d3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetSoundSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetSoundSettingsEvent.java @@ -11,9 +11,9 @@ public class SetSoundSettingsEvent extends MessageHandler { int furni = this.packet.readInt(); int trax = this.packet.readInt(); - this.client.getHabbo().getHabboStats().volumeSystem = system; - this.client.getHabbo().getHabboStats().volumeFurni = furni; - this.client.getHabbo().getHabboStats().volumeTrax = trax; + this.client.getHabbo().getHabboStats().setVolumeSystem(system); + this.client.getHabbo().getHabboStats().setVolumeFurni(furni); + this.client.getHabbo().getHabboStats().setVolumeTrax(trax); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java index efc4b558..c6701b97 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java @@ -9,11 +9,10 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.eu.habbo.messages.outgoing.users.FigureUpdateComposer; import com.eu.habbo.plugin.events.users.UserSavedLookEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class UpdateFigureDataEvent extends MessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(UpdateFigureDataEvent.class); @Override public void handle() throws Exception { @@ -25,7 +24,7 @@ public class UpdateFigureDataEvent extends MessageHandler { } catch (IllegalArgumentException e) { String message = Emulator.getTexts().getValue("scripter.warning.look.gender").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%gender%", genderCode); ScripterManager.scripterDetected(this.client, message); - LOGGER.info(message); + log.info(message); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java index 8983b29e..2fecafd0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java @@ -7,7 +7,7 @@ public class UpdateUIFlagsEvent extends MessageHandler { public void handle() throws Exception { int flags = this.packet.readInt(); - this.client.getHabbo().getHabboStats().uiFlags = flags; + this.client.getHabbo().getHabboStats().setUiFlags(flags); this.client.getHabbo().getHabboStats().run(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 119456ce..55e0c3a9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import java.util.ArrayList; @@ -29,8 +29,8 @@ public class ApplySnapshotEvent extends MessageHandler { // Executing Habbo has to be in a Room if (!this.client.getHabbo().getRoomUnit().isInRoom()) { this.client.sendResponse(new NotificationDialogMessageComposer( - BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, - FurnitureMovementError.NO_RIGHTS.errorCode + BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), + FurnitureMovementError.NO_RIGHTS.getErrorCode() )); return; } @@ -56,18 +56,16 @@ public class ApplySnapshotEvent extends MessageHandler { HabboItem wiredItem = item.get(); // The item should have settings to match furni state, position and rotation - if (wiredItem instanceof InteractionWiredMatchFurniSettings) { - - InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; + if (wiredItem instanceof InteractionWiredMatchFurniSettings wired) { // Try to apply the set settings to each item wired.getMatchFurniSettings().forEach(setting -> { - HabboItem matchItem = room.getHabboItem(setting.item_id); + HabboItem matchItem = room.getHabboItem(setting.getItem_id()); // Match state if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { - if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { - matchItem.setExtradata(setting.state); + if (!setting.getState().equals(" ") && !matchItem.getExtradata().equals(setting.getState())) { + matchItem.setExtradata(setting.getState()); room.updateItemState(matchItem); } } @@ -77,16 +75,16 @@ public class ApplySnapshotEvent extends MessageHandler { // Match Position & Rotation if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { - if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { - room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); + if(matchItem.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) { + room.moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true); } } else if(wired.shouldMatchPosition()) { - boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; - RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); - int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); + boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.getRotation(); + RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); + int newRotation = wired.shouldMatchRotation() ? setting.getRotation() : matchItem.getRotation(); - if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { + if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { if(slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index e0022e8b..a5f34cb4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -31,6 +31,8 @@ public class UpdateActionEvent extends MessageHandler { effect.needsUpdate(true); Emulator.getThreading().run(effect); } + + } catch (WiredSaveException e) { this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index e81fceb9..c4f1b991 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -27,12 +27,13 @@ public class UpdateConditionEvent extends MessageHandler { if (condition.saveData(settings)) { this.client.sendResponse(new WiredSavedComposer()); - condition.needsUpdate(true); + condition.needsUpdate(true); Emulator.getThreading().run(condition); } else { this.client.sendResponse(new WiredValidationErrorComposer("There was an error while saving that condition")); } + } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index e839d335..fd6b3384 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -27,7 +27,7 @@ public class UpdateTriggerEvent extends MessageHandler { if (trigger.saveData(settings)) { this.client.sendResponse(new WiredSavedComposer()); - trigger.needsUpdate(true); + trigger.needsUpdate(true); Emulator.getThreading().run(trigger); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredSaveException.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredSaveException.java index 74feda15..12da1098 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredSaveException.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredSaveException.java @@ -1,13 +1,11 @@ package com.eu.habbo.messages.incoming.wired; +import lombok.AllArgsConstructor; + +@AllArgsConstructor public class WiredSaveException extends Exception { - private final String message; - public WiredSaveException(String message) { - this.message = message; - } - @Override public String getMessage() { return this.message; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementComposer.java index e2062bb3..e2c443d9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementComposer.java @@ -7,16 +7,13 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AchievementComposer extends MessageComposer { private final Habbo habbo; private final Achievement achievement; - public AchievementComposer(Habbo habbo, Achievement achievement) { - this.habbo = habbo; - this.achievement = achievement; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.achievementComposer); @@ -27,26 +24,26 @@ public class AchievementComposer extends MessageComposer { achievementProgress = this.habbo.getHabboStats().getAchievementProgress(this.achievement); currentLevel = this.achievement.getLevelForProgress(achievementProgress); - nextLevel = this.achievement.getNextLevel(currentLevel != null ? currentLevel.level : 0); + nextLevel = this.achievement.getNextLevel(currentLevel != null ? currentLevel.getLevel() : 0); - if (currentLevel != null && currentLevel.level == this.achievement.levels.size()) + if (currentLevel != null && currentLevel.getLevel() == this.achievement.levels.size()) nextLevel = null; int targetLevel = 1; if (nextLevel != null) - targetLevel = nextLevel.level; + targetLevel = nextLevel.getLevel(); - if (currentLevel != null && currentLevel.level == this.achievement.levels.size()) - targetLevel = currentLevel.level; + if (currentLevel != null && currentLevel.getLevel() == this.achievement.levels.size()) + targetLevel = currentLevel.getLevel(); this.response.appendInt(this.achievement.id); //ID this.response.appendInt(targetLevel); //Target level this.response.appendString("ACH_" + this.achievement.name + targetLevel); //Target badge code - this.response.appendInt(currentLevel != null ? currentLevel.progress : 0); //Last level progress needed - this.response.appendInt(nextLevel != null ? nextLevel.progress : 0); //Progress needed - this.response.appendInt(nextLevel != null ? nextLevel.rewardAmount : 0); //Reward amount - this.response.appendInt(nextLevel != null ? nextLevel.rewardType : 0); //Reward currency ID + this.response.appendInt(currentLevel != null ? currentLevel.getProgress() : 0); //Last level progress needed + this.response.appendInt(nextLevel != null ? nextLevel.getProgress() : 0); //Progress needed + this.response.appendInt(nextLevel != null ? nextLevel.getRewardAmount() : 0); //Reward amount + this.response.appendInt(nextLevel != null ? nextLevel.getRewardType() : 0); //Reward currency ID this.response.appendInt(achievementProgress == -1 ? 0 : achievementProgress); //Current progress this.response.appendBoolean(AchievementManager.hasAchieved(this.habbo, this.achievement)); //Achieved? (Current Progress == MaxLevel.Progress) this.response.appendString(this.achievement.category.toString().toLowerCase()); //Category diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementUnlockedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementUnlockedComposer.java index bae76270..f70c4732 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementUnlockedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementUnlockedComposer.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AchievementUnlockedComposer extends MessageComposer { - private final Achievement achievement; private final Habbo habbo; - - public AchievementUnlockedComposer(Habbo habbo, Achievement achievement) { - this.achievement = achievement; - this.habbo = habbo; - } + private final Achievement achievement; @Override protected ServerMessage composeInternal() { @@ -22,15 +19,15 @@ public class AchievementUnlockedComposer extends MessageComposer { AchievementLevel level = this.achievement.getLevelForProgress(this.habbo.getHabboStats().getAchievementProgress(this.achievement)); this.response.appendInt(this.achievement.id); - this.response.appendInt(level.level); + this.response.appendInt(level.getLevel()); this.response.appendInt(144); - this.response.appendString("ACH_" + this.achievement.name + level.level); - this.response.appendInt(level.rewardAmount); - this.response.appendInt(level.rewardType); + this.response.appendString("ACH_" + this.achievement.name + level.getLevel()); + this.response.appendInt(level.getRewardAmount()); + this.response.appendInt(level.getRewardType()); this.response.appendInt(0); this.response.appendInt(10); this.response.appendInt(21); - this.response.appendString(level.level > 1 ? "ACH_" + this.achievement.name + (level.level - 1) : ""); + this.response.appendString(level.getLevel() > 1 ? "ACH_" + this.achievement.name + (level.getLevel() - 1) : ""); this.response.appendString(this.achievement.category.name()); this.response.appendBoolean(true); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementsComposer.java index 36635c92..82982bde 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementsComposer.java @@ -8,18 +8,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor public class AchievementsComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(AchievementsComposer.class); private final Habbo habbo; - public AchievementsComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.achievementsComposer); @@ -34,16 +31,16 @@ public class AchievementsComposer extends MessageComposer { achievementProgress = this.habbo.getHabboStats().getAchievementProgress(achievement); currentLevel = achievement.getLevelForProgress(achievementProgress); - nextLevel = achievement.getNextLevel(currentLevel != null ? currentLevel.level : 0); + nextLevel = achievement.getNextLevel(currentLevel != null ? currentLevel.getLevel() : 0); this.response.appendInt(achievement.id); //ID - this.response.appendInt(nextLevel != null ? nextLevel.level : currentLevel != null ? currentLevel.level : 0); // - this.response.appendString("ACH_" + achievement.name + (nextLevel != null ? nextLevel.level : currentLevel != null ? currentLevel.level : 0)); //Target badge code - this.response.appendInt(currentLevel != null ? currentLevel.progress : 0); //Last level progress needed - this.response.appendInt(nextLevel != null ? nextLevel.progress : -1); //Progress needed - this.response.appendInt(nextLevel != null ? nextLevel.rewardAmount : -1); //Reward amount - this.response.appendInt(nextLevel != null ? nextLevel.rewardType : -1); //Reward currency ID - this.response.appendInt(achievementProgress <= 0 ? 0 : achievementProgress); //Current progress + this.response.appendInt(nextLevel != null ? nextLevel.getLevel() : currentLevel != null ? currentLevel.getLevel() : 0); // + this.response.appendString("ACH_" + achievement.name + (nextLevel != null ? nextLevel.getLevel() : currentLevel != null ? currentLevel.getLevel() : 0)); //Target badge code + this.response.appendInt(currentLevel != null ? currentLevel.getProgress() : 0); //Last level progress needed + this.response.appendInt(nextLevel != null ? nextLevel.getProgress() : -1); //Progress needed + this.response.appendInt(nextLevel != null ? nextLevel.getRewardAmount() : -1); //Reward amount + this.response.appendInt(nextLevel != null ? nextLevel.getRewardType() : -1); //Reward currency ID + this.response.appendInt(Math.max(achievementProgress, 0)); //Current progress this.response.appendBoolean(AchievementManager.hasAchieved(this.habbo, achievement)); //Achieved? (Current Progress == MaxLevel.Progress) this.response.appendString(achievement.category.toString().toLowerCase()); //Category this.response.appendString(""); //Empty, completly unused in client code @@ -53,7 +50,7 @@ public class AchievementsComposer extends MessageComposer { this.response.appendString(""); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpComposer.java index 5a966952..b141eacf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpComposer.java @@ -6,16 +6,13 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TalentLevelUpComposer extends MessageComposer { private final TalentTrackType talentTrackType; private final TalentTrackLevel talentTrackLevel; - public TalentLevelUpComposer(TalentTrackType talentTrackType, TalentTrackLevel talentTrackLevel) { - this.talentTrackType = talentTrackType; - this.talentTrackLevel = talentTrackLevel; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.talentLevelUpComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackMessageComposer.java index 7964e7d0..3365d161 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackMessageComposer.java @@ -9,18 +9,19 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; +@AllArgsConstructor +@Getter public class TalentTrackMessageComposer extends MessageComposer { - public final Habbo habbo; - public final TalentTrackType type; - public TalentTrackMessageComposer(Habbo habbo, TalentTrackType type) { - this.habbo = habbo; - this.type = type; - } + private final Habbo habbo; + private final TalentTrackType type; + @Override protected ServerMessage composeInternal() { @@ -65,7 +66,7 @@ public class TalentTrackMessageComposer extends MessageComposer { achievementLevel = achievement.firstLevel(); } if (finalState != TalentTrackState.LOCKED) { - if (achievementLevel != null && achievementLevel.progress <= progress) { + if (achievementLevel != null && achievementLevel.getProgress() <= progress) { this.response.appendInt(2); } else { this.response.appendInt(1); @@ -74,7 +75,7 @@ public class TalentTrackMessageComposer extends MessageComposer { this.response.appendInt(0); } this.response.appendInt(progress); - this.response.appendInt(achievementLevel != null ? achievementLevel.progress : 0); + this.response.appendInt(achievementLevel != null ? achievementLevel.getProgress() : 0); } else { this.response.appendInt(0); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPriceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPriceComposer.java index 264fc828..f2b3d41e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPriceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPriceComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.camera; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class CameraPriceComposer extends MessageComposer { - public final int credits; - public final int points; - public final int pointsType; - - public CameraPriceComposer(int credits, int points, int pointsType) { - this.credits = credits; - this.points = points; - this.pointsType = pointsType; - } + private final int credits; + private final int points; + private final int pointsType; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishStatusMessageComposer.java index 1f33dbcc..3d737210 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishStatusMessageComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.camera; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class CameraPublishStatusMessageComposer extends MessageComposer { - public final boolean isOk; - public final int cooldownSeconds; - public final String extraDataId; - - public CameraPublishStatusMessageComposer(boolean isOk, int cooldownSeconds, String extraDataId) { - this.isOk = isOk; - this.cooldownSeconds = cooldownSeconds; - this.extraDataId = extraDataId; - } + private final boolean isOk; + private final int cooldownSeconds; + private final String extraDataId; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraStorageUrlMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraStorageUrlMessageComposer.java index 270078ac..9422c105 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraStorageUrlMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraStorageUrlMessageComposer.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.camera; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CameraStorageUrlMessageComposer extends MessageComposer { private final String URL; - public CameraStorageUrlMessageComposer(String url) { - this.URL = url; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CompetitionStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CompetitionStatusMessageComposer.java index 7db4c6c5..94c762ef 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CompetitionStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CompetitionStatusMessageComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.camera; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CompetitionStatusMessageComposer extends MessageComposer { private final boolean unknownBoolean; private final String unknownString; - public CompetitionStatusMessageComposer(boolean unknownBoolean, String unknownString) { - this.unknownBoolean = unknownBoolean; - this.unknownString = unknownString; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ApproveNameMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ApproveNameMessageComposer.java index 0e8f7337..d9ac7ec9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ApproveNameMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ApproveNameMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ApproveNameMessageComposer extends MessageComposer { public static final int NAME_OK = 0; public static final int NAME_TO_LONG = 1; @@ -14,10 +16,6 @@ public class ApproveNameMessageComposer extends MessageComposer { private final int type; private final String value; - public ApproveNameMessageComposer(int type, String value) { - this.type = type; - this.value = value; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/BuildersClubFurniCountMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/BuildersClubFurniCountMessageComposer.java index f4f2f9dd..40b80886 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/BuildersClubFurniCountMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/BuildersClubFurniCountMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BuildersClubFurniCountMessageComposer extends MessageComposer { private final int mode; - public BuildersClubFurniCountMessageComposer(int mode) { - this.mode = mode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.buildersClubFurniCountMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageMessageComposer.java index fab21fa0..f987b141 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageMessageComposer.java @@ -11,24 +11,21 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +@AllArgsConstructor public class CatalogPageMessageComposer extends MessageComposer { private final CatalogPage page; private final Habbo habbo; private final int offerId; private final String mode; - public CatalogPageMessageComposer(CatalogPage page, Habbo habbo, int offerId, String mode) { - this.page = page; - this.habbo = habbo; - this.offerId = offerId; - this.mode = mode; - } + @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java index 453458b2..6a50d752 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java @@ -7,13 +7,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.List; +@Slf4j public class CatalogPagesListComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPagesListComposer.class); private final Habbo habbo; private final String mode; @@ -49,7 +48,7 @@ public class CatalogPagesListComposer extends MessageComposer { return this.response; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftInfoComposer.java index dddb863b..44ab0e13 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftInfoComposer.java @@ -7,23 +7,19 @@ import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Collections; import java.util.List; +@AllArgsConstructor public class ClubGiftInfoComposer extends MessageComposer { private final int daysTillNextGift; private final int availableGifts; private final int daysAsHc; - public ClubGiftInfoComposer(int daysTillNextGift, int availableGifts, int daysAsHc) { - this.daysTillNextGift = daysTillNextGift; - this.availableGifts = availableGifts; - this.daysAsHc = daysAsHc; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.clubGiftInfoComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/HabboClubOffersMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/HabboClubOffersMessageComposer.java index 2dc02cd3..ec42ff70 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/HabboClubOffersMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/HabboClubOffersMessageComposer.java @@ -6,17 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class HabboClubOffersMessageComposer extends MessageComposer { - private final int windowId; private final Habbo habbo; + private final int windowId; - public HabboClubOffersMessageComposer(Habbo habbo, int windowId) { - this.habbo = habbo; - this.windowId = windowId; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughBalanceMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughBalanceMessageComposer.java index 505313d3..97dbfe18 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughBalanceMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughBalanceMessageComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NotEnoughBalanceMessageComposer extends MessageComposer { private final boolean isCredits; private final boolean isPixels; private final int pointsType; - public NotEnoughBalanceMessageComposer(boolean isCredits, boolean isPixels, int pointsType) { - this.isCredits = isCredits; - this.isPixels = isPixels; - this.pointsType = pointsType; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.notEnoughBalanceMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetReceivedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetReceivedMessageComposer.java index 297f8c4a..85996747 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetReceivedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetReceivedMessageComposer.java @@ -4,16 +4,12 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetReceivedMessageComposer extends MessageComposer { private final Pet pet; private final boolean gift; - - public PetReceivedMessageComposer(Pet pet, boolean gift) { - this.pet = pet; - this.gift = gift; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petReceivedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ProductOfferComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ProductOfferComposer.java index 1f9e5ea6..d48e5d38 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ProductOfferComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ProductOfferComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ProductOfferComposer extends MessageComposer { private final CatalogItem item; - public ProductOfferComposer(CatalogItem item) { - this.item = item; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseErrorMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseErrorMessageComposer.java index f0d36d92..a931d7dc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseErrorMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseErrorMessageComposer.java @@ -3,16 +3,15 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PurchaseErrorMessageComposer extends MessageComposer { public static final int SERVER_ERROR = 0; public static final int ALREADY_HAVE_BADGE = 1; private final int error; - public PurchaseErrorMessageComposer(int error) { - this.error = error; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseNotAllowedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseNotAllowedMessageComposer.java index 4b748398..3d813e7f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseNotAllowedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseNotAllowedMessageComposer.java @@ -3,16 +3,15 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PurchaseNotAllowedMessageComposer extends MessageComposer { public final static int ILLEGAL = 0; public final static int REQUIRES_CLUB = 1; private final int code; - public PurchaseNotAllowedMessageComposer(int code) { - this.code = code; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKMessageComposer.java index 9c6d571a..15daebaa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PurchaseOKMessageComposer extends MessageComposer { private final CatalogItem catalogItem; - public PurchaseOKMessageComposer(CatalogItem catalogItem) { - this.catalogItem = catalogItem; - } public PurchaseOKMessageComposer() { this.catalogItem = null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerFinishedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerFinishedComposer.java index cfeedd79..5cb2b544 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerFinishedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerFinishedComposer.java @@ -3,16 +3,15 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RecyclerFinishedComposer extends MessageComposer { public static final int RECYCLING_COMPLETE = 1; public static final int RECYCLING_CLOSED = 2; private final int code; - public RecyclerFinishedComposer(int code) { - this.code = code; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerPrizesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerPrizesComposer.java index 2468038d..c0c5518c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerPrizesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerPrizesComposer.java @@ -16,7 +16,7 @@ public class RecyclerPrizesComposer extends MessageComposer { this.response.appendInt(Emulator.getGameEnvironment().getCatalogManager().prizes.size()); for (Map.Entry> map : Emulator.getGameEnvironment().getCatalogManager().prizes.entrySet()) { this.response.appendInt(map.getKey()); - this.response.appendInt(Integer.valueOf(Emulator.getConfig().getValue("hotel.ecotron.rarity.chance." + map.getKey()))); + this.response.appendInt(Integer.parseInt(Emulator.getConfig().getValue("hotel.ecotron.rarity.chance." + map.getKey()))); this.response.appendInt(map.getValue().size()); for (Item item : map.getValue()) { this.response.appendString(item.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ScrSendKickbackInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ScrSendKickbackInfoMessageComposer.java index 1f61ae09..7b54c146 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ScrSendKickbackInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ScrSendKickbackInfoMessageComposer.java @@ -3,29 +3,22 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class ScrSendKickbackInfoMessageComposer extends MessageComposer { - public final int currentHcStreak; - public final String firstSubDate; - public final double kickbackPercentage; - public final int totalCreditsMissed; - public final int totalCreditsRewarded; - public final int totalCreditsSpent; - public final int creditRewardForStreakBonus; - public final int creditRewardForMonthlySpent; - public final int timeUntilPayday; + private final int currentHcStreak; + private final String firstSubDate; + private final double kickbackPercentage; + private final int totalCreditsMissed; + private final int totalCreditsRewarded; + private final int totalCreditsSpent; + private final int creditRewardForStreakBonus; + private final int creditRewardForMonthlySpent; + private final int timeUntilPayday; - public ScrSendKickbackInfoMessageComposer(int currentHcStreak, String firstSubDate, double kickbackPercentage, int totalCreditsMissed, int totalCreditsRewarded, int totalCreditsSpent, int creditRewardForStreakBonus, int creditRewardForMonthlySpent, int timeUntilPayday) { - this.currentHcStreak = currentHcStreak; - this.firstSubDate = firstSubDate; - this.kickbackPercentage = kickbackPercentage; - this.totalCreditsMissed = totalCreditsMissed; - this.totalCreditsRewarded = totalCreditsRewarded; - this.totalCreditsSpent = totalCreditsSpent; - this.creditRewardForStreakBonus = creditRewardForStreakBonus; - this.creditRewardForMonthlySpent = creditRewardForMonthlySpent; - this.timeUntilPayday = timeUntilPayday; - } @Override protected ServerMessage composeInternal() { @@ -41,6 +34,4 @@ public class ScrSendKickbackInfoMessageComposer extends MessageComposer { this.response.appendInt(this.timeUntilPayday); // timeUntilPayday (minutes) return this.response; } - - } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/SellablePetPalettesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/SellablePetPalettesMessageComposer.java index adf68e78..e2cd024c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/SellablePetPalettesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/SellablePetPalettesMessageComposer.java @@ -5,15 +5,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SellablePetPalettesMessageComposer extends MessageComposer { private final String petName; private final THashSet petRaces; - public SellablePetPalettesMessageComposer(String petName, THashSet petRaces) { - this.petName = petName; - this.petRaces = petRaces; - } @Override protected ServerMessage composeInternal() { @@ -23,11 +21,11 @@ public class SellablePetPalettesMessageComposer extends MessageComposer { this.response.appendString(this.petName); this.response.appendInt(this.petRaces.size()); for (PetRace race : this.petRaces) { - this.response.appendInt(race.race); - this.response.appendInt(race.colorOne); - this.response.appendInt(race.colorTwo); - this.response.appendBoolean(race.hasColorOne); - this.response.appendBoolean(race.hasColorTwo); + this.response.appendInt(race.getRace()); + this.response.appendInt(race.getColorOne()); + this.response.appendInt(race.getColorTwo()); + this.response.appendBoolean(race.isHasColorOne()); + this.response.appendBoolean(race.isHasColorTwo()); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/TargetedOfferComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/TargetedOfferComposer.java index 099501e4..1393f3a0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/TargetedOfferComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/TargetedOfferComposer.java @@ -6,15 +6,13 @@ import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TargetedOfferComposer extends MessageComposer { private final Habbo habbo; private final TargetOffer offer; - public TargetedOfferComposer(Habbo habbo, TargetOffer offer) { - this.habbo = habbo; - this.offer = offer; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/VoucherRedeemErrorMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/VoucherRedeemErrorMessageComposer.java index 66a0ffaa..b89beae0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/VoucherRedeemErrorMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/VoucherRedeemErrorMessageComposer.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.outgoing.catalog; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class VoucherRedeemErrorMessageComposer extends MessageComposer { public static final int INVALID_CODE = 0; public static final int TECHNICAL_ERROR = 1; - private final int code; - public VoucherRedeemErrorMessageComposer(int code) { - this.code = code; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.voucherRedeemErrorMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketPlaceOwnOffersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketPlaceOwnOffersComposer.java index 51ed5278..2f4bdb8c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketPlaceOwnOffersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketPlaceOwnOffersComposer.java @@ -7,18 +7,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor public class MarketPlaceOwnOffersComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlaceOwnOffersComposer.class); private final Habbo habbo; - public MarketPlaceOwnOffersComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketPlaceOwnOffersComposer); @@ -58,7 +55,7 @@ public class MarketPlaceOwnOffersComposer extends MessageComposer { this.response.appendInt(0); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyOfferResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyOfferResultComposer.java index a462e8f5..6d790fda 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyOfferResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyOfferResultComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.catalog.marketplace; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MarketplaceBuyOfferResultComposer extends MessageComposer { public static final int REFRESH = 1; public static final int SOLD_OUT = 2; @@ -15,13 +17,6 @@ public class MarketplaceBuyOfferResultComposer extends MessageComposer { private final int offerId; private final int price; - public MarketplaceBuyOfferResultComposer(int errorCode, int unknown, int offerId, int price) { - this.errorCode = errorCode; - this.unknown = unknown; - this.offerId = offerId; - this.price = price; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketplaceBuyOfferResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCanMakeOfferResult.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCanMakeOfferResult.java index 82e71f3b..85023136 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCanMakeOfferResult.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCanMakeOfferResult.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.catalog.marketplace; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MarketplaceCanMakeOfferResult extends MessageComposer { public static final int NOT_ALLOWED = 2; public static final int NO_TRADE_PASS = 3; @@ -13,12 +15,6 @@ public class MarketplaceCanMakeOfferResult extends MessageComposer { private final int valueA; private final int valueB; - public MarketplaceCanMakeOfferResult(int errorCode, int valueA, int valueB) { - this.errorCode = errorCode; - this.valueA = valueA; - this.valueB = valueB; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketplaceCanMakeOfferResult); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelOfferResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelOfferResultComposer.java index 683a22bb..d990ede9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelOfferResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelOfferResultComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MarketplaceCancelOfferResultComposer extends MessageComposer { private final MarketPlaceOffer offer; private final boolean success; - public MarketplaceCancelOfferResultComposer(MarketPlaceOffer offer, Boolean success) { - this.offer = offer; - this.success = success; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemStatsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemStatsComposer.java index 4725986a..a20d68f3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemStatsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemStatsComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MarketplaceItemStatsComposer extends MessageComposer { private final int itemId; - public MarketplaceItemStatsComposer(int itemId) { - this.itemId = itemId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketplaceItemStatsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceMakeOfferResult.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceMakeOfferResult.java index 3093d647..d33c351f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceMakeOfferResult.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceMakeOfferResult.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.catalog.marketplace; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MarketplaceMakeOfferResult extends MessageComposer { public static final int POST_SUCCESS = 1; public static final int FAILED_TECHNICAL_ERROR = 2; @@ -12,10 +14,6 @@ public class MarketplaceMakeOfferResult extends MessageComposer { private final int code; - public MarketplaceMakeOfferResult(int code) { - this.code = code; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketplaceMakeOfferResult); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOffersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOffersComposer.java index c4ed75d4..96a0bf07 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOffersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOffersComposer.java @@ -5,16 +5,14 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class MarketplaceOffersComposer extends MessageComposer { private final List offers; - public MarketplaceOffersComposer(List offers) { - this.offers = offers; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.marketplaceOffersComposer); @@ -37,7 +35,7 @@ public class MarketplaceOffersComposer extends MessageComposer { } this.response.appendInt(MarketPlace.calculateCommision(offer.getPrice())); this.response.appendInt(0); - this.response.appendInt(MarketPlace.calculateCommision(offer.avarage)); + this.response.appendInt(MarketPlace.calculateCommision(offer.average)); this.response.appendInt(offer.count); total += offer.count; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftableProductsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftableProductsComposer.java index d5fb8538..3a3ab7a7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftableProductsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftableProductsComposer.java @@ -5,19 +5,16 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Collection; import java.util.List; +@AllArgsConstructor public class CraftableProductsComposer extends MessageComposer { private final List recipes; private final Collection ingredients; - public CraftableProductsComposer(List recipes, Collection ingredients) { - this.recipes = recipes; - this.ingredients = ingredients; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.craftableProductsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipeComposer.java index f3c9791e..7a4884b4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipeComposer.java @@ -5,16 +5,14 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class CraftingRecipeComposer extends MessageComposer { private final CraftingRecipe recipe; - public CraftingRecipeComposer(CraftingRecipe recipe) { - this.recipe = recipe; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.craftingRecipeComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipesAvailableComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipesAvailableComposer.java index b85f523e..33fd33d3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipesAvailableComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingRecipesAvailableComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.crafting; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CraftingRecipesAvailableComposer extends MessageComposer { private final int count; private final boolean found; - public CraftingRecipesAvailableComposer(int count, boolean found) { - this.count = count; - this.found = found; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.craftingRecipesAvailableComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingResultComposer.java index 979543fa..f75e1524 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/crafting/CraftingResultComposer.java @@ -4,26 +4,24 @@ import com.eu.habbo.habbohotel.crafting.CraftingRecipe; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CraftingResultComposer extends MessageComposer { private final CraftingRecipe recipe; - private final boolean succes; + private final boolean success; public CraftingResultComposer(CraftingRecipe recipe) { this.recipe = recipe; - this.succes = this.recipe != null; + this.success = this.recipe != null; } - public CraftingResultComposer(CraftingRecipe recipe, boolean success) { - this.recipe = recipe; - this.succes = success; - } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.craftingResultComposer); - this.response.appendBoolean(this.succes); //succes + this.response.appendBoolean(this.success); //succes if (this.recipe != null) { this.response.appendString(this.recipe.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDataMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDataMessageComposer.java index 71977e24..50a201e0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDataMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDataMessageComposer.java @@ -5,9 +5,11 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; +import lombok.AllArgsConstructor; import java.util.ArrayList; +@AllArgsConstructor public class CampaignCalendarDataMessageComposer extends MessageComposer { private final String eventName; private final String campaignImage; @@ -16,15 +18,6 @@ public class CampaignCalendarDataMessageComposer extends MessageComposer { private final ArrayList unlocked; private final boolean lockExpired; - public CampaignCalendarDataMessageComposer(String eventName, String campaignImage, int totalDays, int currentDay, ArrayList unlocked, boolean lockExpired) { - this.eventName = eventName; - this.campaignImage = campaignImage; - this.totalDays = totalDays; - this.currentDay = currentDay; - this.unlocked = unlocked; - this.lockExpired = lockExpired; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.campaignCalendarDataMessageComposer); @@ -35,13 +28,14 @@ public class CampaignCalendarDataMessageComposer extends MessageComposer { this.response.appendInt(this.unlocked.size()); TIntArrayList expired = new TIntArrayList(); - if (this.lockExpired) { for (int i = 0; i < this.totalDays; i++) { - expired.add(i); - } + if (this.lockExpired) { + for (int i = 0; i < this.totalDays; i++) { + expired.add(i); + } } expired.remove(this.currentDay); - if(this.currentDay > 1) expired.remove(this.currentDay - 2); - if(this.currentDay > 0) expired.remove(this.currentDay - 1); + if (this.currentDay > 1) expired.remove(this.currentDay - 2); + if (this.currentDay > 0) expired.remove(this.currentDay - 1); this.unlocked.forEach(claimed -> { CampaignCalendarDataMessageComposer.this.response.appendInt(claimed.getDay()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDoorOpenedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDoorOpenedMessageComposer.java index b7ef0ce5..1b805ac8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDoorOpenedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/CampaignCalendarDoorOpenedMessageComposer.java @@ -6,17 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class CampaignCalendarDoorOpenedMessageComposer extends MessageComposer { - public final boolean visible; - public final CalendarRewardObject rewardObject; - public final Habbo habbo; - - public CampaignCalendarDoorOpenedMessageComposer(boolean visible, CalendarRewardObject rewardObject, Habbo habbo) { - this.visible = visible; - this.rewardObject = rewardObject; - this.habbo = habbo; - } + private final boolean visible; + private final CalendarRewardObject rewardObject; + private final Habbo habbo; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/GotMysteryBoxPrizeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/GotMysteryBoxPrizeMessageComposer.java index 5924e28a..d25f0e03 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/GotMysteryBoxPrizeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/GotMysteryBoxPrizeMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.events.mysticbox; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GotMysteryBoxPrizeMessageComposer extends MessageComposer { private final String type; private final int itemId; - public GotMysteryBoxPrizeMessageComposer(String type, int itemId) { - this.type = type; - this.itemId = itemId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.gotMysteryBoxPrizeMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionCompletedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionCompletedMessageComposer.java index 6845eb61..0b119444 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionCompletedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionCompletedMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.events.resolution; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AchievementResolutionCompletedMessageComposer extends MessageComposer { public final String badge; - public AchievementResolutionCompletedMessageComposer(String badge) { - this.badge = badge; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.achievementResolutionCompletedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionProgressMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionProgressMessageComposer.java index 641c27b3..f6408d47 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionProgressMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/AchievementResolutionProgressMessageComposer.java @@ -3,33 +3,26 @@ package com.eu.habbo.messages.outgoing.events.resolution; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AchievementResolutionProgressMessageComposer extends MessageComposer { - private final int stuffId; - private final int achievementId; - private final String achievementName; - private final int currentProgress; - private final int progressNeeded; - private final int timeLeft; + private final int stuffId; + private final int achievementId; + private final String achievementName; + private final int currentProgress; + private final int progressNeeded; + private final int timeLeft; - public AchievementResolutionProgressMessageComposer(int stuffId, int achievementId, String achievementName, int currentProgress, int progressNeeded, int timeLeft) { - this.stuffId = stuffId; - this.achievementId = achievementId; - this.achievementName = achievementName; - this.currentProgress = currentProgress; - this.progressNeeded = progressNeeded; - this.timeLeft = timeLeft; + @Override + protected ServerMessage composeInternal() { + this.response.init(Outgoing.achievementResolutionProgressMessageComposer); + this.response.appendInt(this.stuffId); + this.response.appendInt(this.achievementId); + this.response.appendString(this.achievementName); + this.response.appendInt(this.currentProgress); + this.response.appendInt(this.progressNeeded); + this.response.appendInt(this.timeLeft); + return this.response; + } } - - @Override - protected ServerMessage composeInternal() { - this.response.init(Outgoing.achievementResolutionProgressMessageComposer); - this.response.appendInt(this.stuffId); - this.response.appendInt(this.achievementId); - this.response.appendString(this.achievementName); - this.response.appendInt(this.currentProgress); - this.response.appendInt(this.progressNeeded); - this.response.appendInt(this.timeLeft); - return this.response; - } -} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomEntryTileMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomEntryTileMessageComposer.java index cac31a1a..d87a6b0d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomEntryTileMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomEntryTileMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomEntryTileMessageComposer extends MessageComposer { private final Room room; - public RoomEntryTileMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomEntryTileMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomOccupiedTilesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomOccupiedTilesMessageComposer.java index d6c54eb6..cd2ca66f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomOccupiedTilesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/RoomOccupiedTilesMessageComposer.java @@ -6,14 +6,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomOccupiedTilesMessageComposer extends MessageComposer { private final Room room; - public RoomOccupiedTilesMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomOccupiedTilesMessageComposer); @@ -22,8 +20,8 @@ public class RoomOccupiedTilesMessageComposer extends MessageComposer { this.response.appendInt(tileList.size()); for (RoomTile node : tileList) { - this.response.appendInt((int) node.x); - this.response.appendInt((int) node.y); + this.response.appendInt((int) node.getX()); + this.response.appendInt((int) node.getY()); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FindFriendsProcessResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FindFriendsProcessResultComposer.java index 26f0dc70..8b03c58f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FindFriendsProcessResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FindFriendsProcessResultComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.friends; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FindFriendsProcessResultComposer extends MessageComposer { public static final int NO_ROOM_FOUND = 0; public static final int ROOM_FOUND = 1; private final int errorCode; - public FindFriendsProcessResultComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.findFriendsProcessResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FollowFriendFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FollowFriendFailedComposer.java index 02dc863a..d9cd0fc5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FollowFriendFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FollowFriendFailedComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.friends; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FollowFriendFailedComposer extends MessageComposer { public static final int NOT_IN_FRIEND_LIST = 0; public static final int FRIEND_OFFLINE = 1; @@ -12,10 +14,6 @@ public class FollowFriendFailedComposer extends MessageComposer { private final int errorCode; - public FollowFriendFailedComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.followFriendFailedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendListFragmentMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendListFragmentMessageComposer.java index 48f1a02f..545f4259 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendListFragmentMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendListFragmentMessageComposer.java @@ -6,14 +6,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.Collection; +@Slf4j public class FriendListFragmentMessageComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(FriendListFragmentMessageComposer.class); + private final int totalPages; private final int pageIndex; @@ -52,14 +52,14 @@ public class FriendListFragmentMessageComposer extends MessageComposer { } return this.response; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; } public static ArrayList getMessagesForBuddyList(Collection buddies) { - ArrayList messages = new ArrayList(); - THashSet friends = new THashSet(); + ArrayList messages = new ArrayList<>(); + THashSet friends = new THashSet<>(); int totalPages = (int)Math.ceil(buddies.size() / 750.0); int page = 0; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendNotificationComposer.java index 311d02cf..60258450 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendNotificationComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.friends; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FriendNotificationComposer extends MessageComposer { public final static int INSTANT_MESSAGE = -1; public final static int ROOM_EVENT = 0; @@ -17,12 +19,6 @@ public class FriendNotificationComposer extends MessageComposer { private final int type; private final String data; - public FriendNotificationComposer(int userId, int type, String data) { - this.userId = userId; - this.type = type; - this.data = data; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.friendNotificationComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestComposer.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestsComposer.java index 758a34fb..8700a405 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestsComposer.java @@ -5,14 +5,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FriendRequestsComposer extends MessageComposer { private final Habbo habbo; - public FriendRequestsComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.friendRequestsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/HabboSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/HabboSearchResultComposer.java index 2ae8c395..476f5c6e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/HabboSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/HabboSearchResultComposer.java @@ -6,23 +6,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +@AllArgsConstructor public class HabboSearchResultComposer extends MessageComposer { private final THashSet users; private final THashSet friends; private final Habbo habbo; - private static Comparator COMPARATOR = Comparator.comparing((MessengerBuddy b) -> b.getUsername().length()).thenComparing((MessengerBuddy b, MessengerBuddy b2) -> b.getUsername().compareToIgnoreCase(b2.getUsername())); + private static final Comparator COMPARATOR = Comparator.comparing((MessengerBuddy b) -> b.getUsername().length()).thenComparing((MessengerBuddy b, MessengerBuddy b2) -> b.getUsername().compareToIgnoreCase(b2.getUsername())); - public HabboSearchResultComposer(THashSet users, THashSet friends, Habbo habbo) { - this.users = users; - this.friends = friends; - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerErrorComposer.java index 403bb00f..76d75baa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerErrorComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.friends; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MessengerErrorComposer extends MessageComposer { public static final int FRIEND_LIST_OWN_FULL = 1; public static final int FRIEND_LIST_TARGET_FULL = 2; @@ -12,9 +14,6 @@ public class MessengerErrorComposer extends MessageComposer { private final int errorCode; - public MessengerErrorComposer(int errorCode) { - this.errorCode = errorCode; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java index 92a85f8f..e64c758f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java @@ -1,22 +1,19 @@ package com.eu.habbo.messages.outgoing.friends; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class MessengerInitComposer extends MessageComposer { private final Habbo habbo; - public MessengerInitComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/NewConsoleMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/NewConsoleMessageComposer.java index f7ea9aaa..2f8e1bde 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/NewConsoleMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/NewConsoleMessageComposer.java @@ -6,7 +6,9 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NewConsoleMessageComposer extends MessageComposer { private final Message message; private final int toId; @@ -18,11 +20,6 @@ public class NewConsoleMessageComposer extends MessageComposer { this.fromId = message.getFromId(); } - public NewConsoleMessageComposer(Message message, int toId, int fromId) { - this.message = message; - this.toId = toId; - this.fromId = fromId; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/RemoveFriendComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/RemoveFriendComposer.java index 43d6d5be..ceec73f5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/RemoveFriendComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/RemoveFriendComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RemoveFriendComposer extends MessageComposer { private final TIntArrayList unfriendIds; - public RemoveFriendComposer(TIntArrayList unfriendIds) { - this.unfriendIds = unfriendIds; - } - public RemoveFriendComposer(int i) { this.unfriendIds = new TIntArrayList(); this.unfriendIds.add(i); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteComposer.java index 5c42c4cf..aba8cb71 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.friends; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomInviteComposer extends MessageComposer { private final int userId; private final String message; - public RoomInviteComposer(int userId, String message) { - this.userId = userId; - this.message = message; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteErrorComposer.java index 2567243a..c4cbc095 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/RoomInviteErrorComposer.java @@ -4,29 +4,22 @@ import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomInviteErrorComposer extends MessageComposer { private final int errorCode; private final THashSet buddies; - public RoomInviteErrorComposer(int errorCode, THashSet buddies) { - this.errorCode = errorCode; - this.buddies = buddies; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomInviteErrorComposer); this.response.appendInt(this.errorCode); this.response.appendInt(this.buddies.size()); - this.buddies.forEach(new TObjectProcedure() { - @Override - public boolean execute(MessengerBuddy object) { - RoomInviteErrorComposer.this.response.appendInt(object.getId()); - return true; - } + this.buddies.forEach(object -> { + RoomInviteErrorComposer.this.response.appendInt(object.getId()); + return true; }); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java index d739b38b..64669172 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java @@ -1,9 +1,5 @@ package com.eu.habbo.messages.outgoing.friends; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.users.Habbo; @@ -12,11 +8,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UpdateFriendComposer extends MessageComposer { - private Collection buddies; +import java.util.Collection; +import java.util.Collections; +import java.util.List; - private Habbo habbo; - private int action; +public class UpdateFriendComposer extends MessageComposer { + private final Collection buddies; + + private final Habbo habbo; + private final int action; public UpdateFriendComposer(Habbo habbo, MessengerBuddy buddy, Integer action) { this.habbo = habbo; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/Game2AccountGameStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/Game2AccountGameStatusMessageComposer.java index ff02140a..62ac7083 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/Game2AccountGameStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/Game2AccountGameStatusMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.gamecenter; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class Game2AccountGameStatusMessageComposer extends MessageComposer { private final int gameId; private final int gamesLeft; - public Game2AccountGameStatusMessageComposer(int gameId, int gamesLeft) { - this.gameId = gameId; - this.gamesLeft = gamesLeft; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.game2AccountGameStatusMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameComposer.java index c31b5b31..3f91b33c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameComposer.java @@ -3,18 +3,18 @@ package com.eu.habbo.messages.outgoing.gamecenter; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class GameCenterGameComposer extends MessageComposer { public final static int OK = 0; public final static int ERROR = 1; - public final int gameId; - public final int status; + private final int gameId; + private final int status; - public GameCenterGameComposer(int gameId, int status) { - this.gameId = gameId; - this.status = status; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/JoinedQueueMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/JoinedQueueMessageComposer.java index 75ca70ee..27c9d750 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/JoinedQueueMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/JoinedQueueMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.gamecenter.basejump; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class JoinedQueueMessageComposer extends MessageComposer { private final int gameId; - public JoinedQueueMessageComposer(int gameId) { - this.gameId = gameId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.joinedQueueMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/LoadGameMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/LoadGameMessageComposer.java index 7b98b99a..bb4e13e4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/LoadGameMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/LoadGameMessageComposer.java @@ -5,19 +5,16 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class LoadGameMessageComposer extends MessageComposer { public static String FASTFOOD_KEY = ""; private final GameClient client; private final int game; - public LoadGameMessageComposer(GameClient client, int game) { - this.client = client; - this.game = game; - } - - @Override + @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.loadGameMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/ClubGiftNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/ClubGiftNotificationComposer.java index 32ddf924..8ab980da 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/ClubGiftNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/ClubGiftNotificationComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.generic; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ClubGiftNotificationComposer extends MessageComposer { private final int count; - public ClubGiftNotificationComposer(int count) { - this.count = count; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.clubGiftNotificationComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BotErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BotErrorComposer.java index 9e442044..50717345 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BotErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BotErrorComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BotErrorComposer extends MessageComposer { public static final int ROOM_ERROR_BOTS_FORBIDDEN_IN_HOTEL = 0; public static final int ROOM_ERROR_BOTS_FORBIDDEN_IN_FLAT = 1; @@ -13,10 +15,6 @@ public class BotErrorComposer extends MessageComposer { private final int errorCode; - public BotErrorComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java index 36ed0441..682544c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java @@ -1,5 +1,10 @@ package com.eu.habbo.messages.outgoing.generic.alerts; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum BubbleAlertKeys { ADMIN_PERSISTENT("admin.persistent"), ADMIN_TRANSIENT("admin.transient"), @@ -35,9 +40,6 @@ public enum BubbleAlertKeys { FIGURESET_REDEEMED("figureset.redeemed.success"), FIGURESET_OWNED_ALREADY("figureset.already.redeemed"); - public final String key; + private final String key; - BubbleAlertKeys(String key) { - this.key = key; - } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomUserNotificationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomUserNotificationMessageComposer.java index ee52885e..11b624a4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomUserNotificationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomUserNotificationMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CustomUserNotificationMessageComposer extends MessageComposer { public static final int HOPPER_NO_COSTUME = 1; public static final int HOPPER_NO_HC = 2; @@ -13,9 +15,6 @@ public class CustomUserNotificationMessageComposer extends MessageComposer { private final int type; - public CustomUserNotificationMessageComposer(int type) { - this.type = type; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorComposer.java index bada8f68..15c57a6d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GenericErrorComposer extends MessageComposer { public static final int AUTHENTICATION_FAILED = -3; public static final int CONNECTING_TO_THE_SERVER_FAILED = -400; @@ -15,10 +17,6 @@ public class GenericErrorComposer extends MessageComposer { private final int errorCode; - public GenericErrorComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.genericErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HabboBroadcastMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HabboBroadcastMessageComposer.java index 65ace982..40274e11 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HabboBroadcastMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HabboBroadcastMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboBroadcastMessageComposer extends MessageComposer { private final String message; - public HabboBroadcastMessageComposer(String message) { - this.message = message; - } - public HabboBroadcastMessageComposer(String message, Habbo habbo) { this.message = message.replace("%username%", habbo.getHabboInfo().getUsername()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosedAndOpensComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosedAndOpensComposer.java index b30f7f48..030c0e77 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosedAndOpensComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosedAndOpensComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelClosedAndOpensComposer extends MessageComposer { private final int hour; private final int minute; - public HotelClosedAndOpensComposer(int hour, int minute) { - this.hour = hour; - this.minute = minute; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosesAndWillOpenAtComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosesAndWillOpenAtComposer.java index 8e316823..f49b4c94 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosesAndWillOpenAtComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelClosesAndWillOpenAtComposer.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelClosesAndWillOpenAtComposer extends MessageComposer { private final int hour; private final int minute; private final boolean disconnected; - public HotelClosesAndWillOpenAtComposer(int hour, int minute, boolean disconnected) { - this.hour = hour; - this.minute = minute; - this.disconnected = disconnected; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesComposer.java index c5e2d655..f7ec3f27 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelWillCloseInMinutesComposer extends MessageComposer { private final int minutes; - public HotelWillCloseInMinutesComposer(int minutes) { - this.minutes = minutes; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.hotelWillCloseInMinutesComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MaintenanceStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MaintenanceStatusMessageComposer.java index d5ca8844..3283b95e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MaintenanceStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MaintenanceStatusMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MaintenanceStatusMessageComposer extends MessageComposer { private final int closeInMinutes; private final int reopenInMinutes; - public MaintenanceStatusMessageComposer(int closeInMinutes, int reopenInMinutes) { - this.closeInMinutes = closeInMinutes; - this.reopenInMinutes = reopenInMinutes; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.maintenanceStatusMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorCautionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorCautionComposer.java index f065655b..f8a158f5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorCautionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorCautionComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ModeratorCautionComposer extends MessageComposer { private final String message; private final String link; - public ModeratorCautionComposer(String message, String link) { - this.message = message; - this.link = link; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorCautionComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorMessageComposer.java index fa74b62c..df204832 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/ModeratorMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ModeratorMessageComposer extends MessageComposer { private final String message; private final String link; - public ModeratorMessageComposer(String message, String link) { - this.message = message; - this.link = link; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/NotificationDialogMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/NotificationDialogMessageComposer.java index 898fd42e..b4b5f736 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/NotificationDialogMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/NotificationDialogMessageComposer.java @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class NotificationDialogMessageComposer extends MessageComposer { private final String errorKey; private final THashMap keys; - public NotificationDialogMessageComposer(String errorKey, THashMap keys) { - this.errorKey = errorKey; - this.keys = keys; - } - public NotificationDialogMessageComposer(String errorKey, String message) { this.errorKey = errorKey; this.keys = new THashMap<>(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetPlacingErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetPlacingErrorComposer.java index 0548bf90..79562352 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetPlacingErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetPlacingErrorComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetPlacingErrorComposer extends MessageComposer { public static final int ROOM_ERROR_PETS_FORBIDDEN_IN_HOTEL = 0; public static final int ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT = 1; @@ -14,10 +16,6 @@ public class PetPlacingErrorComposer extends MessageComposer { private final int errorCode; - public PetPlacingErrorComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petPlacingErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UserBannedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UserBannedMessageComposer.java index 8bee31e8..2a215688 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UserBannedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UserBannedMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserBannedMessageComposer extends MessageComposer { private final String message; - public UserBannedMessageComposer(String message) { - this.message = message; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userBannedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/WiredValidationErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/WiredValidationErrorComposer.java index b352581b..fb7b2915 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/WiredValidationErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/WiredValidationErrorComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.generic.alerts; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredValidationErrorComposer extends MessageComposer { private final String message; - public WiredValidationErrorComposer(String message) { - this.message = message; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredValidationErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionResultsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionResultsMessageComposer.java index 988f9b05..9f53c82b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionResultsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionResultsMessageComposer.java @@ -6,18 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class ChatReviewSessionResultsMessageComposer extends MessageComposer { private final GuardianTicket ticket; private final GuardianVote vote; - public ChatReviewSessionResultsMessageComposer(GuardianTicket ticket, GuardianVote vote) { - this.ticket = ticket; - this.vote = vote; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.chatReviewSessionResultsMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionStartedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionStartedMessageComposer.java index 0816f2e4..90d86edf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionStartedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionStartedMessageComposer.java @@ -6,16 +6,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.TIntIntHashMap; +import lombok.AllArgsConstructor; import java.util.Calendar; +@AllArgsConstructor public class ChatReviewSessionStartedMessageComposer extends MessageComposer { private final GuardianTicket ticket; - public ChatReviewSessionStartedMessageComposer(GuardianTicket ticket) { - this.ticket = ticket; - } - @Override protected ServerMessage composeInternal() { TIntIntHashMap mappedUsers = new TIntIntHashMap(); @@ -33,11 +31,11 @@ public class ChatReviewSessionStartedMessageComposer extends MessageComposer { fullMessage.append("\r"); for (ModToolChatLog chatLog : this.ticket.getChatLogs()) { - if (!mappedUsers.containsKey(chatLog.habboId)) { - mappedUsers.put(chatLog.habboId, mappedUsers.size()); + if (!mappedUsers.containsKey(chatLog.getHabboId())) { + mappedUsers.put(chatLog.getHabboId(), mappedUsers.size()); } - fullMessage.append("unused;").append(mappedUsers.get(chatLog.habboId)).append(";").append(chatLog.message).append("\r"); + fullMessage.append("unused;").append(mappedUsers.get(chatLog.getHabboId())).append(";").append(chatLog.getMessage()).append("\r"); } this.response.init(Outgoing.chatReviewSessionStartedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionVotingStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionVotingStatusMessageComposer.java index 8dcba487..f7c2ac96 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionVotingStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/ChatReviewSessionVotingStatusMessageComposer.java @@ -6,18 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; +@AllArgsConstructor public class ChatReviewSessionVotingStatusMessageComposer extends MessageComposer { private final GuardianTicket ticket; private final Habbo guardian; - public ChatReviewSessionVotingStatusMessageComposer(GuardianTicket ticket, Habbo guardian) { - this.ticket = ticket; - this.guardian = guardian; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.chatReviewSessionVotingStatusMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideOnDutyStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideOnDutyStatusMessageComposer.java index fbf844e9..ae1dd270 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideOnDutyStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideOnDutyStatusMessageComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideOnDutyStatusMessageComposer extends MessageComposer { private final boolean onDuty; - - public GuideOnDutyStatusMessageComposer(boolean onDuty) { - this.onDuty = onDuty; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideOnDutyStatusMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedMessageComposer.java index 79fc88a2..1ea9da1b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedMessageComposer.java @@ -5,16 +5,12 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionAttachedMessageComposer extends MessageComposer { private final GuideTour tour; private final boolean isHelper; - - public GuideSessionAttachedMessageComposer(GuideTour tour, boolean isHelper) { - this.tour = tour; - this.isHelper = isHelper; - } - @Override protected ServerMessage composeInternal() { //:test 3549 b:1 i:1 s:abcd i:100 diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedMessageComposer.java index 65c948c0..2d107608 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedMessageComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.guides; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionEndedMessageComposer extends MessageComposer { public static final int SOMETHING_WRONG = 0; public static final int HELP_CASE_CLOSED = 1; private final int errorCode; - public GuideSessionEndedMessageComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionEndedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorMessageComposer.java index ae59e8fd..96f5b273 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.guides; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionErrorMessageComposer extends MessageComposer { public static final int SOMETHING_WRONG_REQUEST = 0; public static final int NO_HELPERS_AVAILABLE = 1; @@ -11,10 +13,6 @@ public class GuideSessionErrorMessageComposer extends MessageComposer { private final int errorCode; - public GuideSessionErrorMessageComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionErrorMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java index fcb83565..0db1cc67 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionInvitedToGuideRoomMessageComposer extends MessageComposer { private final Room room; - public GuideSessionInvitedToGuideRoomMessageComposer(Room room) { - this.room = room; - } //Helper invites noob @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageMessageComposer.java index aa9c40f7..8ca0fa8d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageMessageComposer.java @@ -4,19 +4,16 @@ import com.eu.habbo.habbohotel.guides.GuideChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionMessageMessageComposer extends MessageComposer { private final GuideChatMessage message; - - public GuideSessionMessageMessageComposer(GuideChatMessage message) { - this.message = message; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionMessageMessageComposer); - this.response.appendString(this.message.message); //Message - this.response.appendInt(this.message.userId); //Sender ID + this.response.appendString(this.message.getMessage()); //Message + this.response.appendInt(this.message.getUserId()); //Sender ID return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsTypingComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsTypingComposer.java index 46cc53bf..e67e04c5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsTypingComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsTypingComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.guides; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionPartnerIsTypingComposer extends MessageComposer { private final boolean typing; - - public GuideSessionPartnerIsTypingComposer(boolean typing) { - this.typing = typing; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionPartnerIsTypingComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java index e80fdd9c..bcce411b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionRequesterRoomMessageComposer extends MessageComposer { private final Room room; - - public GuideSessionRequesterRoomMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionRequesterRoomMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionStartedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionStartedComposer.java index 6fefed90..9649866a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionStartedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionStartedComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideSessionStartedComposer extends MessageComposer { private final GuideTour tour; - - public GuideSessionStartedComposer(GuideTour tour) { - this.tour = tour; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionStartedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideTicketResolutionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideTicketResolutionMessageComposer.java index 71f1d0a8..98e787ba 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideTicketResolutionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideTicketResolutionMessageComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.guides; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideTicketResolutionMessageComposer extends MessageComposer { public final static int CLOSED = 1; public final static int MISUSE = 2; public final int code; - public GuideTicketResolutionMessageComposer(int code) { - this.code = code; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideTicketResolutionMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/YouArePlayingGameMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/YouArePlayingGameMessageComposer.java index 7635197e..b7cab702 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/YouArePlayingGameMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/YouArePlayingGameMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.guides; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class YouArePlayingGameMessageComposer extends MessageComposer { public final boolean isPlaying; - public YouArePlayingGameMessageComposer(boolean isPlaying) { - this.isPlaying = isPlaying; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.youArePlayingGameMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java index b12f125b..28b34815 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java @@ -5,22 +5,20 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FavoriteMembershipUpdateMessageComposer extends MessageComposer { - private RoomUnit roomUnit; - private Guild guild; + private final RoomUnit roomUnit; + private final Guild guild; - public FavoriteMembershipUpdateMessageComposer(RoomUnit roomUnit, Guild guild) { - this.roomUnit = roomUnit; - this.guild = guild; - } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.favoriteMembershipUpdateMessageComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.guild != null ? this.guild.getId() : 0); - this.response.appendInt(this.guild != null ? this.guild.getState().state : 3); + this.response.appendInt(this.guild != null ? this.guild.getState().getState() : 3); this.response.appendString(this.guild != null ? this.guild.getName() : ""); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreatedMessageComposer.java index 2bbfd7de..36187a74 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreatedMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildCreatedMessageComposer extends MessageComposer { private final Guild guild; - public GuildCreatedMessageComposer(Guild guild) { - this.guild = guild; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildCreatedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java index bae6c227..670715c3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java @@ -6,14 +6,11 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildCreationInfoMessageComposer extends MessageComposer { private final THashSet rooms; - - public GuildCreationInfoMessageComposer(THashSet rooms) { - this.rooms = rooms; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildCreationInfoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailedMessageComposer.java index 67822552..cf8d8085 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailedMessageComposer.java @@ -3,18 +3,16 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildEditFailedMessageComposer extends MessageComposer { public static final int ROOM_ALREADY_IN_USE = 0; public static final int INVALID_GUILD_NAME = 1; public static final int HC_REQUIRED = 2; public static final int MAX_GUILDS_JOINED = 3; - private int errorCode; - - public GuildEditFailedMessageComposer(int errorCode) { - this.errorCode = errorCode; - } + private final int errorCode; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditInfoMessageComposer.java index 137669bf..a22e1f0d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditInfoMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildEditInfoMessageComposer extends MessageComposer { private final Guild guild; - public GuildEditInfoMessageComposer(Guild guild) { - this.guild = guild; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildEditInfoMessageComposer); @@ -26,8 +24,8 @@ public class GuildEditInfoMessageComposer extends MessageComposer { this.response.appendInt(this.guild.getRoomId()); this.response.appendInt(this.guild.getColorOne()); this.response.appendInt(this.guild.getColorTwo()); - this.response.appendInt(this.guild.getState().state); - this.response.appendInt(this.guild.getRights() ? 0 : 1); + this.response.appendInt(this.guild.getState().getState()); + this.response.appendInt(this.guild.isRights() ? 0 : 1); this.response.appendBoolean(false); this.response.appendString(""); this.response.appendInt(5); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditorDataMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditorDataMessageComposer.java index acf86d00..af3f8fc6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditorDataMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditorDataMessageComposer.java @@ -12,34 +12,34 @@ public class GuildEditorDataMessageComposer extends MessageComposer { this.response.init(Outgoing.guildEditorDataMessageComposer); this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getBases().size()); for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBases()) { - this.response.appendInt(part.id); - this.response.appendString(part.valueA); - this.response.appendString(part.valueB); + this.response.appendInt(part.getId()); + this.response.appendString(part.getValueA()); + this.response.appendString(part.getValueB()); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getSymbols().size()); for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getSymbols()) { - this.response.appendInt(part.id); - this.response.appendString(part.valueA); - this.response.appendString(part.valueB); + this.response.appendInt(part.getId()); + this.response.appendString(part.getValueA()); + this.response.appendString(part.getValueB()); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getBaseColors().size()); for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBaseColors()) { - this.response.appendInt(part.id); - this.response.appendString(part.valueA); + this.response.appendInt(part.getId()); + this.response.appendString(part.getValueA()); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getSymbolColors().size()); for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getSymbolColors()) { - this.response.appendInt(part.id); - this.response.appendString(part.valueA); + this.response.appendInt(part.getId()); + this.response.appendString(part.getValueA()); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getBackgroundColors().size()); for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBackgroundColors()) { - this.response.appendInt(part.id); - this.response.appendString(part.valueA); + this.response.appendInt(part.getId()); + this.response.appendString(part.getValueA()); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java index a9a3fb93..3fc033e8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java @@ -7,17 +7,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildFurniContextMenuInfoMessageComposer extends MessageComposer { - private final HabboItem item; - private final Guild guild; private final Habbo habbo; - - public GuildFurniContextMenuInfoMessageComposer(Habbo habbo, Guild guild, HabboItem item) { - this.habbo = habbo; - this.item = item; - this.guild = guild; - } + private final Guild guild; + private final HabboItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberFurniCountInHQMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberFurniCountInHQMessageComposer.java index 4cfa64cc..c224b56b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberFurniCountInHQMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberFurniCountInHQMessageComposer.java @@ -3,15 +3,12 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildMemberFurniCountInHQMessageComposer extends MessageComposer { - private int userId; - private int furniCount; - - public GuildMemberFurniCountInHQMessageComposer(int userId, int furniCount) { - this.userId = userId; - this.furniCount = furniCount; - } + private final int userId; + private final int furniCount; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberMgmtFailedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberMgmtFailedMessageComposer.java index 988cf2b5..61bcd6b8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberMgmtFailedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberMgmtFailedMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildMemberMgmtFailedMessageComposer extends MessageComposer { public final static int NO_LONGER_MEMBER = 0; public final static int ALREADY_REJECTED = 1; @@ -12,11 +14,6 @@ public class GuildMemberMgmtFailedMessageComposer extends MessageComposer { private final int guildId; private final int errorCode; - public GuildMemberMgmtFailedMessageComposer(int guildId, int errorCode) { - this.guildId = guildId; - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildMemberMgmtFailedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java index 99b1bf5c..8f5ee679 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java @@ -6,14 +6,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Calendar; import java.util.TimeZone; +@AllArgsConstructor public class GuildMembersComposer extends MessageComposer { - private final ArrayList members; private final Guild guild; + private final ArrayList members; private final Habbo session; private final int pageId; private final int level; @@ -21,16 +23,6 @@ public class GuildMembersComposer extends MessageComposer { private final boolean isAdmin; private final int totalCount; - public GuildMembersComposer(Guild guild, ArrayList members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin, int totalCount) { - this.guild = guild; - this.members = members; - this.session = session; - this.pageId = pageId; - this.level = level; - this.searchValue = searchValue; - this.isAdmin = isAdmin; - this.totalCount = totalCount; - } @Override protected ServerMessage composeInternal() { @@ -45,11 +37,11 @@ public class GuildMembersComposer extends MessageComposer { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); for (GuildMember member : this.members) { cal.setTimeInMillis(member.getJoinDate() * 1000L); - this.response.appendInt(member.getRank().type); + this.response.appendInt(member.getRank().getType()); this.response.appendInt(member.getUserId()); this.response.appendString(member.getUsername()); this.response.appendString(member.getLook()); - this.response.appendString(member.getRank().type < 3 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : ""); + this.response.appendString(member.getRank().getType() < 3 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : ""); } this.response.appendBoolean(this.isAdmin); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipRejectedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipRejectedMessageComposer.java index 3f57559a..f885f767 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipRejectedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipRejectedMessageComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildMembershipRejectedMessageComposer extends MessageComposer { private final Guild guild; private final Integer userId; - public GuildMembershipRejectedMessageComposer(Guild guild, int userId) { - this.guild = guild; - this.userId = userId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildMembershipRejectedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipUpdatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipUpdatedMessageComposer.java index 513e5fa6..43cab046 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipUpdatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipUpdatedMessageComposer.java @@ -5,25 +5,22 @@ import com.eu.habbo.habbohotel.guilds.GuildMember; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildMembershipUpdatedMessageComposer extends MessageComposer { private final Guild guild; private final GuildMember guildMember; - public GuildMembershipUpdatedMessageComposer(Guild guild, GuildMember guildMember) { - this.guildMember = guildMember; - this.guild = guild; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildMembershipUpdatedMessageComposer); this.response.appendInt(this.guild.getId()); - this.response.appendInt(this.guildMember.getRank().type); + this.response.appendInt(this.guildMember.getRank().getType()); this.response.appendInt(this.guildMember.getUserId()); this.response.appendString(this.guildMember.getUsername()); this.response.appendString(this.guildMember.getLook()); - this.response.appendString(this.guildMember.getRank().type != 0 ? this.guildMember.getJoinDate() + "" : ""); + this.response.appendString(this.guildMember.getRank().getType() != 0 ? this.guildMember.getJoinDate() + "" : ""); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipsMessageComposer.java index 4ce44347..29787e0b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembershipsMessageComposer.java @@ -7,16 +7,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuildMembershipsMessageComposer extends MessageComposer { private final THashSet guilds; private final Habbo habbo; - - public GuildMembershipsMessageComposer(THashSet guilds, Habbo habbo) { - this.guilds = guilds; - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guildMembershipsMessageComposer); @@ -25,9 +21,9 @@ public class GuildMembershipsMessageComposer extends MessageComposer { this.response.appendInt(guild.getId()); this.response.appendString(guild.getName()); this.response.appendString(guild.getBadge()); - this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).valueA); - this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).valueA); - this.response.appendBoolean(this.habbo.getHabboStats().guild == guild.getId()); + this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).getValueA()); + this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).getValueA()); + this.response.appendBoolean(this.habbo.getHabboStats().getGuild() == guild.getId()); this.response.appendInt(guild.getOwnerId()); this.response.appendBoolean(guild.hasForum()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDeactivatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDeactivatedMessageComposer.java index b33ccaa3..c5ae75cf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDeactivatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDeactivatedMessageComposer.java @@ -3,13 +3,11 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboGroupDeactivatedMessageComposer extends MessageComposer { - private int guildId; - - public HabboGroupDeactivatedMessageComposer(int guildId) { - this.guildId = guildId; - } + private final int guildId; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java index 3e0d1714..8313e588 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java @@ -10,30 +10,24 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.text.SimpleDateFormat; import java.util.Date; +@AllArgsConstructor public class HabboGroupDetailsMessageComposer extends MessageComposer { private final Guild guild; private final GameClient client; private final boolean newWindow; private final GuildMember member; - - public HabboGroupDetailsMessageComposer(Guild guild, GameClient client, boolean newWindow, GuildMember member) { - this.guild = guild; - this.client = client; - this.newWindow = newWindow; - this.member = member; - } - @Override protected ServerMessage composeInternal() { boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN) || Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(this.client.getHabbo().getHabboInfo().getId()) != null; this.response.init(Outgoing.habboGroupDetailsMessageComposer); this.response.appendInt(this.guild.getId()); this.response.appendBoolean(true); - this.response.appendInt(this.guild.getState().state); + this.response.appendInt(this.guild.getState().getState()); this.response.appendString(this.guild.getName()); this.response.appendString(this.guild.getDescription()); this.response.appendString(this.guild.getBadge()); @@ -41,14 +35,14 @@ public class HabboGroupDetailsMessageComposer extends MessageComposer { this.response.appendString(this.guild.getRoomName()); this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); this.response.appendInt(this.guild.getMemberCount()); - this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group + this.response.appendBoolean(this.client.getHabbo().getHabboStats().getGuild() == this.guild.getId()); // favorite group this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); this.response.appendString(this.guild.getOwnerName()); this.response.appendBoolean(this.newWindow); - this.response.appendBoolean(this.guild.getRights()); + this.response.appendBoolean(this.guild.isRights()); this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. this.response.appendBoolean(this.guild.hasForum()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupJoinFailedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupJoinFailedMessageComposer.java index e7d4f4b4..f32ac88f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupJoinFailedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupJoinFailedMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboGroupJoinFailedMessageComposer extends MessageComposer { public static final int GROUP_FULL = 0; public static final int GROUP_LIMIT_EXCEED = 1; @@ -15,10 +17,6 @@ public class HabboGroupJoinFailedMessageComposer extends MessageComposer { private final int code; - public HabboGroupJoinFailedMessageComposer(int code) { - this.code = code; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.habboGroupJoinFailedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java index bc714cac..b97ebdde 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java @@ -13,8 +13,9 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -22,16 +23,14 @@ import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@Getter +@AllArgsConstructor public class ForumDataMessageComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(ForumDataMessageComposer.class); - public final Guild guild; - public Habbo habbo; - public ForumDataMessageComposer(Guild guild, Habbo habbo) { - this.guild = guild; - this.habbo = habbo; - } + private final Guild guild; + private Habbo habbo; public static void serializeForumData(ServerMessage response, Guild guild, Habbo habbo) { @@ -78,7 +77,7 @@ public class ForumDataMessageComposer extends MessageComposer { newComments = set.getInt(1); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } response.appendInt(guild.getId()); @@ -107,7 +106,7 @@ public class ForumDataMessageComposer extends MessageComposer { serializeForumData(this.response, guild, habbo); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); - boolean isAdmin = member != null && (member.getRank().type < GuildRank.MEMBER.type || guild.getOwnerId() == this.habbo.getHabboInfo().getId()); + boolean isAdmin = member != null && (member.getRank().getType() < GuildRank.MEMBER.getType() || guild.getOwnerId() == this.habbo.getHabboInfo().getId()); boolean isStaff = this.habbo.hasPermission(Permission.ACC_MODTOOL_TICKET_Q); String errorRead = ""; @@ -115,52 +114,52 @@ public class ForumDataMessageComposer extends MessageComposer { String errorStartThread = ""; String errorModerate = ""; - if (guild.canReadForum().state == 1 && member == null && !isStaff) { + if (guild.canReadForum().getState() == 1 && member == null && !isStaff) { errorRead = "not_member"; - } else if (guild.canReadForum().state == 2 && !isAdmin && !isStaff) { + } else if (guild.canReadForum().getState() == 2 && !isAdmin && !isStaff) { errorRead = "not_admin"; } - if (guild.canPostMessages().state == 1 && member == null && !isStaff) { + if (guild.canPostMessages().getState() == 1 && member == null && !isStaff) { errorPost = "not_member"; - } else if (guild.canPostMessages().state == 2 && !isAdmin && !isStaff) { + } else if (guild.canPostMessages().getState() == 2 && !isAdmin && !isStaff) { errorPost = "not_admin"; - } else if (guild.canPostMessages().state == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { + } else if (guild.canPostMessages().getState() == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { errorPost = "not_owner"; } - if (guild.canPostThreads().state == 1 && member == null && !isStaff) { + if (guild.canPostThreads().getState() == 1 && member == null && !isStaff) { errorStartThread = "not_member"; - } else if (guild.canPostThreads().state == 2 && !isAdmin && !isStaff) { + } else if (guild.canPostThreads().getState() == 2 && !isAdmin && !isStaff) { errorStartThread = "not_admin"; - } else if (guild.canPostThreads().state == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { + } else if (guild.canPostThreads().getState() == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { errorStartThread = "not_owner"; } - if (guild.canModForum().state == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { + if (guild.canModForum().getState() == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { errorModerate = "not_owner"; } else if (!isAdmin && !isStaff) { errorModerate = "not_admin"; } - this.response.appendInt(guild.canReadForum().state); - this.response.appendInt(guild.canPostMessages().state); - this.response.appendInt(guild.canPostThreads().state); - this.response.appendInt(guild.canModForum().state); + this.response.appendInt(guild.canReadForum().getState()); + this.response.appendInt(guild.canPostMessages().getState()); + this.response.appendInt(guild.canPostThreads().getState()); + this.response.appendInt(guild.canModForum().getState()); this.response.appendString(errorRead); this.response.appendString(errorPost); this.response.appendString(errorStartThread); this.response.appendString(errorModerate); this.response.appendString(""); //citizen this.response.appendBoolean(guild.getOwnerId() == this.habbo.getHabboInfo().getId()); //Forum Settings - if (guild.canModForum().state == 3) { + if (guild.canModForum().getState() == 3) { this.response.appendBoolean(guild.getOwnerId() == this.habbo.getHabboInfo().getId() || isStaff); } else { this.response.appendBoolean(guild.getOwnerId() == this.habbo.getHabboInfo().getId() || isStaff || isAdmin); //Can Mod (staff) } } catch (Exception e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); return new ErrorReportComposer(500).compose(); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumsListMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumsListMessageComposer.java index b6203ced..2b285b49 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumsListMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumsListMessageComposer.java @@ -5,22 +5,18 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Iterator; import java.util.Set; +@AllArgsConstructor public class ForumsListMessageComposer extends MessageComposer { private final Set guilds; private final Habbo habbo; private final int mode; private final int index; - public ForumsListMessageComposer(Set guilds, Habbo habbo, int mode, int index) { - this.guilds = guilds; - this.habbo = habbo; - this.mode = mode; - this.index = index; - } @Override protected ServerMessage composeInternal() { @@ -31,7 +27,7 @@ public class ForumsListMessageComposer extends MessageComposer { this.response.appendInt(this.index); Iterator it = guilds.iterator(); - int count = guilds.size() > 20 ? 20 : guilds.size(); + int count = Math.min(guilds.size(), 20); this.response.appendInt(count); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadsComposer.java index d2fe3bba..7b685b19 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadsComposer.java @@ -6,20 +6,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; +@Getter +@AllArgsConstructor public class GuildForumThreadsComposer extends MessageComposer { - public final Guild guild; - public final int index; + private final Guild guild; + private final int index; - public GuildForumThreadsComposer(Guild guild, int index) { - this.guild = guild; - this.index = index; - } @Override protected ServerMessage composeInternal() { @@ -35,7 +35,7 @@ public class GuildForumThreadsComposer extends MessageComposer { Collections.reverse(threads); Iterator it = threads.iterator(); - int count = threads.size() > 20 ? 20 : threads.size(); + int count = Math.min(threads.size(), 20); this.response.init(Outgoing.guildForumThreadsComposer); this.response.appendInt(this.guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostMessageMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostMessageMessageComposer.java index 5dd6003e..828918d4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostMessageMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostMessageMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThreadComment; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PostMessageMessageComposer extends MessageComposer { private final ForumThreadComment comment; - public PostMessageMessageComposer(ForumThreadComment comment) { - this.comment = comment; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.postMessageMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostThreadMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostThreadMessageComposer.java index 374b7345..fd0282c6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostThreadMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostThreadMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PostThreadMessageComposer extends MessageComposer { public final ForumThread thread; - public PostThreadMessageComposer(ForumThread thread) { - this.thread = thread; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadMessagesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadMessagesMessageComposer.java index ef062643..3d92ad6f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadMessagesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadMessagesMessageComposer.java @@ -4,22 +4,17 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThreadComment; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Collection; +@AllArgsConstructor public class ThreadMessagesMessageComposer extends MessageComposer { private final int guildId; private final int threadId; private final int index; private final Collection guildForumCommentList; - public ThreadMessagesMessageComposer(int guildId, int threadId, int index, Collection guildForumCommentList) { - this.guildId = guildId; - this.threadId = threadId; - this.index = index; - this.guildForumCommentList = guildForumCommentList; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.threadMessagesMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UnreadForumsCountMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UnreadForumsCountMessageComposer.java index 8aa765f3..e9196fdc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UnreadForumsCountMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UnreadForumsCountMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.guilds.forums; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UnreadForumsCountMessageComposer extends MessageComposer { public final int count; - public UnreadForumsCountMessageComposer(int count) { - this.count = count; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.unreadForumsCountMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateMessageMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateMessageMessageComposer.java index 5266b208..6c3664c8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateMessageMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateMessageMessageComposer.java @@ -4,17 +4,15 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThreadComment; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class UpdateMessageMessageComposer extends MessageComposer { - public final int guildId; - public final int threadId; - public final ForumThreadComment comment; - - public UpdateMessageMessageComposer(int guildId, int threadId, ForumThreadComment comment) { - this.guildId = guildId; - this.threadId = threadId; - this.comment = comment; - } + private final int guildId; + private final int threadId; + private final ForumThreadComment comment; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateThreadMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateThreadMessageComposer.java index 14a5648b..4d75c502 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateThreadMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/UpdateThreadMessageComposer.java @@ -6,12 +6,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class UpdateThreadMessageComposer extends MessageComposer { - public final Guild guild; + private final Guild guild; - public final ForumThread thread; + private final ForumThread thread; private final Habbo habbo; @@ -19,14 +23,6 @@ public class UpdateThreadMessageComposer extends MessageComposer { private final boolean isLocked; - public UpdateThreadMessageComposer(Guild guild, ForumThread thread, Habbo habbo, boolean isPinned, boolean isLocked) { - this.guild = guild; - this.habbo = habbo; - this.thread = thread; - this.isPinned = isPinned; - this.isLocked = isLocked; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.updateThreadMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer1.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer1.java index 3d69e9c7..0fc58cdc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer1.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer1.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.habboway; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboWayQuizComposer1 extends MessageComposer { public final String name; public final int[] items; - public HabboWayQuizComposer1(String name, int[] items) { - this.name = name; - this.items = items; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.habboWayQuizComposer1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/QuizDataMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/QuizDataMessageComposer.java index 5bda0d99..d8cd3bf5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/QuizDataMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/QuizDataMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.habboway; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuizDataMessageComposer extends MessageComposer { public final String name; public final int[] items; - public QuizDataMessageComposer(String name, int[] items) { - this.name = name; - this.items = items; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.quizDataMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/InClientLinkMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/InClientLinkMessageComposer.java index 41b6ca51..fbf9d990 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/InClientLinkMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/InClientLinkMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.habboway.nux; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class InClientLinkMessageComposer extends MessageComposer { private final String link; - public InClientLinkMessageComposer(String link) { - this.link = link; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.inClientLinkMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserExperienceGiftOfferComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserExperienceGiftOfferComposer.java index 5aeb9f6f..7c12cadf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserExperienceGiftOfferComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserExperienceGiftOfferComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.items.NewUserGift; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class NewUserExperienceGiftOfferComposer extends MessageComposer { private final List> options; - public NewUserExperienceGiftOfferComposer(List> options) { - this.options = options; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.newUserExperienceGiftOfferComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NoobnessLevelMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NoobnessLevelMessageComposer.java index 93ac42bc..7011376f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NoobnessLevelMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NoobnessLevelMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NoobnessLevelMessageComposer extends MessageComposer { private final Habbo habbo; - public NoobnessLevelMessageComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.noobnessLevelMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/AvailabilityStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/AvailabilityStatusMessageComposer.java index a1c0862e..ac861afc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/AvailabilityStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/AvailabilityStatusMessageComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AvailabilityStatusMessageComposer extends MessageComposer { private final boolean isOpen; private final boolean isShuttingDown; private final boolean isAuthenticHabbo; - public AvailabilityStatusMessageComposer(boolean isOpen, boolean isShuttingDown, boolean isAuthenticHabbo) { - this.isOpen = isOpen; - this.isShuttingDown = isShuttingDown; - this.isAuthenticHabbo = isAuthenticHabbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.availabilityStatusMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/CompleteDiffieHandshakeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/CompleteDiffieHandshakeComposer.java index 9c9ef8b5..69a466a2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/CompleteDiffieHandshakeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/CompleteDiffieHandshakeComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CompleteDiffieHandshakeComposer extends MessageComposer { private final String publicKey; @@ -13,10 +15,6 @@ public class CompleteDiffieHandshakeComposer extends MessageComposer { this(publicKey, true); } - public CompleteDiffieHandshakeComposer(String publicKey, boolean clientEncryption) { - this.publicKey = publicKey; - this.clientEncryption = clientEncryption; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/EnableNotificationsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/EnableNotificationsComposer.java index 4febea68..b1152407 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/EnableNotificationsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/EnableNotificationsComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class EnableNotificationsComposer extends MessageComposer { private final boolean enabled; - public EnableNotificationsComposer(boolean enabled) { - this.enabled = enabled; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.infoFeedEnableMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/ErrorReportComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/ErrorReportComposer.java index 761f97a2..1bff820c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/ErrorReportComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/ErrorReportComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ErrorReportComposer extends MessageComposer { private final int messageId; private final int errorCode; @@ -15,12 +17,6 @@ public class ErrorReportComposer extends MessageComposer { this.timestamp = ""; } - public ErrorReportComposer(int messageId, int errorCode, String timestamp) { - this.messageId = messageId; - this.errorCode = errorCode; - this.timestamp = timestamp; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.errorReportComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/InitDiffieHandshakeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/InitDiffieHandshakeComposer.java index 22c54ae1..dc70e7d2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/InitDiffieHandshakeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/InitDiffieHandshakeComposer.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class InitDiffieHandshakeComposer extends MessageComposer { private final String signedPrime; private final String signedGenerator; - public InitDiffieHandshakeComposer(String signedPrime, String signedGenerator) { - this.signedPrime = signedPrime; - this.signedGenerator = signedGenerator; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.initDiffieHandshakeComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/LatencyPingResponseMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/LatencyPingResponseMessageComposer.java index e1244b0d..d6b4d904 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/LatencyPingResponseMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/LatencyPingResponseMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class LatencyPingResponseMessageComposer extends MessageComposer { private final int id; - public LatencyPingResponseMessageComposer(int id) { - this.id = id; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.latencyPingResponseMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/UniqueMachineIDComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/UniqueMachineIDComposer.java index 3090b467..8d19b0dd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/UniqueMachineIDComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/UniqueMachineIDComposer.java @@ -3,15 +3,12 @@ package com.eu.habbo.messages.outgoing.handshake; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UniqueMachineIDComposer extends MessageComposer { private final String machineId; - - public UniqueMachineIDComposer(String machineId) { - this.machineId = machineId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.uniqueMachineIDComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareInfoMessageComposer.java index 82a9b97e..d865e077 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareInfoMessageComposer.java @@ -5,14 +5,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BonusRareInfoMessageComposer extends MessageComposer { private final Habbo habbo; - public BonusRareInfoMessageComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.bonusRareInfoMessageComposer); @@ -21,7 +19,7 @@ public class BonusRareInfoMessageComposer extends MessageComposer { this.response.appendInt(Emulator.getConfig().getInt("hotelview.promotional.points", 120)); //Total Required //this.response.appendInt(this.habbo.getHabboInfo().getBonusRarePoints() >= Emulator.getConfig().getInt("hotelview.promotinal.points", 120) ? Emulator.getConfig().getInt("hotelview.promotinal.points", 120) : this.habbo.getHabboInfo().getBonusRarePoints() ); //Total To Gain int points = Emulator.getConfig().getInt("hotelview.promotional.points", 120) - this.habbo.getHabboInfo().getBonusRarePoints(); - this.response.appendInt(points < 0 ? 0 : points); + this.response.appendInt(Math.max(points, 0)); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CatalogPageWithEarliestExpiryMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CatalogPageWithEarliestExpiryMessageComposer.java index 9e9c89de..b65ca64a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CatalogPageWithEarliestExpiryMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CatalogPageWithEarliestExpiryMessageComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.catalog.CatalogPage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CatalogPageWithEarliestExpiryMessageComposer extends MessageComposer { private final CatalogPage page; private final String image; - public CatalogPageWithEarliestExpiryMessageComposer(CatalogPage page, String image) { - this.page = page; - this.image = image; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.catalogPageWithEarliestExpiryMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalHallOfFameMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalHallOfFameMessageComposer.java index 2b4e09d1..4cd24879 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalHallOfFameMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalHallOfFameMessageComposer.java @@ -5,18 +5,16 @@ import com.eu.habbo.habbohotel.hotelview.HallOfFameWinner; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Collections; import java.util.List; +@AllArgsConstructor public class CommunityGoalHallOfFameMessageComposer extends MessageComposer { private final HallOfFame hallOfFame; - public CommunityGoalHallOfFameMessageComposer(HallOfFame hallOfFame) { - this.hallOfFame = hallOfFame; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.communityGoalHallOfFameMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalProgressMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalProgressMessageComposer.java index 564079bc..a213716a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalProgressMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalProgressMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CommunityGoalProgressMessageComposer extends MessageComposer { private final boolean achieved; private final int personalContributionScore; @@ -16,27 +18,6 @@ public class CommunityGoalProgressMessageComposer extends MessageComposer { private final int timeLeft; private final int[] rankData; - public CommunityGoalProgressMessageComposer(boolean achieved, - int personalContributionScore, - int personalRank, - int totalAmount, - int communityHighestAchievedLevel, - int scoreRemainingUntilNextLevel, - int percentCompletionTowardsNextLevel, - String competitionName, - int timeLeft, - int[] rankData) { - this.achieved = achieved; - this.personalContributionScore = personalContributionScore; - this.personalRank = personalRank; - this.totalAmount = totalAmount; - this.communityHighestAchievedLevel = communityHighestAchievedLevel; - this.scoreRemainingUntilNextLevel = scoreRemainingUntilNextLevel; - this.percentCompletionTowardsNextLevel = percentCompletionTowardsNextLevel; - this.competitionName = competitionName; - this.timeLeft = timeLeft; - this.rankData = rankData; - } //:test 1579 b:1 i:0 i:1 i:2 i:3 i:4 i:5 s:a i:6 i:1 i:1 @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalVoteMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalVoteMessageComposer.java index f87aaa7c..57779112 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalVoteMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CommunityGoalVoteMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CommunityGoalVoteMessageComposer extends MessageComposer { private final boolean unknownBoolean; - public CommunityGoalVoteMessageComposer(boolean unknownBoolean) { - this.unknownBoolean = unknownBoolean; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.communityGoalVoteMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/ConcurrentUsersGoalProgressMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/ConcurrentUsersGoalProgressMessageComposer.java index ec0a47f1..21b46712 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/ConcurrentUsersGoalProgressMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/ConcurrentUsersGoalProgressMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ConcurrentUsersGoalProgressMessageComposer extends MessageComposer { public static final int ACTIVE = 0; public static final int HIDDEN = 2; @@ -13,12 +15,6 @@ public class ConcurrentUsersGoalProgressMessageComposer extends MessageComposer private final int userCount; private final int goal; - public ConcurrentUsersGoalProgressMessageComposer(int state, int userCount, int goal) { - this.state = state; - this.userCount = userCount; - this.goal = goal; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.concurrentUsersGoalProgressMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CurrentTimingCodeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CurrentTimingCodeMessageComposer.java index 6bc07ea4..ad6a81b7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CurrentTimingCodeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/CurrentTimingCodeMessageComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CurrentTimingCodeMessageComposer extends MessageComposer { private final String data; private final String key; - public CurrentTimingCodeMessageComposer(String data, String key) { - this.data = data; - this.key = key; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewBadgeButtonConfigComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewBadgeButtonConfigComposer.java index 321db15a..efe9f708 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewBadgeButtonConfigComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewBadgeButtonConfigComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelViewBadgeButtonConfigComposer extends MessageComposer { private final String badge; private final boolean enabled; - public HotelViewBadgeButtonConfigComposer(String badge, boolean enabled) { - this.badge = badge; - this.enabled = enabled; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCatalogPageExpiringComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCatalogPageExpiringComposer.java index 6a371e3a..c51e1548 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCatalogPageExpiringComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCatalogPageExpiringComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelViewCatalogPageExpiringComposer extends MessageComposer { private final String name; private final int time; private final String image; - public HotelViewCatalogPageExpiringComposer(String name, int time, String image) { - this.name = name; - this.time = time; - this.image = image; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.hotelViewCatalogPageExpiringComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCustomTimerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCustomTimerComposer.java index 0b0c4285..dcb05a08 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCustomTimerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCustomTimerComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HotelViewCustomTimerComposer extends MessageComposer { private final String name; private final int seconds; - public HotelViewCustomTimerComposer(String name, int seconds) { - this.name = name; - this.seconds = seconds; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.hotelViewCustomTimerComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/LimitedOfferAppearingNextMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/LimitedOfferAppearingNextMessageComposer.java index 9a6ae106..fa42336e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/LimitedOfferAppearingNextMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/LimitedOfferAppearingNextMessageComposer.java @@ -3,20 +3,14 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class LimitedOfferAppearingNextMessageComposer extends MessageComposer { private final int time; private final int pageId; private final int itemId; private final String itemName; - - public LimitedOfferAppearingNextMessageComposer(int time, int pageId, int itemId, String itemName) { - this.time = time; - this.pageId = pageId; - this.itemId = itemId; - this.itemName = itemName; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.limitedOfferAppearingNextMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/SecondsUntilMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/SecondsUntilMessageComposer.java index ff39528e..c5a63063 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/SecondsUntilMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/SecondsUntilMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.hotelview; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SecondsUntilMessageComposer extends MessageComposer { private final String dateString; private final int seconds; - public SecondsUntilMessageComposer(String dateString, int seconds) { - this.dateString = dateString; - this.seconds = seconds; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.secondsUntilMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectActivatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectActivatedMessageComposer.java index be5e1017..dba7f063 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectActivatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectActivatedMessageComposer.java @@ -4,13 +4,14 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class AvatarEffectActivatedMessageComposer extends MessageComposer { - public final EffectsComponent.HabboEffect effect; + private final EffectsComponent.HabboEffect effect; - public AvatarEffectActivatedMessageComposer(EffectsComponent.HabboEffect effect) { - this.effect = effect; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectAddedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectAddedMessageComposer.java index b52c9d0d..9fcf8464 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectAddedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectAddedMessageComposer.java @@ -4,14 +4,13 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class AvatarEffectAddedMessageComposer extends MessageComposer { - public final EffectsComponent.HabboEffect effect; - - public AvatarEffectAddedMessageComposer(EffectsComponent.HabboEffect effect) { - this.effect = effect; - } - + private final EffectsComponent.HabboEffect effect; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.avatarEffectAddedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectExpiredMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectExpiredMessageComposer.java index 42808baa..cc296980 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectExpiredMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectExpiredMessageComposer.java @@ -4,13 +4,13 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; +@Getter +@AllArgsConstructor public class AvatarEffectExpiredMessageComposer extends MessageComposer { - public final EffectsComponent.HabboEffect effect; - - public AvatarEffectExpiredMessageComposer(EffectsComponent.HabboEffect effect) { - this.effect = effect; - } + private final EffectsComponent.HabboEffect effect; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectsMessageComposer.java index 4aa85f2c..3f0df95b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AvatarEffectsMessageComposer.java @@ -6,28 +6,27 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.Collection; +@Getter +@AllArgsConstructor public class AvatarEffectsMessageComposer extends MessageComposer { - public final Habbo habbo; - public final Collection effects; - - public AvatarEffectsMessageComposer(Habbo habbo, Collection effects) { - this.habbo = habbo; - this.effects = effects; - } + private final Habbo habbo; + private final Collection effects; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.avatarEffectsMessageComposer); - if (this.habbo == null || this.habbo.getInventory() == null || this.habbo.getInventory().getEffectsComponent() == null || this.habbo.getInventory().getEffectsComponent().effects == null) { + if (this.habbo == null || this.habbo.getInventory() == null || this.habbo.getInventory().getEffectsComponent() == null || this.habbo.getInventory().getEffectsComponent().getEffects() == null) { this.response.appendInt(0); } else { - synchronized (this.habbo.getInventory().getEffectsComponent().effects) { + synchronized (this.habbo.getInventory().getEffectsComponent().getEffects()) { this.response.appendInt(this.effects.size()); for (EffectsComponent.HabboEffect effect : effects) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgePointLimitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgePointLimitsComposer.java index f3939ac6..c0eb3c85 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgePointLimitsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgePointLimitsComposer.java @@ -7,7 +7,6 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TObjectProcedure; public class BadgePointLimitsComposer extends MessageComposer { @Override @@ -18,19 +17,16 @@ public class BadgePointLimitsComposer extends MessageComposer { THashMap achievements = Emulator.getGameEnvironment().getAchievementManager().getAchievements(); this.response.appendInt(achievements.size()); - achievements.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(Achievement achievement) { - BadgePointLimitsComposer.this.response.appendString((achievement.name.startsWith("ACH_") ? achievement.name.replace("ACH_", "") : achievement.name)); - BadgePointLimitsComposer.this.response.appendInt(achievement.levels.size()); + achievements.forEachValue(achievement -> { + BadgePointLimitsComposer.this.response.appendString((achievement.name.startsWith("ACH_") ? achievement.name.replace("ACH_", "") : achievement.name)); + BadgePointLimitsComposer.this.response.appendInt(achievement.levels.size()); - for (AchievementLevel level : achievement.levels.values()) { - BadgePointLimitsComposer.this.response.appendInt(level.level); - BadgePointLimitsComposer.this.response.appendInt(level.progress); - } - - return true; + for (AchievementLevel level : achievement.levels.values()) { + BadgePointLimitsComposer.this.response.appendInt(level.getLevel()); + BadgePointLimitsComposer.this.response.appendInt(level.getProgress()); } + + return true; }); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgesComposer.java index 80e5dd2e..ca7ee721 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BadgesComposer.java @@ -6,14 +6,11 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BadgesComposer extends MessageComposer { private final Habbo habbo; - - public BadgesComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { if (this.habbo == null) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotAddedToInventoryComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotAddedToInventoryComposer.java index 5d4b3601..ecb73661 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotAddedToInventoryComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotAddedToInventoryComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BotAddedToInventoryComposer extends MessageComposer { private final Bot bot; - public BotAddedToInventoryComposer(Bot bot) { - this.bot = bot; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botAddedToInventoryComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotInventoryComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotInventoryComposer.java index 6e001228..28142e8b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotInventoryComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotInventoryComposer.java @@ -6,14 +6,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BotInventoryComposer extends MessageComposer { private final Habbo habbo; - public BotInventoryComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botInventoryComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotRemovedFromInventoryComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotRemovedFromInventoryComposer.java index 90bfba4c..bc4097a0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotRemovedFromInventoryComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/BotRemovedFromInventoryComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BotRemovedFromInventoryComposer extends MessageComposer { private final Bot bot; - public BotRemovedFromInventoryComposer(Bot bot) { - this.bot = bot; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botRemovedFromInventoryComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java index 342ac66d..34809b06 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java @@ -5,14 +5,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FurniListAddOrUpdateComposer extends MessageComposer { private final HabboItem habboItem; - public FurniListAddOrUpdateComposer(HabboItem item) { - this.habboItem = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.furniListAddOrUpdateComposer); @@ -22,18 +20,10 @@ public class FurniListAddOrUpdateComposer extends MessageComposer { this.response.appendInt(this.habboItem.getBaseItem().getSpriteId()); switch (this.habboItem.getBaseItem().getName()) { - case "landscape": - this.response.appendInt(4); - break; - case "floor": - this.response.appendInt(3); - break; - case "wallpaper": - this.response.appendInt(2); - break; - case "poster": - this.response.appendInt(6); - break; + case "landscape" -> this.response.appendInt(4); + case "floor" -> this.response.appendInt(3); + case "wallpaper" -> this.response.appendInt(2); + case "poster" -> this.response.appendInt(6); } if (this.habboItem.isLimited()) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java index 402b3c14..9def2fb0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java @@ -8,23 +8,20 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; import gnu.trove.procedure.TIntObjectProcedure; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + import java.util.Arrays; import java.util.List; +@Slf4j +@AllArgsConstructor public class FurniListComposer extends MessageComposer implements TIntObjectProcedure { - private static final Logger LOGGER = LoggerFactory.getLogger(FurniListComposer.class); private final int fragmentNumber; private final int totalFragments; private final TIntObjectMap items; - public FurniListComposer(int fragmentNumber, int totalFragments, TIntObjectMap items) { - this.fragmentNumber = fragmentNumber; - this.totalFragments = totalFragments; - this.items = items; - } @Override protected ServerMessage composeInternal() { @@ -37,7 +34,7 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc this.items.forEachEntry(this); return this.response; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; @@ -52,21 +49,11 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("song_disk") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { switch (habboItem.getBaseItem().getName()) { - case "landscape": - this.response.appendInt(4); - break; - case "floor": - this.response.appendInt(3); - break; - case "wallpaper": - this.response.appendInt(2); - break; - case "poster": - this.response.appendInt(6); - break; - case "song_disk": - this.response.appendInt(8); - break; + case "landscape" -> this.response.appendInt(4); + case "floor" -> this.response.appendInt(3); + case "wallpaper" -> this.response.appendInt(2); + case "poster" -> this.response.appendInt(6); + case "song_disk" -> this.response.appendInt(8); } this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListRemoveComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListRemoveComposer.java index 8f7bacb3..0760741f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListRemoveComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListRemoveComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.inventory; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FurniListRemoveComposer extends MessageComposer { private final int itemId; - - public FurniListRemoveComposer(final int itemId) { - this.itemId = itemId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.furniListRemoveComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetAddedToInventoryComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetAddedToInventoryComposer.java index a9184d31..97942edb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetAddedToInventoryComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetAddedToInventoryComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetAddedToInventoryComposer extends MessageComposer { private final Pet pet; - public PetAddedToInventoryComposer(Pet pet) { - this.pet = pet; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petAddedToInventoryComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetInventoryComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetInventoryComposer.java index 115df618..b6c3e8d6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetInventoryComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/PetInventoryComposer.java @@ -6,16 +6,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.iterator.TIntObjectIterator; +import lombok.AllArgsConstructor; import java.util.NoSuchElementException; +@AllArgsConstructor public class PetInventoryComposer extends MessageComposer { private final Habbo habbo; - public PetInventoryComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petInventoryComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpPendingCallsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpPendingCallsMessageComposer.java index a4d584bf..754571e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpPendingCallsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpPendingCallsMessageComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class CallForHelpPendingCallsMessageComposer extends MessageComposer { private final List pendingIssues; - public CallForHelpPendingCallsMessageComposer(List issues) { - this.pendingIssues = issues; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.callForHelpPendingCallsMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpReplyMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpReplyMessageComposer.java index 6b5df221..37283582 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpReplyMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpReplyMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CallForHelpReplyMessageComposer extends MessageComposer { private final String message; - public CallForHelpReplyMessageComposer(String message) { - this.message = message; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.callForHelpReplyMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpResultMessageComposer.java index 44172a73..55eea8e0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CallForHelpResultMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CallForHelpResultMessageComposer extends MessageComposer { public static final int REPORT_RECEIVED = 0; public static final int REPORT_WINDOW = 1; @@ -12,10 +14,6 @@ public class CallForHelpResultMessageComposer extends MessageComposer { private final int errorCode; private final String message; - public CallForHelpResultMessageComposer(int errorCode, String message) { - this.errorCode = errorCode; - this.message = message; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java index f28dff0d..ff356e02 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java @@ -6,11 +6,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.List; +@RequiredArgsConstructor +@AllArgsConstructor public class CfhChatlogComposer extends MessageComposer { private final SimpleDateFormat format = new SimpleDateFormat("HH:mm"); private final ModToolIssue issue; @@ -18,19 +22,6 @@ public class CfhChatlogComposer extends MessageComposer { private final String roomName; private ModToolIssueChatlogType type = ModToolIssueChatlogType.CHAT; - public CfhChatlogComposer(ModToolIssue issue, List chatlog, String roomName) { - this.issue = issue; - this.chatlog = chatlog; - this.roomName = roomName; - } - - public CfhChatlogComposer(ModToolIssue issue, List chatlog, String roomName, ModToolIssueChatlogType type) { - this.issue = issue; - this.chatlog = chatlog; - this.roomName = roomName; - this.type = type; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.cfhChatlogComposer); @@ -88,14 +79,15 @@ public class CfhChatlogComposer extends MessageComposer { this.response.appendShort(this.chatlog.size()); for (ModToolChatLog chatLog : this.chatlog) { - this.response.appendString(format.format(chatLog.timestamp * 1000L)); - this.response.appendInt(chatLog.habboId); - this.response.appendString(chatLog.username); - this.response.appendString(chatLog.message); - this.response.appendBoolean(chatLog.highlighted); + this.response.appendString(format.format(chatLog.getTimestamp() * 1000L)); + this.response.appendInt(chatLog.getHabboId()); + this.response.appendString(chatLog.getUsername()); + this.response.appendString(chatLog.getMessage()); + this.response.appendBoolean(chatLog.isHighlighted()); } //} return this.response; } } + diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsInitComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsInitComposer.java index b44ebbc0..a875b3c6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsInitComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsInitComposer.java @@ -1,12 +1,9 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.modtool.CfhCategory; -import com.eu.habbo.habbohotel.modtool.CfhTopic; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.procedure.TObjectProcedure; public class CfhTopicsInitComposer extends MessageComposer { @Override @@ -15,22 +12,16 @@ public class CfhTopicsInitComposer extends MessageComposer { this.response.appendInt(Emulator.getGameEnvironment().getModToolManager().getCfhCategories().valueCollection().size()); - Emulator.getGameEnvironment().getModToolManager().getCfhCategories().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CfhCategory category) { - CfhTopicsInitComposer.this.response.appendString(category.getName()); - CfhTopicsInitComposer.this.response.appendInt(category.getTopics().valueCollection().size()); - category.getTopics().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CfhTopic topic) { - CfhTopicsInitComposer.this.response.appendString(topic.name); - CfhTopicsInitComposer.this.response.appendInt(topic.id); - CfhTopicsInitComposer.this.response.appendString(topic.action.toString()); - return true; - } - }); + Emulator.getGameEnvironment().getModToolManager().getCfhCategories().forEachValue(category -> { + CfhTopicsInitComposer.this.response.appendString(category.getName()); + CfhTopicsInitComposer.this.response.appendInt(category.getTopics().valueCollection().size()); + category.getTopics().forEachValue(topic -> { + CfhTopicsInitComposer.this.response.appendString(topic.getName()); + CfhTopicsInitComposer.this.response.appendInt(topic.getId()); + CfhTopicsInitComposer.this.response.appendString(topic.getAction().toString()); return true; - } + }); + return true; }); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideReportingStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideReportingStatusMessageComposer.java index 911966fb..a80dd437 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideReportingStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideReportingStatusMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideReportingStatusMessageComposer extends MessageComposer { public static final int START_REPORT = 0; public static final int ONGOING_HELPER_CASE = 1; @@ -12,12 +14,6 @@ public class GuideReportingStatusMessageComposer extends MessageComposer { private final int errorCode; private final int errorCodeType; - - public GuideReportingStatusMessageComposer(int errorCode, int errorCodeType) { - this.errorCode = errorCode; - this.errorCodeType = errorCodeType; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideReportingStatusMessageComposer); @@ -31,11 +27,8 @@ public class GuideReportingStatusMessageComposer extends MessageComposer { this.response.appendString("admin"); this.response.appendString("ca-1807-64.lg-3365-78.hr-3370-42-31.hd-3093-1359.ch-3372-65"); switch (this.errorCodeType) { - case 3: - this.response.appendString("room Name"); - break; - case 1: - this.response.appendString("description"); + case 3 -> this.response.appendString("room Name"); + case 1 -> this.response.appendString("description"); } } //:test 1917 i:1 i:3 i:1 b:0 s:1 s:1 s:1 diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideTicketCreationResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideTicketCreationResultMessageComposer.java index 15f6e4cd..40b935ff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideTicketCreationResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/GuideTicketCreationResultMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuideTicketCreationResultMessageComposer extends MessageComposer { public static final int RECEIVED = 0; public static final int IGNORED = 1; @@ -13,10 +15,6 @@ public class GuideTicketCreationResultMessageComposer extends MessageComposer { private final int code; - public GuideTicketCreationResultMessageComposer(int code) { - this.code = code; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideTicketCreationResultMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssueInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssueInfoMessageComposer.java index 07f626ff..6c97a8d8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssueInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssueInfoMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class IssueInfoMessageComposer extends MessageComposer { private final ModToolIssue issue; - public IssueInfoMessageComposer(ModToolIssue issue) { - this.issue = issue; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.issueInfoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssuePickFailedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssuePickFailedMessageComposer.java index 959caed9..2384bb76 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssuePickFailedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/IssuePickFailedMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class IssuePickFailedMessageComposer extends MessageComposer { private final ModToolIssue issue; - public IssuePickFailedMessageComposer(ModToolIssue issue) { - this.issue = issue; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.issuePickFailedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java index 62fdafc1..e376cacf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java @@ -12,16 +12,14 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.Iterator; +@AllArgsConstructor public class ModeratorInitMessageComposer extends MessageComposer implements TObjectProcedure { private final Habbo habbo; - public ModeratorInitMessageComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorInitMessageComposer); @@ -86,12 +84,6 @@ public class ModeratorInitMessageComposer extends MessageComposer implements TOb public boolean execute(ModToolCategory category) { this.response.appendString(category.getName()); - -// - -// - - return true; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java index 4b2f2206..4e05d6f0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ModeratorRoomInfoComposer extends MessageComposer { private final Room room; - public ModeratorRoomInfoComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorRoomInfoComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorToolPreferencesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorToolPreferencesComposer.java index 90ab9fa2..8bc1af2f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorToolPreferencesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorToolPreferencesComposer.java @@ -3,20 +3,15 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ModeratorToolPreferencesComposer extends MessageComposer { private final int x; private final int y; private final int width; private final int height; - public ModeratorToolPreferencesComposer(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorToolPreferencesComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorUserInfoComposer.java index 4da65747..83669e2f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorUserInfoComposer.java @@ -8,21 +8,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; +@Slf4j +@AllArgsConstructor public class ModeratorUserInfoComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(ModeratorUserInfoComposer.class); private final ResultSet set; - public ModeratorUserInfoComposer(ResultSet set) { - this.set = set; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorUserInfoComposer); @@ -37,10 +37,10 @@ public class ModeratorUserInfoComposer extends MessageComposer { totalBans = set.getInt("amount"); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.response.appendInt(this.set.getInt("user_id")); @@ -70,7 +70,7 @@ public class ModeratorUserInfoComposer extends MessageComposer { if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) //has sanction { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.getSanctionLevel()); this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); this.response.appendInt(31); @@ -80,7 +80,7 @@ public class ModeratorUserInfoComposer extends MessageComposer { return this.response; } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java index cadf3fa2..e7118bda 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +@AllArgsConstructor public class RoomChatlogComposer extends MessageComposer { private final Room room; private final ArrayList chatlog; - public RoomChatlogComposer(Room room, ArrayList chatlog) { - this.room = room; - this.chatlog = chatlog; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomChatlogComposer); @@ -35,10 +32,10 @@ public class RoomChatlogComposer extends MessageComposer { this.response.appendShort(this.chatlog.size()); for (ModToolChatLog line : this.chatlog) { - this.response.appendString(formatDate.format(new Date((line.timestamp * 1000L)))); - this.response.appendInt(line.habboId); - this.response.appendString(line.username); - this.response.appendString(line.message); + this.response.appendString(formatDate.format(new Date((line.getTimestamp() * 1000L)))); + this.response.appendInt(line.getHabboId()); + this.response.appendString(line.getUsername()); + this.response.appendString(line.getMessage()); this.response.appendBoolean(false); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomVisitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomVisitsComposer.java index 589f839a..0af5b674 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomVisitsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomVisitsComposer.java @@ -6,19 +6,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.Calendar; import java.util.TimeZone; +@AllArgsConstructor public class RoomVisitsComposer extends MessageComposer { private final HabboInfo habboInfo; private final THashSet roomVisits; - public RoomVisitsComposer(HabboInfo habboInfo, THashSet roomVisits) { - this.habboInfo = habboInfo; - this.roomVisits = roomVisits; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomVisitsComposer); @@ -28,9 +25,9 @@ public class RoomVisitsComposer extends MessageComposer { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); for (ModToolRoomVisit visit : this.roomVisits) { - cal.setTimeInMillis(visit.timestamp * 1000L); - this.response.appendInt(visit.roomId); - this.response.appendString(visit.roomName); + cal.setTimeInMillis(visit.getTimestamp() * 1000L); + this.response.appendInt(visit.getRoomId()); + this.response.appendString(visit.getRoomName()); this.response.appendInt(cal.get(Calendar.HOUR)); this.response.appendInt(cal.get(Calendar.MINUTE)); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/SanctionStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/SanctionStatusComposer.java index 12afce6b..456d972b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/SanctionStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/SanctionStatusComposer.java @@ -9,19 +9,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; +import lombok.AllArgsConstructor; import org.joda.time.DateTime; import java.util.ArrayList; import java.util.Date; +@AllArgsConstructor public class SanctionStatusComposer extends MessageComposer { private final Habbo habbo; - public SanctionStatusComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); @@ -41,34 +39,34 @@ public class SanctionStatusComposer extends MessageComposer { prevItem = modToolSanctionItems.get(modToolSanctionItems.size() - 2); } - ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); - ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1); + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.getSanctionLevel()); + ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.getSanctionLevel() + 1); - if (item.probationTimestamp > 0) { - probationEndTime = new Date((long) item.probationTimestamp * 1000); + if (item.getProbationTimestamp() > 0) { + probationEndTime = new Date((long) item.getProbationTimestamp() * 1000); probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); Date tradeLockedUntil = null; - if (item.tradeLockedUntil > 0) { - tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); + if (item.getTradeLockedUntil() > 0) { + tradeLockedUntil = new Date((long) item.getTradeLockedUntil() * 1000); } this.response.init(Outgoing.sanctionStatusComposer); - this.response.appendBoolean(prevItem != null && prevItem.probationTimestamp > 0); // has prev sanction - this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation + this.response.appendBoolean(prevItem != null && prevItem.getProbationTimestamp() > 0); // has prev sanction + this.response.appendBoolean(item.getProbationTimestamp() >= Emulator.getIntUnixTimestamp()); // is on probation this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction this.response.appendInt(30); // TODO: unused? - this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason + this.response.appendString(item.getReason().equals("") ? "cfh.reason.EMPTY" : item.getReason()); // reason this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time this.response.appendInt(0); // TODO: unused? this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) this.response.appendInt(30); // TODO: unused? - this.response.appendBoolean(item.isMuted); // muted + this.response.appendBoolean(item.isMuted()); // muted this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until } else { return cleanResponse(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/UserChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/UserChatlogComposer.java index 803186a7..96de22aa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/UserChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/UserChatlogComposer.java @@ -5,22 +5,18 @@ import com.eu.habbo.habbohotel.modtool.ModToolRoomVisit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.text.SimpleDateFormat; import java.util.ArrayList; +@AllArgsConstructor public class UserChatlogComposer extends MessageComposer { private final SimpleDateFormat format = new SimpleDateFormat("HH:mm"); private final ArrayList set; private final int userId; private final String username; - public UserChatlogComposer(ArrayList set, int userId, String username) { - this.set = set; - this.userId = userId; - this.username = username; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userChatlogComposer); @@ -33,17 +29,17 @@ public class UserChatlogComposer extends MessageComposer { this.response.appendShort(2); this.response.appendString("roomName"); this.response.appendByte(2); - this.response.appendString(visit.roomName); + this.response.appendString(visit.getRoomName()); this.response.appendString("roomId"); this.response.appendByte(1); - this.response.appendInt(visit.roomId); + this.response.appendInt(visit.getRoomId()); - this.response.appendShort(visit.chat.size()); - for (ModToolChatLog chatLog : visit.chat) { - this.response.appendString(format.format(chatLog.timestamp * 1000L)); - this.response.appendInt(chatLog.habboId); - this.response.appendString(chatLog.username); - this.response.appendString(chatLog.message); + this.response.appendShort(visit.getChat().size()); + for (ModToolChatLog chatLog : visit.getChat()) { + this.response.appendString(format.format(chatLog.getTimestamp() * 1000L)); + this.response.appendInt(chatLog.getHabboId()); + this.response.appendString(chatLog.getUsername()); + this.response.appendString(chatLog.getMessage()); this.response.appendBoolean(false); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateRoomComposer.java index 256ac763..6b766808 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateRoomComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.navigator; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CanCreateRoomComposer extends MessageComposer { private final int count; private final int max; - public CanCreateRoomComposer(int count, int max) { - this.count = count; - this.max = max; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.canCreateRoomComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CategoriesWithVisitorCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CategoriesWithVisitorCountComposer.java index b66a7950..8ff8000f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CategoriesWithVisitorCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CategoriesWithVisitorCountComposer.java @@ -4,22 +4,22 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.List; +@Getter +@AllArgsConstructor public class CategoriesWithVisitorCountComposer extends MessageComposer { - public final List roomCategories; - - public CategoriesWithVisitorCountComposer(List roomCategories) { - this.roomCategories = roomCategories; - } + private final List roomCategories; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.categoriesWithVisitorCountComposer); this.response.appendInt(this.roomCategories.size()); - for (RoomCategory category : this.roomCategories) { + for (int i = 0; i < this.roomCategories.size(); i++) { this.response.appendInt(0); this.response.appendInt(0); this.response.appendInt(200); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java index b7fd1b0e..5b7ebaf1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FlatCreatedComposer extends MessageComposer { private final Room room; - public FlatCreatedComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatCreatedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/GuestRoomSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/GuestRoomSearchResultComposer.java index ae568272..7a0e3bd9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/GuestRoomSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/GuestRoomSearchResultComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.util.List; +@Slf4j +@AllArgsConstructor public class GuestRoomSearchResultComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(GuestRoomSearchResultComposer.class); private final List rooms; - public GuestRoomSearchResultComposer(List rooms) { - this.rooms = rooms; - } - @Override protected ServerMessage composeInternal() { try { @@ -45,7 +42,7 @@ public class GuestRoomSearchResultComposer extends MessageComposer { this.response.appendString("E"); return this.response; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSavedSearchesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSavedSearchesComposer.java index e6db71ad..ee0d099c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSavedSearchesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSavedSearchesComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class NavigatorSavedSearchesComposer extends MessageComposer { private final List searches; - public NavigatorSavedSearchesComposer(List searches) { - this.searches = searches; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.navigatorSavedSearchesComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSearchResultBlocksComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSearchResultBlocksComposer.java index e059ddca..8ead13c4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSearchResultBlocksComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NavigatorSearchResultBlocksComposer.java @@ -4,20 +4,16 @@ import com.eu.habbo.habbohotel.navigation.SearchResultList; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class NavigatorSearchResultBlocksComposer extends MessageComposer { private final String searchCode; private final String searchQuery; private final List resultList; - public NavigatorSearchResultBlocksComposer(String searchCode, String searchQuery, List resultList) { - this.searchCode = searchCode; - this.searchQuery = searchQuery; - this.resultList = resultList; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.navigatorSearchResultBlocksComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorPreferencesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorPreferencesComposer.java index feeb7801..9ae7ea88 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorPreferencesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorPreferencesComposer.java @@ -4,22 +4,20 @@ import com.eu.habbo.habbohotel.users.HabboNavigatorWindowSettings; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NewNavigatorPreferencesComposer extends MessageComposer { private final HabboNavigatorWindowSettings windowSettings; - public NewNavigatorPreferencesComposer(HabboNavigatorWindowSettings windowSettings) { - this.windowSettings = windowSettings; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.newNavigatorPreferencesComposer); - this.response.appendInt(this.windowSettings.x); - this.response.appendInt(this.windowSettings.y); - this.response.appendInt(this.windowSettings.width); - this.response.appendInt(this.windowSettings.height); - this.response.appendBoolean(this.windowSettings.openSearches); + this.response.appendInt(this.windowSettings.getX()); + this.response.appendInt(this.windowSettings.getY()); + this.response.appendInt(this.windowSettings.getWidth()); + this.response.appendInt(this.windowSettings.getHeight()); + this.response.appendBoolean(this.windowSettings.isOpenSearches()); this.response.appendInt(0); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PopularRoomTagsResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PopularRoomTagsResultComposer.java index c3405640..b6d83c69 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PopularRoomTagsResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PopularRoomTagsResultComposer.java @@ -3,16 +3,14 @@ package com.eu.habbo.messages.outgoing.navigator; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Set; +@AllArgsConstructor public class PopularRoomTagsResultComposer extends MessageComposer { private final Set tags; - public PopularRoomTagsResultComposer(Set tags) { - this.tags = tags; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.popularRoomTagsResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/UserFlatCatsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/UserFlatCatsComposer.java index bd1ec555..b751cfd0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/UserFlatCatsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/UserFlatCatsComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class UserFlatCatsComposer extends MessageComposer { private final List categories; - - public UserFlatCatsComposer(List categories) { - this.categories = categories; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userFlatCatsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollContentsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollContentsComposer.java index 37fcfb50..d72089e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollContentsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollContentsComposer.java @@ -5,21 +5,19 @@ import com.eu.habbo.habbohotel.polls.PollQuestion; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PollContentsComposer extends MessageComposer { private final Poll poll; - public PollContentsComposer(Poll poll) { - this.poll = poll; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.pollContentsComposer); - this.response.appendInt(this.poll.id); - this.response.appendString(this.poll.title); - this.response.appendString(this.poll.thanksMessage); + this.response.appendInt(this.poll.getId()); + this.response.appendString(this.poll.getTitle()); + this.response.appendString(this.poll.getThanksMessage()); this.response.appendInt(this.poll.getQuestions().size()); for (PollQuestion question : this.poll.getQuestions()) { question.serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollOfferComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollOfferComposer.java index 23bc4114..6fb79603 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollOfferComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollOfferComposer.java @@ -4,21 +4,19 @@ import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PollOfferComposer extends MessageComposer { private final Poll poll; - public PollOfferComposer(Poll poll) { - this.poll = poll; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.pollOfferComposer); - this.response.appendInt(this.poll.id); - this.response.appendString(this.poll.title); - this.response.appendString(this.poll.thanksMessage); - this.response.appendString(this.poll.title); + this.response.appendInt(this.poll.getId()); + this.response.appendString(this.poll.getTitle()); + this.response.appendString(this.poll.getThanksMessage()); + this.response.appendString(this.poll.getTitle()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionAnsweredComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionAnsweredComposer.java index ff5cd917..63993212 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionAnsweredComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionAnsweredComposer.java @@ -3,20 +3,15 @@ package com.eu.habbo.messages.outgoing.polls.infobus; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestionAnsweredComposer extends MessageComposer { private final int userId; private final String choice; private final int no; private final int yes; - public QuestionAnsweredComposer(int userId, String choice, int no, int yes) { - this.userId = userId; - this.choice = choice; - this.no = no; - this.yes = yes; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.questionAnsweredComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionComposer.java index 83e6eb62..30a37b1a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.polls.infobus; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestionComposer extends MessageComposer { public final int duration; public final String question; - public QuestionComposer(int duration, String question) { - this.duration = duration; - this.question = question; - } //:test 3047 s:a i:10 i:20 i:10000 i:1 i:1 i:3 s:abcdefghijklmnopqrstuvwxyz12345678901234? i:1 s:a s:b @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionFinishedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionFinishedComposer.java index 025298b1..4a61c0d7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionFinishedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/QuestionFinishedComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.polls.infobus; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestionFinishedComposer extends MessageComposer { private final int no; private final int yes; - public QuestionFinishedComposer(int no, int yes) { - this.no = no; - this.yes = yes; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCancelledMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCancelledMessageComposer.java index 8f1ccbae..eb9f41d8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCancelledMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCancelledMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.quests; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestCancelledMessageComposer extends MessageComposer { private final boolean expired; - public QuestCancelledMessageComposer(boolean expired) { - this.expired = expired; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.questCancelledMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedMessageComposer.java index 44667b34..0bea6354 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedMessageComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestCompletedMessageComposer extends MessageComposer { private final UnknownClass unknownClass; private final boolean unknowbOolean; - public QuestCompletedMessageComposer(UnknownClass unknownClass, boolean unknowbOolean) { - this.unknownClass = unknownClass; - this.unknowbOolean = unknowbOolean; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.questCompletedMessageComposer); @@ -21,6 +18,7 @@ public class QuestCompletedMessageComposer extends MessageComposer { return this.response; } + @AllArgsConstructor public static class UnknownClass implements ISerialize { private final int activityPointsType; private final boolean accepted; @@ -29,14 +27,6 @@ public class QuestCompletedMessageComposer extends MessageComposer { private final int sortOrder; private final boolean easy; - public UnknownClass(int activityPointsType, boolean accepted, int id, String type, int sortOrder, boolean easy) { - this.activityPointsType = activityPointsType; - this.accepted = accepted; - this.id = id; - this.type = type; - this.sortOrder = sortOrder; - this.easy = easy; - } @Override public void serialize(ServerMessage message) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestMessageComposer.java index 26c2e012..cad1bf5d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestMessageComposer.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.quests; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class QuestMessageComposer extends MessageComposer { private final QuestsMessageComposer.Quest quest; - public QuestMessageComposer(QuestsMessageComposer.Quest quest) { - this.quest = quest; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsMessageComposer.java index 5cecad71..d49890da 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsMessageComposer.java @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class QuestsMessageComposer extends MessageComposer { private final List quests; private final boolean unknownBoolean; - public QuestsMessageComposer(List quests, boolean unknownBoolean) { - this.quests = quests; - this.unknownBoolean = unknownBoolean; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.questsMessageComposer); @@ -27,6 +24,7 @@ public class QuestsMessageComposer extends MessageComposer { return this.response; } + @AllArgsConstructor public static class Quest implements ISerialize { private final String campaignCode; private final int completedQuestsInCampaign; @@ -45,24 +43,6 @@ public class QuestsMessageComposer extends MessageComposer { private final String chainCode; private final boolean easy; - public Quest(String campaignCode, int completedQuestsInCampaign, int questCountInCampaign, int activityPointType, int id, boolean accepted, String type, String imageVersion, int rewardCurrencyAmount, String localizationCode, int completedSteps, int totalSteps, int sortOrder, String catalogPageName, String chainCode, boolean easy) { - this.campaignCode = campaignCode; - this.completedQuestsInCampaign = completedQuestsInCampaign; - this.questCountInCampaign = questCountInCampaign; - this.activityPointType = activityPointType; - this.id = id; - this.accepted = accepted; - this.type = type; - this.imageVersion = imageVersion; - this.rewardCurrencyAmount = rewardCurrencyAmount; - this.localizationCode = localizationCode; - this.completedSteps = completedSteps; - this.totalSteps = totalSteps; - this.sortOrder = sortOrder; - this.catalogPageName = catalogPageName; - this.chainCode = chainCode; - this.easy = easy; - } @Override public void serialize(ServerMessage message) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java index bc993aa3..c09508f2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java @@ -8,16 +8,14 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.NoSuchElementException; +@AllArgsConstructor public class BannedUsersFromRoomComposer extends MessageComposer { private final Room room; - public BannedUsersFromRoomComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { int timeStamp = Emulator.getIntUnixTimestamp(); @@ -30,7 +28,7 @@ public class BannedUsersFromRoomComposer extends MessageComposer { try { iterator.advance(); - if (iterator.value().endTimestamp > timeStamp) + if (iterator.value().getEndTimestamp() > timeStamp) roomBans.add(iterator.value()); } catch (NoSuchElementException e) { break; @@ -45,8 +43,8 @@ public class BannedUsersFromRoomComposer extends MessageComposer { this.response.appendInt(roomBans.size()); for (RoomBan ban : roomBans) { - this.response.appendInt(ban.userId); - this.response.appendString(ban.username); + this.response.appendInt(ban.getUserId()); + this.response.appendString(ban.getUsername()); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotForceOpenContextMenuComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotForceOpenContextMenuComposer.java index 546962a2..9d26c554 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotForceOpenContextMenuComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotForceOpenContextMenuComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BotForceOpenContextMenuComposer extends MessageComposer { private final int botId; - public BotForceOpenContextMenuComposer(int botId) { - this.botId = botId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botForceOpenContextMenuComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/CantConnectMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/CantConnectMessageComposer.java index bf421149..8bccb008 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/CantConnectMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/CantConnectMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CantConnectMessageComposer extends MessageComposer { public static final int ROOM_ERROR_GUESTROOM_FULL = 1; public static final int ROOM_ERROR_CANT_ENTER = 2; @@ -23,10 +25,6 @@ public class CantConnectMessageComposer extends MessageComposer { this.queError = ""; } - public CantConnectMessageComposer(int errorCode, String queError) { - this.errorCode = errorCode; - this.queError = queError; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellMessageComposer.java index 3e5a08bf..ab0b8f9d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellMessageComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class DoorbellMessageComposer extends MessageComposer { private final String habbo; - - public DoorbellMessageComposer(String habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.doorbellMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavouriteChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavouriteChangedComposer.java index 9c81839d..bf7ddb82 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavouriteChangedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavouriteChangedComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FavouriteChangedComposer extends MessageComposer { private final int roomId; private final boolean favorite; - public FavouriteChangedComposer(int roomId, boolean favorite) { - this.roomId = roomId; - this.favorite = favorite; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.favouriteChangedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessDeniedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessDeniedMessageComposer.java index d8bffa10..e4a80106 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessDeniedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessDeniedMessageComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FlatAccessDeniedMessageComposer extends MessageComposer { private final String habbo; - - public FlatAccessDeniedMessageComposer(String habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatAccessDeniedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessibleMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessibleMessageComposer.java index f82929cf..4e9de362 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessibleMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatAccessibleMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FlatAccessibleMessageComposer extends MessageComposer { private final String username; - public FlatAccessibleMessageComposer(String username) { - this.username = username; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatAccessibleMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java index 8c613606..8534955a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java @@ -4,18 +4,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FlatControllerAddedComposer extends MessageComposer { private final Room room; private final int userId; private final String userName; - public FlatControllerAddedComposer(Room room, int userId, String username) { - this.room = room; - this.userId = userId; - this.userName = username; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatControllerAddedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java index 4cce03f4..4300380c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FlatControllerRemovedComposer extends MessageComposer { private final Room room; private final int userId; - public FlatControllerRemovedComposer(Room room, int userId) { - this.room = room; - this.userId = userId; - } - @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java index 96bfe1f4..079357f7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java @@ -5,16 +5,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class FlatControllersComposer extends MessageComposer { private final Room room; - public FlatControllersComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatControllersComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodControlMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodControlMessageComposer.java index f8dcca3c..06488e7b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodControlMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodControlMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FloodControlMessageComposer extends MessageComposer { private final int time; - public FloodControlMessageComposer(int time) { - this.time = time; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.floodControlMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java index da317555..253b4ee0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FloorHeightMapComposer extends MessageComposer { private final Room room; - public FloorHeightMapComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.floorHeightMapComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java index 2ab7b15e..14017806 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GamePlayerValueMessageComposer extends MessageComposer { private final FreezeGamePlayer gamePlayer; - public GamePlayerValueMessageComposer(FreezeGamePlayer gamePlayer) { - this.gamePlayer = gamePlayer; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.gamePlayerValueMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java index b0b490d2..24f06ade 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java @@ -7,20 +7,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GetGuestRoomResultComposer extends MessageComposer { private final Room room; private final Habbo habbo; private final boolean roomForward; private final boolean enterRoom; - public GetGuestRoomResultComposer(Room room, Habbo habbo, boolean roomForward, boolean enterRoom) { - this.room = room; - this.habbo = habbo; - this.roomForward = roomForward; - this.enterRoom = enterRoom; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.getGuestRoomResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapComposer.java index 90ed8ea5..53c12767 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapComposer.java @@ -6,14 +6,12 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HeightMapComposer extends MessageComposer { private final Room room; - public HeightMapComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.heightMapComposer); @@ -25,7 +23,7 @@ public class HeightMapComposer extends MessageComposer { if (t != null) { if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { - this.response.appendShort((short) (t.z * 256.0)); + this.response.appendShort((short) (t.getZ() * 256.0)); } else { this.response.appendShort(t.relativeHeight()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java index a698cf2b..bdc5e593 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java @@ -41,10 +41,10 @@ public class HeightMapUpdateMessageComposer extends MessageComposer { for(int i = 0; i < 127; i++) { RoomTile t = tiles[i]; updateTiles.remove(t); // remove it from the set - this.response.appendByte((int) t.x); - this.response.appendByte((int) t.y); + this.response.appendByte((int) t.getX()); + this.response.appendByte((int) t.getY()); if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { - this.response.appendShort((short) (t.z * 256.0)); + this.response.appendShort((short) (t.getZ() * 256.0)); } else { this.response.appendShort(t.relativeHeight()); @@ -57,10 +57,10 @@ public class HeightMapUpdateMessageComposer extends MessageComposer { this.response.appendByte(this.updateTiles.size()); for (RoomTile t : this.updateTiles) { - this.response.appendByte((int) t.x); - this.response.appendByte((int) t.y); + this.response.appendByte((int) t.getX()); + this.response.appendByte((int) t.getY()); if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { - this.response.appendShort((short) (t.z * 256.0)); + this.response.appendShort((short) (t.getZ() * 256.0)); } else { this.response.appendShort(t.relativeHeight()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/KnockKnockUnknownComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/KnockKnockUnknownComposer.java index 67518055..db213bd0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/KnockKnockUnknownComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/KnockKnockUnknownComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class KnockKnockUnknownComposer extends MessageComposer { private final Habbo habbo; - public KnockKnockUnknownComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(478); //TODO Hardcoded header diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java index 8a54bbcf..62fc89f0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class MuteAllInRoomComposer extends MessageComposer { private final Room room; - public MuteAllInRoomComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.muteAllInRoomComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java index 784c7a89..0f51fb6a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomChatSettingsMessageComposer extends MessageComposer { private final Room room; - public RoomChatSettingsMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomChatSettingsMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java index cb0b4d50..b236b606 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomEntryInfoComposer extends MessageComposer { private final Room room; - public RoomEntryInfoComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomEntryInfoComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java index 40c8dce3..cad2f54f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomEntryInfoMessageComposer extends MessageComposer { private final Room room; private final boolean roomOwner; - public RoomEntryInfoMessageComposer(Room room, boolean roomOwner) { - this.room = room; - this.roomOwner = roomOwner; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomEntryInfoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java index d2c2deac..96d0ad1c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomFilterSettingsMessageComposer extends MessageComposer { private final Room room; - public RoomFilterSettingsMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomFilterSettingsMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java index 3a03275b..f123933c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomFloorThicknessUpdatedComposer extends MessageComposer { private final Room room; - public RoomFloorThicknessUpdatedComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomFloorThicknessUpdatedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomForwardMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomForwardMessageComposer.java index 2d45f0d2..33585108 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomForwardMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomForwardMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomForwardMessageComposer extends MessageComposer { private final int roomId; - public RoomForwardMessageComposer(int roomId) { - this.roomId = roomId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomForwardMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java index f7b40967..77ed4d97 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomInfoUpdatedComposer extends MessageComposer { private final Room room; - public RoomInfoUpdatedComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomInfoUpdatedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPropertyMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPropertyMessageComposer.java index 311ca936..d9a2564c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPropertyMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPropertyMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomPropertyMessageComposer extends MessageComposer { private final String type; private final String value; - public RoomPropertyMessageComposer(String type, String value) { - this.type = type; - this.value = value; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomPropertyMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRatingComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRatingComposer.java index 0b65fe9c..e1b65c39 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRatingComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRatingComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomRatingComposer extends MessageComposer { private final int score; private final boolean canVote; - public RoomRatingComposer(int score, boolean canVote) { - this.score = score; - this.canVote = canVote; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomRatingComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java index 4e13d686..d57b2c22 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomReadyMessageComposer extends MessageComposer { private final Room room; - public RoomReadyMessageComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomReadyMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java index a4f3da26..6520ae16 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomSettingsDataComposer extends MessageComposer { private final Room room; - - public RoomSettingsDataComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomSettingsDataComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSaveErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSaveErrorComposer.java index 95bca36b..6ebfd4f2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSaveErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSaveErrorComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomSettingsSaveErrorComposer extends MessageComposer { public final static int PASSWORD_REQUIRED = 5; public final static int ROOM_NAME_MISSING = 7; @@ -17,12 +19,6 @@ public class RoomSettingsSaveErrorComposer extends MessageComposer { private final int errorCode; private final String info; - public RoomSettingsSaveErrorComposer(int roomId, int errorCode, String info) { - this.roomId = roomId; - this.errorCode = errorCode; - this.info = info; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomSettingsSaveErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java index 31b80d3f..5ebf1aa1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomSettingsSavedComposer extends MessageComposer { private final Room room; - public RoomSettingsSavedComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomSettingsSavedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java index 44a845cc..4982e0db 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomVisualizationSettingsComposer extends MessageComposer { private final Room room; - public RoomVisualizationSettingsComposer(Room room) { - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomVisualizationSettingsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/YouAreControllerMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/YouAreControllerMessageComposer.java index 1ff3bfd5..8c194a17 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/YouAreControllerMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/YouAreControllerMessageComposer.java @@ -4,18 +4,16 @@ import com.eu.habbo.habbohotel.rooms.RoomRightLevels; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class YouAreControllerMessageComposer extends MessageComposer { private final RoomRightLevels type; - public YouAreControllerMessageComposer(RoomRightLevels type) { - this.type = type; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.youAreControllerMessageComposer); - this.response.appendInt(this.type.level); + this.response.appendInt(this.type.getLevel()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/DiceValueMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/DiceValueMessageComposer.java index 3360f64e..e23478ce 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/DiceValueMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/DiceValueMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class DiceValueMessageComposer extends MessageComposer { private final int id; private final int value; - public DiceValueMessageComposer(int id, int value) { - this.id = id; - this.value = value; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.diceValueMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java index 751d8aef..40629d13 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java @@ -7,16 +7,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FloorItemOnRollerComposer extends MessageComposer { // THIS IS WRONG SlideObjectBundleMessageComposer private final HabboItem item; private final HabboItem roller; private final RoomTile oldLocation; - private final RoomTile newLocation; - private final double heightOffset; private final double oldZ; + private final RoomTile newLocation; private final double newZ; + private final double heightOffset; private final Room room; public FloorItemOnRollerComposer(HabboItem item, HabboItem roller, RoomTile newLocation, double heightOffset, Room room) { @@ -30,16 +32,6 @@ public class FloorItemOnRollerComposer extends MessageComposer { this.newZ = -1; } - public FloorItemOnRollerComposer(HabboItem item, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, double heightOffset, Room room) { - this.item = item; - this.roller = roller; - this.oldLocation = oldLocation; - this.oldZ = oldZ; - this.newLocation = newLocation; - this.newZ = newZ; - this.heightOffset = heightOffset; - this.room = room; - } @Override protected ServerMessage composeInternal() { @@ -47,10 +39,10 @@ public class FloorItemOnRollerComposer extends MessageComposer { short oldY = this.item.getY(); this.response.init(Outgoing.slideObjectBundleMessageComposer); - this.response.appendInt(this.oldLocation != null ? this.oldLocation.x : this.item.getX()); - this.response.appendInt(this.oldLocation != null ? this.oldLocation.y : this.item.getY()); - this.response.appendInt(this.newLocation.x); - this.response.appendInt(this.newLocation.y); + this.response.appendInt(this.oldLocation != null ? this.oldLocation.getX() : this.item.getX()); + this.response.appendInt(this.oldLocation != null ? this.oldLocation.getY() : this.item.getY()); + this.response.appendInt(this.newLocation.getX()); + this.response.appendInt(this.newLocation.getY()); this.response.appendInt(1); this.response.appendInt(this.item.getId()); this.response.appendString(Double.toString(this.oldLocation != null ? this.oldZ : this.item.getZ())); @@ -59,8 +51,8 @@ public class FloorItemOnRollerComposer extends MessageComposer { if(this.oldLocation == null) { this.item.onMove(this.room, this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.newLocation); - this.item.setX(this.newLocation.x); - this.item.setY(this.newLocation.y); + this.item.setX(this.newLocation.getX()); + this.item.setY(this.newLocation.getY()); this.item.setZ(this.item.getZ() + this.heightOffset); this.item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java index 5cf6bd80..88325771 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ItemAddMessageComposer extends MessageComposer { private final HabboItem item; private final String itemOwnerName; - public ItemAddMessageComposer(HabboItem item, String itemOwnerName) { - this.item = item; - this.itemOwnerName = itemOwnerName; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java index cdaad108..54962305 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ItemDataUpdateMessageComposer extends MessageComposer { private final InteractionPostIt postIt; - public ItemDataUpdateMessageComposer(InteractionPostIt postIt) { - this.postIt = postIt; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java index 5ef368b5..50fa9538 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ItemRemoveMessageComposer extends MessageComposer { private final HabboItem item; - public ItemRemoveMessageComposer(HabboItem item) { - this.item = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.itemRemoveMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java index 1cd0c4ef..d2b3ecf0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ItemUpdateMessageComposer extends MessageComposer { private final HabboItem item; - public ItemUpdateMessageComposer(HabboItem item) { - this.item = item; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java index d770e9aa..919701be 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java @@ -9,16 +9,15 @@ import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.Map; import java.util.NoSuchElementException; +@AllArgsConstructor public class ItemsComposer extends MessageComposer { private final Room room; - public ItemsComposer(Room room) { - this.room = room; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java index e63edcdc..76359e60 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Set; +@AllArgsConstructor public class ItemsDataUpdateComposer extends MessageComposer { private final Set items; - public ItemsDataUpdateComposer(Set items) { - this.items = items; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.objectsDataUpdateMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java index da86e395..40ac8239 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java @@ -6,15 +6,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ObjectAddMessageComposer extends MessageComposer { private final HabboItem item; private final String itemOwnerName; - public ObjectAddMessageComposer(HabboItem item, String itemOwnerName) { - this.item = item; - this.itemOwnerName = itemOwnerName == null ? "" : itemOwnerName; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java index 0d9242b7..76b98b6f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ObjectDataUpdateMessageComposer extends MessageComposer { private final HabboItem item; - public ObjectDataUpdateMessageComposer(HabboItem item) { - this.item = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.objectDataUpdateMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java index 17072b06..9f48b749 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java @@ -6,13 +6,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ObjectUpdateMessageComposer extends MessageComposer { private final HabboItem item; - public ObjectUpdateMessageComposer(HabboItem item) { - this.item = item; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java index 5cd90fce..d2274efb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java @@ -9,17 +9,15 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; import java.util.NoSuchElementException; +@AllArgsConstructor public class ObjectsMessageComposer extends MessageComposer { private final TIntObjectMap furniOwnerNames; private final THashSet items; - public ObjectsMessageComposer(TIntObjectMap furniOwnerNames, THashSet items) { - this.furniOwnerNames = furniOwnerNames; - this.items = items; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java index 88eed980..dfaa9c36 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java @@ -4,20 +4,18 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OneWayDoorStatusMessageComposer extends MessageComposer { private final HabboItem item; - public OneWayDoorStatusMessageComposer(HabboItem item) { - this.item = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.oneWayDoorStatusMessageComposer); this.response.appendInt(this.item.getId()); try { - int state = Integer.valueOf(this.item.getExtradata()); + int state = Integer.parseInt(this.item.getExtradata()); this.response.appendInt(state); } catch (Exception e) { this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java index c9365c8b..21e5773a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java @@ -4,17 +4,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PresentOpenedMessageComposer extends MessageComposer { private final HabboItem item; private final String text; private final boolean unknown; - public PresentOpenedMessageComposer(HabboItem item, String text, boolean unknown) { - this.item = item; - this.text = text; - this.unknown = unknown; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java index 71b6b3ac..724b51a6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java @@ -4,7 +4,9 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RemoveFloorItemComposer extends MessageComposer { private final HabboItem item; private final boolean noUser; @@ -14,10 +16,6 @@ public class RemoveFloorItemComposer extends MessageComposer { this.noUser = false; } - public RemoveFloorItemComposer(HabboItem item, boolean noUser) { - this.item = item; - this.noUser = noUser; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java index 583589cf..f3016dd0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RequestSpamWallPostItMessageComposer extends MessageComposer { private final HabboItem item; - public RequestSpamWallPostItMessageComposer(HabboItem item) { - this.item = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.requestSpamWallPostItMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomDimmerPresetsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomDimmerPresetsComposer.java index c79b4a42..8e430b46 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomDimmerPresetsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomDimmerPresetsComposer.java @@ -5,14 +5,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomDimmerPresetsComposer extends MessageComposer { private final TIntObjectMap moodLightData; - public RoomDimmerPresetsComposer(TIntObjectMap moodLightData) { - this.moodLightData = moodLightData; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomDimmerPresetsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java index 6d991303..c9c07747 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java @@ -4,17 +4,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UpdateStackHeightTileHeightComposer extends MessageComposer { private final HabboItem item; private final int height; - public UpdateStackHeightTileHeightComposer(HabboItem item, int height) { - this.item = item; - this.height = height; - - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.updateStackHeightTileHeightComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeboxSongDisksMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeboxSongDisksMessageComposer.java index 5202fc3c..b7e40a8a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeboxSongDisksMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeboxSongDisksMessageComposer.java @@ -4,18 +4,15 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class JukeboxSongDisksMessageComposer extends MessageComposer { private final List songs; private final int totalLength; - public JukeboxSongDisksMessageComposer(List songs, int totalLength) { - this.songs = songs; - this.totalLength = totalLength; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.jukeboxSongDisksMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/NowPlayingMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/NowPlayingMessageComposer.java index d1b29028..41929d8c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/NowPlayingMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/NowPlayingMessageComposer.java @@ -4,18 +4,14 @@ import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NowPlayingMessageComposer extends MessageComposer { private final SoundTrack track; private final int playListId; private final int msPlayed; - public NowPlayingMessageComposer(SoundTrack track, int playListId, int msPlayed) { - this.track = track; - this.playListId = playListId; - this.msPlayed = msPlayed; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.nowPlayingMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/OfficialSongIdMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/OfficialSongIdMessageComposer.java index 8a0ac6f2..3d998c72 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/OfficialSongIdMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/OfficialSongIdMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OfficialSongIdMessageComposer extends MessageComposer { private final SoundTrack track; - public OfficialSongIdMessageComposer(SoundTrack track) { - this.track = track; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListMessageComposer.java index e4abcb9f..811b4413 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListMessageComposer.java @@ -5,14 +5,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PlayListMessageComposer extends MessageComposer { private final THashSet tracks; - public PlayListMessageComposer(THashSet tracks) { - this.tracks = tracks; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.playListMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListSongAddedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListSongAddedMessageComposer.java index baaff7de..591cd477 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListSongAddedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/PlayListSongAddedMessageComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PlayListSongAddedMessageComposer extends MessageComposer { private final SoundTrack track; - - public PlayListSongAddedMessageComposer(SoundTrack track) { - this.track = track; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.playListSongAddedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/TraxSongInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/TraxSongInfoMessageComposer.java index 1e6d2edd..84efe58c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/TraxSongInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/TraxSongInfoMessageComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class TraxSongInfoMessageComposer extends MessageComposer { private final List tracks; - public TraxSongInfoMessageComposer(List tracks) { - this.tracks = tracks; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.traxSongInfoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/UserSongDisksInventoryMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/UserSongDisksInventoryMessageComposer.java index 068f158c..a2a1de11 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/UserSongDisksInventoryMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/UserSongDisksInventoryMessageComposer.java @@ -1,19 +1,17 @@ package com.eu.habbo.messages.outgoing.rooms.items.jukebox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class UserSongDisksInventoryMessageComposer extends MessageComposer { private final List items; - public UserSongDisksInventoryMessageComposer(List items) { - this.items = items; - } @Override protected ServerMessage composeInternal() { @@ -21,9 +19,9 @@ public class UserSongDisksInventoryMessageComposer extends MessageComposer { this.response.appendInt(this.items.size()); - for (HabboItem item : this.items) { + for (InteractionMusicDisc item : this.items) { this.response.appendInt(item.getId()); - this.response.appendInt(((InteractionMusicDisc) item).getSongId()); + this.response.appendInt(item.getSongId()); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniCancelLockMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniCancelLockMessageComposer.java index 68e5a3a3..4c73acb1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniCancelLockMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniCancelLockMessageComposer.java @@ -4,14 +4,11 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionLoveLock; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FriendFurniCancelLockMessageComposer extends MessageComposer { private final InteractionLoveLock loveLock; - - public FriendFurniCancelLockMessageComposer(InteractionLoveLock loveLock) { - this.loveLock = loveLock; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.friendFurniCancelLockMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniOtherLockConfirmedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniOtherLockConfirmedMessageComposer.java index 139a6e97..24480304 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniOtherLockConfirmedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniOtherLockConfirmedMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionLoveLock; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FriendFurniOtherLockConfirmedMessageComposer extends MessageComposer { private final InteractionLoveLock loveLock; - public FriendFurniOtherLockConfirmedMessageComposer(InteractionLoveLock loveLock) { - this.loveLock = loveLock; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.friendFurniOtherLockConfirmedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniStartConfirmationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniStartConfirmationMessageComposer.java index 0c18d081..68eb83e4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniStartConfirmationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/FriendFurniStartConfirmationMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionLoveLock; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FriendFurniStartConfirmationMessageComposer extends MessageComposer { private final InteractionLoveLock loveLock; - public FriendFurniStartConfirmationMessageComposer(InteractionLoveLock loveLock) { - this.loveLock = loveLock; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.friendFurniStartConfirmationMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentFailedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentFailedMessageComposer.java index aae98e16..ee4c8518 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentFailedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentFailedMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms.items.rentablespaces; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RentableSpaceRentFailedMessageComposer extends MessageComposer { private final int itemId; - public RentableSpaceRentFailedMessageComposer(int itemId) { - this.itemId = itemId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.rentableSpaceRentFailedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentOkMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentOkMessageComposer.java index 86db86c6..494110d9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentOkMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceRentOkMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.rooms.items.rentablespaces; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RentableSpaceRentOkMessageComposer extends MessageComposer { private final int itemId; - public RentableSpaceRentOkMessageComposer(int itemId) { - this.itemId = itemId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.rentableSpaceRentOkMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java index 18b0fa34..07581d57 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java @@ -7,7 +7,11 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +@RequiredArgsConstructor +@AllArgsConstructor public class RentableSpaceStatusMessageComposer extends MessageComposer { public static final int SPACE_ALREADY_RENTED = 100; public static final int SPACE_EXTEND_NOT_RENTED = 101; @@ -23,19 +27,7 @@ public class RentableSpaceStatusMessageComposer extends MessageComposer { private final Habbo habbo; private final HabboItem item; - private final int errorCode; - - public RentableSpaceStatusMessageComposer(Habbo habbo, HabboItem item) { - this.habbo = habbo; - this.item = item; - this.errorCode = 0; - } - - public RentableSpaceStatusMessageComposer(Habbo habbo, HabboItem item, int errorCode) { - this.habbo = habbo; - this.item = item; - this.errorCode = errorCode; - } + private int errorCode = 0; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeControlVideoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeControlVideoMessageComposer.java index 8f0569d5..d43b96be 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeControlVideoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeControlVideoMessageComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms.items.youtube; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class YoutubeControlVideoMessageComposer extends MessageComposer { private final int furniId; private final int state; - public YoutubeControlVideoMessageComposer(int furniId, int state) { - this.furniId = furniId; - this.state = state; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayPlaylistsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayPlaylistsComposer.java index b7674dd7..8f511c24 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayPlaylistsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayPlaylistsComposer.java @@ -4,19 +4,16 @@ import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; +@AllArgsConstructor public class YoutubeDisplayPlaylistsComposer extends MessageComposer { private final int itemId; private final ArrayList playlists; private final YoutubeManager.YoutubePlaylist currentPlaylist; - public YoutubeDisplayPlaylistsComposer(int itemId, ArrayList playlists, YoutubeManager.YoutubePlaylist currentPlaylist) { - this.itemId = itemId; - this.playlists = playlists; - this.currentPlaylist = currentPlaylist; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayVideoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayVideoMessageComposer.java index a06f8913..4cbe76c5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayVideoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayVideoMessageComposer.java @@ -4,20 +4,15 @@ import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class YoutubeDisplayVideoMessageComposer extends MessageComposer { private final int itemId; private final YoutubeManager.YoutubeVideo video; private final boolean playing; private final int startTime; - public YoutubeDisplayVideoMessageComposer(int itemId, YoutubeManager.YoutubeVideo video, boolean playing, int startTime) { - this.itemId = itemId; - this.video = video; - this.playing = playing; - this.startTime = startTime; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.youtubeDisplayVideoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java index 6b1c382f..d360906a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OpenPetPackageRequestedMessageComposer extends MessageComposer { private final HabboItem item; - public OpenPetPackageRequestedMessageComposer(HabboItem item) { - this.item = item; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PerkAllowancesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PerkAllowancesComposer.java index 66f53c6b..b8a7a8d3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PerkAllowancesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PerkAllowancesComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.rooms.pets; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PerkAllowancesComposer extends MessageComposer { public static final int CLOSE_WIDGET = 0; public static final int NAME_TOO_SHORT = 1; @@ -15,11 +17,7 @@ public class PerkAllowancesComposer extends MessageComposer { private final int errorCode; private final String errorString; - public PerkAllowancesComposer(int itemId, int errorCode, String errorString) { - this.itemId = itemId; - this.errorCode = errorCode; - this.errorString = errorString; - } + @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java index 6b195364..63a0d18b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetExperienceComposer extends MessageComposer { private final Pet pet; private final int amount; - public PetExperienceComposer(Pet pet, int amount) { - this.pet = pet; - this.amount = amount; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java index d3c9a3e3..f393d9e2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetFigureUpdateComposer extends MessageComposer { private final HorsePet pet; - public PetFigureUpdateComposer(HorsePet pet) { - this.pet = pet; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInfoMessageComposer.java index 8511657b..fcaff99f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInfoMessageComposer.java @@ -10,17 +10,14 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetInfoMessageComposer extends MessageComposer { private final Pet pet; private final Room room; private final Habbo requestingHabbo; - public PetInfoMessageComposer(Pet pet, Room room, Habbo requestingHabbo) { - this.pet = pet; - this.room = room; - this.requestingHabbo = requestingHabbo; - } @Override protected ServerMessage composeInternal() { @@ -43,7 +40,7 @@ public class PetInfoMessageComposer extends MessageComposer { } this.response.appendInt(this.pet.getEnergy()); this.response.appendInt(this.pet.getMaxEnergy()); //Max energy - this.response.appendInt(this.pet.getHappyness()); //this.pet.getHappyness() + this.response.appendInt(this.pet.getHappiness()); //this.pet.getHappyness() this.response.appendInt(100); this.response.appendInt(this.pet.getRespect()); this.response.appendInt(this.pet.getUserId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelNotificationComposer.java index dbf3ad61..c80d8eb7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelNotificationComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetLevelNotificationComposer extends MessageComposer { private final Pet pet; - public PetLevelNotificationComposer(Pet pet) { - this.pet = pet; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java index 770e40c1..01583576 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetLevelUpdatedComposer extends MessageComposer { private final Pet pet; - public PetLevelUpdatedComposer(Pet pet) { - this.pet = pet; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectFailedComposer.java index 02a87f16..44bf9b1e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectFailedComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms.pets; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetRespectFailedComposer extends MessageComposer { private final int currentAge; private final int requiredAge; - public PetRespectFailedComposer(int currentAge, int requiredAge) { - this.currentAge = currentAge; - this.requiredAge = requiredAge; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petRespectFailedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectNotificationComposer.java index 40820f20..db29389f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetRespectNotificationComposer.java @@ -4,7 +4,9 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetRespectNotificationComposer extends MessageComposer { public final static int PET_RESPECTED = 1; public final static int PET_TREATED = 2; @@ -17,11 +19,6 @@ public class PetRespectNotificationComposer extends MessageComposer { this.type = 1; } - public PetRespectNotificationComposer(Pet pet, int type) { - this.pet = pet; - this.type = type; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petRespectNotificationComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java index 1c2bdffe..0b4c7408 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java @@ -6,14 +6,12 @@ import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetStatusUpdateComposer extends MessageComposer { private final Pet pet; - public PetStatusUpdateComposer(Pet pet) { - this.pet = pet; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petStatusUpdateComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetTrainingPanelComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetTrainingPanelComposer.java index 80f365b0..69d3c0d8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetTrainingPanelComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetTrainingPanelComposer.java @@ -5,17 +5,16 @@ import com.eu.habbo.habbohotel.pets.PetCommand; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.Collections; import java.util.List; +@AllArgsConstructor public class PetTrainingPanelComposer extends MessageComposer { private final Pet pet; - public PetTrainingPanelComposer(Pet pet) { - this.pet = pet; - } @Override protected ServerMessage composeInternal() { @@ -27,9 +26,9 @@ public class PetTrainingPanelComposer extends MessageComposer { this.response.appendInt(this.pet.getPetData().getPetCommands().size()); for (PetCommand petCommand : this.pet.getPetData().getPetCommands()) { - this.response.appendInt(petCommand.id); + this.response.appendInt(petCommand.getId()); - if (this.pet.getLevel() >= petCommand.level) { + if (this.pet.getLevel() >= petCommand.getLevel()) { enabled.add(petCommand); } } @@ -41,7 +40,7 @@ public class PetTrainingPanelComposer extends MessageComposer { this.response.appendInt(enabled.size()); for (PetCommand petCommand : enabled) { - this.response.appendInt(petCommand.id); + this.response.appendInt(petCommand.getId()); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java index ffd6e403..2d942965 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java @@ -7,7 +7,9 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TIntObjectProcedure; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomPetComposer extends MessageComposer implements TIntObjectProcedure { private final TIntObjectMap pets; @@ -16,9 +18,6 @@ public class RoomPetComposer extends MessageComposer implements TIntObjectProced this.pets.put(pet.getId(), pet); } - public RoomPetComposer(TIntObjectMap pets) { - this.pets = pets; - } @Override protected ServerMessage composeInternal() { @@ -36,6 +35,7 @@ public class RoomPetComposer extends MessageComposer implements TIntObjectProced if (pet instanceof IPetLook) { this.response.appendString(((IPetLook) pet).getLook()); } else { + // TODO: It will never be a type of MonsterplantPet in this scenario? this.response.appendString(pet.getPetData().getType() + " " + pet.getRace() + " " + pet.getColor() + " " + ((pet instanceof HorsePet ? (((HorsePet) pet).hasSaddle() ? "3" : "2") + " 2 " + ((HorsePet) pet).getHairStyle() + " " + ((HorsePet) pet).getHairColor() + " 3 " + ((HorsePet) pet).getHairStyle() + " " + ((HorsePet) pet).getHairColor() + (((HorsePet) pet).hasSaddle() ? " 4 9 0" : "") : pet instanceof MonsterplantPet ? (((MonsterplantPet) pet).look.isEmpty() ? "2 1 8 6 0 -1 -1" : ((MonsterplantPet) pet).look) : "2 2 -1 0 3 -1 0"))); } this.response.appendInt(pet.getRoomUnit().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingRequestComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingRequestComposer.java index 59505529..13f7de0e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingRequestComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingRequestComposer.java @@ -57,7 +57,7 @@ public class ConfirmBreedingRequestComposer extends MessageComposer { this.response.appendInt(rewardBreeds.get(4).size()); //Count { for (PetBreedingReward reward : rewardBreeds.get(4)) { - this.response.appendInt(reward.breed); + this.response.appendInt(reward.getBreed()); } } @@ -65,7 +65,7 @@ public class ConfirmBreedingRequestComposer extends MessageComposer { this.response.appendInt(rewardBreeds.get(3).size()); //Count { for (PetBreedingReward reward : rewardBreeds.get(3)) { - this.response.appendInt(reward.breed); + this.response.appendInt(reward.getBreed()); } } @@ -73,7 +73,7 @@ public class ConfirmBreedingRequestComposer extends MessageComposer { this.response.appendInt(rewardBreeds.get(2).size()); //Count { for (PetBreedingReward reward : rewardBreeds.get(2)) { - this.response.appendInt(reward.breed); + this.response.appendInt(reward.getBreed()); } } @@ -81,7 +81,7 @@ public class ConfirmBreedingRequestComposer extends MessageComposer { this.response.appendInt(rewardBreeds.get(1).size()); //Count { for (PetBreedingReward reward : rewardBreeds.get(1)) { - this.response.appendInt(reward.breed); + this.response.appendInt(reward.getBreed()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingResultComposer.java index 35eb6cf0..ba949649 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/ConfirmBreedingResultComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms.pets.breeding; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ConfirmBreedingResultComposer extends MessageComposer { private final int anInt1; private final int anInt2; - public ConfirmBreedingResultComposer(int anInt1, int anInt2) { - this.anInt1 = anInt1; - this.anInt2 = anInt2; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/GoToBreedingNestFailureComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/GoToBreedingNestFailureComposer.java index f226b6d7..1f5bcf4b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/GoToBreedingNestFailureComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/GoToBreedingNestFailureComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.rooms.pets.breeding; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GoToBreedingNestFailureComposer extends MessageComposer { public final static int NO_NESTS = 0; public final static int NO_SUITABLE_NESTS = 1; @@ -15,10 +17,6 @@ public class GoToBreedingNestFailureComposer extends MessageComposer { private final int reason; - public GoToBreedingNestFailureComposer(int reason) { - this.reason = reason; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.goToBreedingNestFailureComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/NestBreedingSuccessComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/NestBreedingSuccessComposer.java index 8ea74d5a..15db2f02 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/NestBreedingSuccessComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/NestBreedingSuccessComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.rooms.pets.breeding; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NestBreedingSuccessComposer extends MessageComposer { private final int type; private final int race; - public NestBreedingSuccessComposer(int type, int race) { - this.type = type; - this.race = race; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.nestBreedingSuccessComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingComposer.java index 3c4628c7..f3d567ff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingComposer.java @@ -3,19 +3,14 @@ package com.eu.habbo.messages.outgoing.rooms.pets.breeding; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetBreedingComposer extends MessageComposer { private final int state; private final int anInt1; private final int anInt2; - - public PetBreedingComposer(int state, int anInt1, int anInt2) { - this.state = state; - this.anInt1 = anInt1; - this.anInt2 = anInt2; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petBreedingComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java index da6b9c26..0f5f1ebd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java @@ -6,16 +6,13 @@ import com.eu.habbo.habbohotel.rooms.RoomPromotion; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomEventComposer extends MessageComposer { private final Room room; private final RoomPromotion roomPromotion; - public RoomEventComposer(Room room, RoomPromotion roomPromotion) { - this.room = room; - this.roomPromotion = roomPromotion; - } - @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java index 7c0ee60d..3004bd7b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java @@ -4,7 +4,9 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AvatarEffectMessageComposer extends MessageComposer { private final RoomUnit roomUnit; private final int effectId; @@ -14,10 +16,6 @@ public class AvatarEffectMessageComposer extends MessageComposer { this.effectId = -1; } - public AvatarEffectMessageComposer(RoomUnit roomUnit, int effectId) { - this.roomUnit = roomUnit; - this.effectId = effectId; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java index af8d2209..5d3e1947 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CarryObjectMessageComposer extends MessageComposer { private final RoomUnit roomUnit; - public CarryObjectMessageComposer(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeUserNameResultMessageEvent.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeUserNameResultMessageEvent.java index 88e63811..c45a6a69 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeUserNameResultMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeUserNameResultMessageEvent.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ChangeUserNameResultMessageEvent extends MessageComposer { private final Habbo habbo; - public ChangeUserNameResultMessageEvent(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java index 32ec302e..060a0ed6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ChatMessageComposer extends MessageComposer { private final RoomChatMessage roomChatMessage; - public ChatMessageComposer(RoomChatMessage roomChatMessage) { - this.roomChatMessage = roomChatMessage; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.chatMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java index f61f2cf2..5da8c5b0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class DanceMessageComposer extends MessageComposer { private final RoomUnit roomUnit; - public DanceMessageComposer(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java index 5ee03e95..e4a3aef5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ExpressionMessageComposer extends MessageComposer { - private RoomUserAction action; - private RoomUnit roomUnit; - - public ExpressionMessageComposer(RoomUnit roomUnit, RoomUserAction action) { - this.roomUnit = roomUnit; - this.action = action; - } + private final RoomUnit roomUnit; + private final RoomUserAction action; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboAddGroupBadgesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboAddGroupBadgesMessageComposer.java index 2c81a1c5..a6e33381 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboAddGroupBadgesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboAddGroupBadgesMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboAddGroupBadgesMessageComposer extends MessageComposer { private final Guild guild; - public HabboAddGroupBadgesMessageComposer(Guild guild) { - this.guild = guild; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboGroupBadgesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboGroupBadgesMessageComposer.java index 480ff693..f69f2ab1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboGroupBadgesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HabboGroupBadgesMessageComposer.java @@ -4,27 +4,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TObjectObjectProcedure; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboGroupBadgesMessageComposer extends MessageComposer { private final THashMap guildBadges; - public HabboGroupBadgesMessageComposer(THashMap guildBadges) { - this.guildBadges = guildBadges; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.habboGroupBadgesMessageComposer); this.response.appendInt(this.guildBadges.size()); - this.guildBadges.forEachEntry(new TObjectObjectProcedure() { - @Override - public boolean execute(Integer guildId, String badge) { - HabboGroupBadgesMessageComposer.this.response.appendInt(guildId); - HabboGroupBadgesMessageComposer.this.response.appendString(badge); - return true; - } + this.guildBadges.forEachEntry((guildId, badge) -> { + HabboGroupBadgesMessageComposer.this.response.appendInt(guildId); + HabboGroupBadgesMessageComposer.this.response.appendString(badge); + return true; }); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java index f0f1d25f..aa9914e5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java @@ -4,15 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HandItemReceivedMessageComposer extends MessageComposer { - private RoomUnit from; - private int handItem; - - public HandItemReceivedMessageComposer(RoomUnit from, int handItem) { - this.from = from; - this.handItem = handItem; - } + private final RoomUnit from; + private final int handItem; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/IgnoreResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/IgnoreResultMessageComposer.java index 31026681..4097e61a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/IgnoreResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/IgnoreResultMessageComposer.java @@ -4,7 +4,9 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class IgnoreResultMessageComposer extends MessageComposer { public final static int IGNORED = 1; public final static int MUTED = 2; @@ -13,10 +15,7 @@ public class IgnoreResultMessageComposer extends MessageComposer { private final Habbo habbo; private final int state; - public IgnoreResultMessageComposer(Habbo habbo, int state) { - this.habbo = habbo; - this.state = state; - } + @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java index f872e15a..559cbc76 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NoSuchFlatComposer extends MessageComposer { private final Room room; private final int habboId; - public NoSuchFlatComposer(Room room, int habboId) { - this.room = room; - this.habboId = habboId; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 151df5ff..36d8ee4e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -9,9 +9,11 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class RoomUnitOnRollerComposer extends MessageComposer { // THIS IS WRONG SlideObjectBundleMessageComposer private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitOnRollerComposer.class); @@ -24,7 +26,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { private final Room room; private int x; private int y; - private HabboItem oldTopItem; + private final HabboItem oldTopItem; public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) { this.roomUnit = roomUnit; @@ -34,7 +36,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.newLocation = newLocation; this.newZ = newZ; this.room = room; - oldTopItem = this.room.getTopItemAt(oldLocation.x, oldLocation.y); + oldTopItem = this.room.getTopItemAt(oldLocation.getX(), oldLocation.getY()); } public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) { @@ -54,10 +56,10 @@ public class RoomUnitOnRollerComposer extends MessageComposer { return null; this.response.init(Outgoing.slideObjectBundleMessageComposer); - this.response.appendInt(this.oldLocation.x); - this.response.appendInt(this.oldLocation.y); - this.response.appendInt(this.newLocation.x); - this.response.appendInt(this.newLocation.y); + this.response.appendInt(this.oldLocation.getX()); + this.response.appendInt(this.oldLocation.getY()); + this.response.appendInt(this.newLocation.getX()); + this.response.appendInt(this.newLocation.getY()); this.response.appendInt(0); this.response.appendInt(this.roller == null ? 0 : this.roller.getId()); this.response.appendInt(2); @@ -68,14 +70,14 @@ public class RoomUnitOnRollerComposer extends MessageComposer { if (this.roller != null && room.getLayout() != null) { Emulator.getThreading().run(() -> { if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentLocation() == this.oldLocation) { - HabboItem topItem = this.room.getTopItemAt(this.oldLocation.x, this.oldLocation.y); - HabboItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.x, this.newLocation.y); + HabboItem topItem = this.room.getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); + HabboItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -87,7 +89,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { try { topItemNewLocation.onWalkOn(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -107,7 +109,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRespectComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRespectComposer.java index 7e8945bb..b943d94f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRespectComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRespectComposer.java @@ -4,19 +4,17 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomUserRespectComposer extends MessageComposer { private final Habbo habbo; - public RoomUserRespectComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomUserRespectComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); - this.response.appendInt(this.habbo.getHabboStats().respectPointsReceived); + this.response.appendInt(this.habbo.getHabboStats().getRespectPointsReceived()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java index a1c6ea26..10225e60 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java @@ -48,12 +48,12 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(1); this.response.appendString(this.habbo.getHabboInfo().getGender().name().toUpperCase()); - this.response.appendInt(this.habbo.getHabboStats().guild != 0 ? this.habbo.getHabboStats().guild : -1); - this.response.appendInt(this.habbo.getHabboStats().guild != 0 ? 1 : -1); + this.response.appendInt(this.habbo.getHabboStats().getGuild() != 0 ? this.habbo.getHabboStats().getGuild() : -1); + this.response.appendInt(this.habbo.getHabboStats().getGuild() != 0 ? 1 : -1); String name = ""; - if (this.habbo.getHabboStats().guild != 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.habbo.getHabboStats().guild); + if (this.habbo.getHabboStats().getGuild() != 0) { + Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.habbo.getHabboStats().getGuild()); if (g != null) name = g.getName(); @@ -78,11 +78,11 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(1); this.response.appendString(habbo.getHabboInfo().getGender().name().toUpperCase()); - this.response.appendInt(habbo.getHabboStats().guild != 0 ? habbo.getHabboStats().guild : -1); - this.response.appendInt(habbo.getHabboStats().guild != 0 ? habbo.getHabboStats().guild : -1); + this.response.appendInt(habbo.getHabboStats().getGuild() != 0 ? habbo.getHabboStats().getGuild() : -1); + this.response.appendInt(habbo.getHabboStats().getGuild() != 0 ? habbo.getHabboStats().getGuild() : -1); String name = ""; - if (habbo.getHabboStats().guild != 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().guild); + if (habbo.getHabboStats().getGuild() != 0) { + Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().getGuild()); if (g != null) name = g.getName(); @@ -95,7 +95,7 @@ public class RoomUsersComposer extends MessageComposer { } } else if (this.bot != null) { this.response.appendInt(1); - this.response.appendInt(0 - this.bot.getId()); + this.response.appendInt(-this.bot.getId()); this.response.appendString(this.bot.getName()); this.response.appendString(this.bot.getMotto()); this.response.appendString(this.bot.getFigure()); @@ -122,7 +122,7 @@ public class RoomUsersComposer extends MessageComposer { } else if (this.bots != null) { this.response.appendInt(this.bots.size()); for (Bot bot : this.bots) { - this.response.appendInt(0 - bot.getId()); + this.response.appendInt(-bot.getId()); this.response.appendString(bot.getName()); this.response.appendString(bot.getMotto()); this.response.appendString(bot.getFigure()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java index d1843236..0e33a7c4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java @@ -4,13 +4,11 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ShoutMessageComposer extends MessageComposer { - private RoomChatMessage roomChatMessage; - - public ShoutMessageComposer(RoomChatMessage roomChatMessage) { - this.roomChatMessage = roomChatMessage; - } + private final RoomChatMessage roomChatMessage; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java index 582f851f..778f4fc0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SleepMessageComposer extends MessageComposer { private final RoomUnit roomUnit; - public SleepMessageComposer(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java index 9b73a4e5..d35c7dbb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserChangeMessageComposer extends MessageComposer { private final Habbo habbo; - public UserChangeMessageComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userChangeMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java index 5953a118..21278e18 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java @@ -5,7 +5,9 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserNameChangedMessageComposer extends MessageComposer { private final int userId; @@ -22,12 +24,6 @@ public class UserNameChangedMessageComposer extends MessageComposer { this.name = (includePrefix ? Room.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getRank().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getRank().getPrefix()) : "") + habbo.getHabboInfo().getUsername(); } - public UserNameChangedMessageComposer(int userId, int roomId, String name) { - this.userId = userId; - this.roomId = roomId; - this.name = name; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userNameChangedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java index 7859c1e1..b1bb08b8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserRemoveMessageComposer extends MessageComposer { private final RoomUnit roomUnit; - public UserRemoveMessageComposer(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } - - @Override + @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userRemoveMessageComposer); this.response.appendString(this.roomUnit.getId() + ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java index e3400ea1..72a1482a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java @@ -4,21 +4,19 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserTagsMessageComposer extends MessageComposer { private final Habbo habbo; - public UserTagsMessageComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userTagsMessageComposer); this.response.appendInt(this.habbo.getRoomUnit().getId()); - this.response.appendInt(this.habbo.getHabboStats().tags.length); + this.response.appendInt(this.habbo.getHabboStats().getTags().length); - for (String tag : this.habbo.getHabboStats().tags) { + for (String tag : this.habbo.getHabboStats().getTags()) { this.response.appendString(tag); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java index 489a55d7..f9e91566 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserTypingMessageComposer extends MessageComposer { private final RoomUnit roomUnit; private final boolean typing; - public UserTypingMessageComposer(RoomUnit roomUnit, boolean typing) { - this.roomUnit = roomUnit; - this.typing = typing; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userTypingMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java index 5e0cc0f1..917b0ebc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserUnbannedFromRoomComposer extends MessageComposer { private final Room room; private final int userId; - public UserUnbannedFromRoomComposer(Room room, int userId) { - this.room = room; - this.userId = userId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userUnbannedFromRoomComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java index 91ab1784..9c492cb6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java @@ -41,8 +41,8 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(this.roomUnits.size()); for (RoomUnit roomUnit : this.roomUnits) { this.response.appendInt(roomUnit.getId()); - this.response.appendInt(roomUnit.getPreviousLocation().x); - this.response.appendInt(roomUnit.getPreviousLocation().y); + this.response.appendInt(roomUnit.getPreviousLocation().getX()); + this.response.appendInt(roomUnit.getPreviousLocation().getY()); this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); @@ -62,8 +62,8 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(this.habbos.size()); for (Habbo habbo : this.habbos) { this.response.appendInt(habbo.getRoomUnit().getId()); - this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().x); - this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().y); + this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getX()); + this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getY()); this.response.appendString(habbo.getRoomUnit().getPreviousLocationZ() + ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java index bda7ee34..6bce50a3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WhisperMessageComposer extends MessageComposer { private final RoomChatMessage roomChatMessage; - public WhisperMessageComposer(RoomChatMessage roomChatMessage) { - this.roomChatMessage = roomChatMessage; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java index 463f22e0..9bc54acf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java @@ -4,19 +4,17 @@ import com.eu.habbo.habbohotel.rooms.RoomTradeUser; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TradingAcceptComposer extends MessageComposer { private final RoomTradeUser tradeUser; - public TradingAcceptComposer(RoomTradeUser tradeUser) { - this.tradeUser = tradeUser; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.tradingAcceptComposer); this.response.appendInt(this.tradeUser.getUserId()); - this.response.appendInt(this.tradeUser.getAccepted()); + this.response.appendInt(this.tradeUser.isAccepted()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingCloseComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingCloseComposer.java index 67100fb2..8a29c74a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingCloseComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingCloseComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.trading; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TradingCloseComposer extends MessageComposer { public static final int USER_CANCEL_TRADE = 0; public static final int ITEMS_NOT_FOUND = 1; @@ -11,10 +13,6 @@ public class TradingCloseComposer extends MessageComposer { private final int userId; private final int errorCode; - public TradingCloseComposer(int userId, int errorCode) { - this.userId = userId; - this.errorCode = errorCode; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java index 111d49f3..f0ecff94 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java @@ -7,14 +7,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TradingItemListComposer extends MessageComposer { private final RoomTrade roomTrade; - public TradingItemListComposer(RoomTrade roomTrade) { - this.roomTrade = roomTrade; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.tradingItemListComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java index 0efa92a8..8a189406 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java @@ -5,7 +5,9 @@ import com.eu.habbo.habbohotel.rooms.RoomTradeUser; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TradingOpenComposer extends MessageComposer { private final RoomTrade roomTrade; private final int state; @@ -15,11 +17,6 @@ public class TradingOpenComposer extends MessageComposer { this.state = 1; } - public TradingOpenComposer(RoomTrade roomTrade, int state) { - this.roomTrade = roomTrade; - this.state = state; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.tradingOpenComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenFailedComposer.java index 4869e128..172c67fb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenFailedComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.trading; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TradingOpenFailedComposer extends MessageComposer { public static final int HOTEL_TRADING_NOT_ALLOWED = 1; public static final int YOU_TRADING_OFF = 2; @@ -12,18 +14,14 @@ public class TradingOpenFailedComposer extends MessageComposer { public static final int YOU_ALREADY_TRADING = 7; public static final int TARGET_ALREADY_TRADING = 8; - private final String username; private final int code; + private final String username; public TradingOpenFailedComposer(int code) { this.code = code; this.username = ""; } - public TradingOpenFailedComposer(int code, String username) { - this.code = code; - this.username = username; - } protected ServerMessage composeInternal() { this.response.init(Outgoing.tradingOpenFailedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AcceptFriendResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AcceptFriendResultComposer.java index 4caf6901..4c41fca8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AcceptFriendResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AcceptFriendResultComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class AcceptFriendResultComposer extends MessageComposer { private final Map errors; - - public AcceptFriendResultComposer(Map errors) { - this.errors = errors; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.acceptFriendResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AccountSafetyLockStatusChangeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AccountSafetyLockStatusChangeMessageComposer.java index e3e32823..123d407f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AccountSafetyLockStatusChangeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AccountSafetyLockStatusChangeMessageComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AccountSafetyLockStatusChangeMessageComposer extends MessageComposer { public final int STATUS_ZERO = 0; public final int STATUS_ONE = 1; private final int status; - public AccountSafetyLockStatusChangeMessageComposer(int status) { - this.status = status; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.accountSafetyLockStatusChangeMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AvatarEffectSelectedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AvatarEffectSelectedMessageComposer.java index 891e9672..5bbef280 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/AvatarEffectSelectedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/AvatarEffectSelectedMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AvatarEffectSelectedMessageComposer extends MessageComposer { private final int type; - public AvatarEffectSelectedMessageComposer(int type) { - this.type = type; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.avatarEffectSelectedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/BotSkillListUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/BotSkillListUpdateComposer.java index db9e6bc8..07726208 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/BotSkillListUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/BotSkillListUpdateComposer.java @@ -3,18 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class BotSkillListUpdateComposer extends MessageComposer { private final int unknownInt1; private final Map unknownMap; - public BotSkillListUpdateComposer(int unknownInt1, Map unknownMap) { - this.unknownInt1 = unknownInt1; - this.unknownMap = unknownMap; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.botSkillListUpdateComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CfhSanctionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CfhSanctionMessageComposer.java index 3080d217..42aafdce 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CfhSanctionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CfhSanctionMessageComposer.java @@ -4,17 +4,15 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CfhSanctionMessageComposer extends MessageComposer { private final int unknownInt1; private final int accountId; private final CFHSanction sanction; - public CfhSanctionMessageComposer(int unknownInt1, int accountId, CFHSanction sanction) { - this.unknownInt1 = unknownInt1; - this.accountId = accountId; - this.sanction = sanction; - } + @Override protected ServerMessage composeInternal() { @@ -25,6 +23,7 @@ public class CfhSanctionMessageComposer extends MessageComposer { return this.response; } + @AllArgsConstructor public static class CFHSanction implements ISerialize { private final String name; private final int length; @@ -33,15 +32,6 @@ public class CfhSanctionMessageComposer extends MessageComposer { private final String tradelockInfo; private final String machineBanInfo; - public CFHSanction(String name, int length, int unknownInt1, boolean avatarOnly, String tradelockInfo, String machineBanInfo) { - this.name = name; - this.length = length; - this.unknownInt1 = unknownInt1; - this.avatarOnly = avatarOnly; - this.tradelockInfo = tradelockInfo; - this.machineBanInfo = machineBanInfo; - } - @Override public void serialize(ServerMessage message) { message.appendString(this.name); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ChangeEmailResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ChangeEmailResultComposer.java index 2de35fb4..07bacd45 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ChangeEmailResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ChangeEmailResultComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ChangeEmailResultComposer extends MessageComposer { private final int result; - public ChangeEmailResultComposer(int result) { - this.result = result; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.changeEmailResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionEntrySubmitResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionEntrySubmitResultComposer.java index 1f2d2991..34b3ae1f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionEntrySubmitResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionEntrySubmitResultComposer.java @@ -3,9 +3,11 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class CompetitionEntrySubmitResultComposer extends MessageComposer { private final int unknownInt1; private final String unknownString1; @@ -13,14 +15,6 @@ public class CompetitionEntrySubmitResultComposer extends MessageComposer { private final List unknownStringList1; private final List unknownStringList2; - public CompetitionEntrySubmitResultComposer(int unknownInt1, String unknownString1, int result, List unknownStringList1, List unknownStringList2) { - this.unknownInt1 = unknownInt1; - this.unknownString1 = unknownString1; - this.result = result; - this.unknownStringList1 = unknownStringList1; - this.unknownStringList2 = unknownStringList2; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.competitionEntrySubmitResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionVotingInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionVotingInfoMessageComposer.java index 0a70f7b0..7509878c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionVotingInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CompetitionVotingInfoMessageComposer.java @@ -3,20 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CompetitionVotingInfoMessageComposer extends MessageComposer { private final int unknownInt1; private final String unknownString1; private final int unknownInt2; private final int unknownInt3; - public CompetitionVotingInfoMessageComposer(int unknownInt1, String unknownString1, int unknownInt2, int unknownInt3) { - this.unknownInt1 = unknownInt1; - this.unknownString1 = unknownString1; - this.unknownInt2 = unknownInt2; - this.unknownInt3 = unknownInt3; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.competitionVotingInfoMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedRoomIdComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedRoomIdComposer.java index 25f2c302..e39eba86 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedRoomIdComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedRoomIdComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ConvertedRoomIdComposer extends MessageComposer { private final String unknownString1; private final int unknownInt1; - public ConvertedRoomIdComposer(String unknownString1, int unknownInt1) { - this.unknownString1 = unknownString1; - this.unknownInt1 = unknownInt1; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.convertedRoomIdComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/DisconnectReasonComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/DisconnectReasonComposer.java index 9507a7b7..0547223b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/DisconnectReasonComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/DisconnectReasonComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class DisconnectReasonComposer extends MessageComposer { private final int errorCode; - public DisconnectReasonComposer(int errorCode) { - this.errorCode = errorCode; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.disconnectReasonComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ElementPointerMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ElementPointerMessageComposer.java index c381c108..44c58c50 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ElementPointerMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ElementPointerMessageComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ElementPointerMessageComposer extends MessageComposer { private final String key; - - public ElementPointerMessageComposer(String key) { - this.key = key; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.elementPointerMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EmailStatusResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EmailStatusResultComposer.java index 3b944442..2b43d608 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EmailStatusResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EmailStatusResultComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class EmailStatusResultComposer extends MessageComposer { private final String email; private final boolean unknownB1; private final boolean unknownB2; - public EmailStatusResultComposer(String email, boolean unknownB1, boolean unknownB2) { - this.email = email; - this.unknownB1 = unknownB1; - this.unknownB2 = unknownB2; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.emailStatusResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupMessageComposer.java index 48172c6c..a1e771fb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupMessageComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class EpicPopupMessageComposer extends MessageComposer { public static final String LIBRARY_URL = "${image.library.url}"; private final String assetURI; - public EpicPopupMessageComposer(String assetURI) { - this.assetURI = assetURI; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.epicPopupMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendedProfileChangedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendedProfileChangedMessageComposer.java index 2bdee081..7af2a328 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendedProfileChangedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendedProfileChangedMessageComposer.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ExtendedProfileChangedMessageComposer extends MessageComposer { private final int userId; - public ExtendedProfileChangedMessageComposer(int userId) { - this.userId = userId; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.extendedProfileChangedMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurniRentOrBuyoutOfferMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurniRentOrBuyoutOfferMessageComposer.java index 22b5b0a6..5e50dcb4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurniRentOrBuyoutOfferMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurniRentOrBuyoutOfferMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FurniRentOrBuyoutOfferMessageComposer extends MessageComposer { private final boolean unknownBoolean1; private final String unknownString1; @@ -12,15 +14,6 @@ public class FurniRentOrBuyoutOfferMessageComposer extends MessageComposer { private final int points; private final int pointsType; - public FurniRentOrBuyoutOfferMessageComposer(boolean unknownBoolean1, String unknownString1, boolean unknownBoolean2, int credits, int points, int pointsType) { - this.unknownBoolean1 = unknownBoolean1; - this.unknownString1 = unknownString1; - this.unknownBoolean2 = unknownBoolean2; - this.credits = credits; - this.points = points; - this.pointsType = pointsType; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.furniRentOrBuyoutOfferMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurnitureAliasesMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurnitureAliasesMessageComposer.java index aa214d0a..c8bdfb2a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurnitureAliasesMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/FurnitureAliasesMessageComposer.java @@ -3,16 +3,14 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class FurnitureAliasesMessageComposer extends MessageComposer { private final Map unknownMap; - public FurnitureAliasesMessageComposer(Map unknownMap) { - this.unknownMap = unknownMap; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.furnitureAliasesMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/GroupDetailsChangedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/GroupDetailsChangedMessageComposer.java index be08f2d9..c957d496 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/GroupDetailsChangedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/GroupDetailsChangedMessageComposer.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GroupDetailsChangedMessageComposer extends MessageComposer { private final int guildId; - public GroupDetailsChangedMessageComposer(int guildId) { - this.guildId = guildId; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboClubExtendOfferMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboClubExtendOfferMessageComposer.java index c691bec4..070207d5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboClubExtendOfferMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboClubExtendOfferMessageComposer.java @@ -5,7 +5,9 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboClubExtendOfferMessageComposer extends MessageComposer { private final Habbo habbo; private final ClubOffer offer; @@ -14,14 +16,6 @@ public class HabboClubExtendOfferMessageComposer extends MessageComposer { private final int pointsType; private final int daysRemaining; - public HabboClubExtendOfferMessageComposer(Habbo habbo, ClubOffer offer, int normalCreditCost, int normalPointsCost, int pointsType, int daysRemaining) { - this.habbo = habbo; - this.offer = offer; - this.normalCreditCost = normalCreditCost; - this.normalPointsCost = normalPointsCost; - this.pointsType = pointsType; - this.daysRemaining = daysRemaining; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/IdentityAccountsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/IdentityAccountsComposer.java index 25d8f4cc..82ae848b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/IdentityAccountsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/IdentityAccountsComposer.java @@ -3,16 +3,14 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class IdentityAccountsComposer extends MessageComposer { private final Map unknownMap; - public IdentityAccountsComposer(Map unknownMap) { - this.unknownMap = unknownMap; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.identityAccountsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/OfferRewardDeliveredMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/OfferRewardDeliveredMessageComposer.java index 85a2ea32..17d1fc7f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/OfferRewardDeliveredMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/OfferRewardDeliveredMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OfferRewardDeliveredMessageComposer extends MessageComposer { private final Item item; - public OfferRewardDeliveredMessageComposer(Item item) { - this.item = item; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.offerRewardDeliveredMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PetSupplementedNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PetSupplementedNotificationComposer.java index 73240865..5359428a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PetSupplementedNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PetSupplementedNotificationComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetSupplementedNotificationComposer extends MessageComposer { private final int unknownInt1; private final int userId; private final int unknownInt2; - public PetSupplementedNotificationComposer(int unknownInt1, int userId, int unknownInt2) { - this.unknownInt1 = unknownInt1; - this.userId = userId; - this.unknownInt2 = unknownInt2; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petSupplementedNotificationComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java index ef2c7249..c4bf530a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java @@ -4,16 +4,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PostItPlacedComposer extends MessageComposer { private final HabboItem item; private final int unknownInt; - public PostItPlacedComposer(HabboItem item, int unknownInt) { - this.item = item; - this.unknownInt = unknownInt; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.postItPlacedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/QuizResultsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/QuizResultsMessageComposer.java index a89a7490..da2262d3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/QuizResultsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/QuizResultsMessageComposer.java @@ -3,18 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class QuizResultsMessageComposer extends MessageComposer { private final String unknownString; private final List unknownIntegerList; - public QuizResultsMessageComposer(String unknownString, List unknownIntegerList) { - this.unknownString = unknownString; - this.unknownIntegerList = unknownIntegerList; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.quizResultsMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomAdErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomAdErrorComposer.java index 3fa1bea5..5e96c8c2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomAdErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomAdErrorComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomAdErrorComposer extends MessageComposer { private final int errorCode; private final String unknownString; - public RoomAdErrorComposer(int errorCode, String unknownString) { - this.errorCode = errorCode; - this.unknownString = unknownString; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomAdErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java index 5227ffab..9b74bbd7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomMessageNotificationMessageComposer extends MessageComposer { private final Room room; private final int count; - public RoomMessageNotificationMessageComposer(Room room, int count) { - this.room = room; - this.count = count; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUserQuestionAnsweredComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUserQuestionAnsweredComposer.java index b8493fa3..5b2e0737 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUserQuestionAnsweredComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUserQuestionAnsweredComposer.java @@ -3,20 +3,16 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class RoomUserQuestionAnsweredComposer extends MessageComposer { private final int userId; private final String value; private final Map unknownMap; - public RoomUserQuestionAnsweredComposer(int userId, String value, Map unknownMap) { - this.userId = userId; - this.value = value; - this.unknownMap = unknownMap; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomUserQuestionAnsweredComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SeasonalCalendarDailyOfferMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SeasonalCalendarDailyOfferMessageComposer.java index 106585ba..6895d9fe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SeasonalCalendarDailyOfferMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SeasonalCalendarDailyOfferMessageComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SeasonalCalendarDailyOfferMessageComposer extends MessageComposer { private final int pageId; private final CatalogItem catalogItem; - public SeasonalCalendarDailyOfferMessageComposer(int pageId, CatalogItem catalogItem) { - this.pageId = pageId; - this.catalogItem = catalogItem; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ShowEnforceRoomCategoryDialogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ShowEnforceRoomCategoryDialogComposer.java index f269f31a..122f7f7e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ShowEnforceRoomCategoryDialogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ShowEnforceRoomCategoryDialogComposer.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ShowEnforceRoomCategoryDialogComposer extends MessageComposer { private final int unknownInt1; - public ShowEnforceRoomCategoryDialogComposer(int unknownInt1) { - this.unknownInt1 = unknownInt1; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsCompose1.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsCompose1.java index 5dcdc02d..6713fce0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsCompose1.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsCompose1.java @@ -2,14 +2,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SnowWarsCompose1 extends MessageComposer { private final int header; - public SnowWarsCompose1(int header) { - this.header = header; - } - //:test 1604 i:1 s:a i:10 i:2 i:3 i:4 s:1 i:3 i:10 i:1 s:Admin s:%look% s:M i:0 i:0 i:0 i:0 @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLoadingArenaComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLoadingArenaComposer.java index d6f11a4f..83aaf438 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLoadingArenaComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLoadingArenaComposer.java @@ -2,14 +2,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SnowWarsLoadingArenaComposer extends MessageComposer { private final int count; - public SnowWarsLoadingArenaComposer(int count) { - this.count = count; - } - @Override protected ServerMessage composeInternal() { this.response.init(3850); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserEnteredArenaComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserEnteredArenaComposer.java index 4bd4de90..aa6f1193 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserEnteredArenaComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserEnteredArenaComposer.java @@ -2,13 +2,12 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SnowWarsUserEnteredArenaComposer extends MessageComposer { private final int type; - public SnowWarsUserEnteredArenaComposer(int type) { - this.type = type; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAdManagerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAdManagerComposer.java index 13832c30..c7107722 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAdManagerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAdManagerComposer.java @@ -3,14 +3,11 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UnknownAdManagerComposer extends MessageComposer { private final boolean unknownBoolean; - - public UnknownAdManagerComposer(boolean unknownBoolean) { - this.unknownBoolean = unknownBoolean; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.interstitialMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownMessengerErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownMessengerErrorComposer.java index 4a414354..039708c7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownMessengerErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownMessengerErrorComposer.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UnknownMessengerErrorComposer extends MessageComposer { private final int errorCode; private final int userId; private final String message; - public UnknownMessengerErrorComposer(int errorCode, int userId, String message) { - this.errorCode = errorCode; - this.userId = userId; - this.message = message; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.instantMessageErrorComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownPollQuestionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownPollQuestionComposer.java index b4eb89a8..ba277217 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownPollQuestionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownPollQuestionComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.Map; +@AllArgsConstructor public class UnknownPollQuestionComposer extends MessageComposer { private final int unknownInt; private final Map unknownMap; - public UnknownPollQuestionComposer(int unknownInt, Map unknownMap) { - this.unknownInt = unknownInt; - this.unknownMap = unknownMap; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationMessageComposer.java index 5e19db28..79316c67 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationMessageComposer.java @@ -3,16 +3,15 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import org.apache.commons.math3.util.Pair; import java.util.List; +@AllArgsConstructor public class UserClassificationMessageComposer extends MessageComposer { private final List>> info; - public UserClassificationMessageComposer(List>> info) { - this.info = info; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftChangeEmailResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftChangeEmailResultComposer.java index 7a86bb02..b0dc0e56 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftChangeEmailResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftChangeEmailResultComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WelcomeGiftChangeEmailResultComposer extends MessageComposer { public final static int EMAIL_INVALID = 0; public final static int EMAIL_LENGTH_EXCEEDED = 1; @@ -12,10 +14,6 @@ public class WelcomeGiftChangeEmailResultComposer extends MessageComposer { private final int error; - public WelcomeGiftChangeEmailResultComposer(int error) { - this.error = error; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.welcomeGiftChangeEmailResultComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftStatusComposer.java index 2204f439..c7802e5c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftStatusComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WelcomeGiftStatusComposer extends MessageComposer { private final String email; private final boolean unknownB1; @@ -11,14 +13,6 @@ public class WelcomeGiftStatusComposer extends MessageComposer { private final int furniId; private final boolean unknownB3; - public WelcomeGiftStatusComposer(String email, boolean unknownB1, boolean unknownB2, int furniId, boolean unknownB3) { - this.email = email; - this.unknownB1 = unknownB1; - this.unknownB2 = unknownB2; - this.furniId = furniId; - this.unknownB3 = unknownB3; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.welcomeGiftStatusComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/AccountPreferencesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/AccountPreferencesComposer.java index 91586605..da8ce12c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/AccountPreferencesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/AccountPreferencesComposer.java @@ -4,25 +4,23 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AccountPreferencesComposer extends MessageComposer { private final Habbo habbo; - public AccountPreferencesComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.accountPreferencesComposer); - this.response.appendInt(this.habbo.getHabboStats().volumeSystem); - this.response.appendInt(this.habbo.getHabboStats().volumeFurni); - this.response.appendInt(this.habbo.getHabboStats().volumeTrax); - this.response.appendBoolean(this.habbo.getHabboStats().preferOldChat); - this.response.appendBoolean(this.habbo.getHabboStats().blockRoomInvites); - this.response.appendBoolean(this.habbo.getHabboStats().blockCameraFollow); - this.response.appendInt(this.habbo.getHabboStats().uiFlags); - this.response.appendInt(this.habbo.getHabboStats().chatColor.getType()); + this.response.appendInt(this.habbo.getHabboStats().getVolumeSystem()); + this.response.appendInt(this.habbo.getHabboStats().getVolumeFurni()); + this.response.appendInt(this.habbo.getHabboStats().getVolumeTrax()); + this.response.appendBoolean(this.habbo.getHabboStats().isPreferOldChat()); + this.response.appendBoolean(this.habbo.getHabboStats().isBlockRoomInvites()); + this.response.appendBoolean(this.habbo.getHabboStats().isBlockCameraFollow()); + this.response.appendInt(this.habbo.getHabboStats().getUiFlags()); + this.response.appendInt(this.habbo.getHabboStats().getChatColor().getType()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/AchievementsScoreComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/AchievementsScoreComposer.java index a1dd2c37..1e504c1c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/AchievementsScoreComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/AchievementsScoreComposer.java @@ -4,13 +4,13 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class AchievementsScoreComposer extends MessageComposer { + private final Habbo habbo; - public AchievementsScoreComposer(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ActivityPointsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ActivityPointsMessageComposer.java index b3221865..a711f1a4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ActivityPointsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ActivityPointsMessageComposer.java @@ -5,17 +5,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor public class ActivityPointsMessageComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPointsMessageComposer.class); private final Habbo habbo; - public ActivityPointsMessageComposer(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { @@ -25,9 +23,9 @@ public class ActivityPointsMessageComposer extends MessageComposer { for (String s : pointsTypes) { int type; try { - type = Integer.valueOf(s); + type = Integer.parseInt(s); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/BadgeReceivedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/BadgeReceivedComposer.java index 296d87ba..c9ba2ac3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/BadgeReceivedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/BadgeReceivedComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class BadgeReceivedComposer extends MessageComposer { private final HabboBadge badge; - public BadgeReceivedComposer(HabboBadge badge) { - this.badge = badge; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.badgeReceivedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/CheckUserNameResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/CheckUserNameResultMessageComposer.java index 77cc794a..3e687f3f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/CheckUserNameResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/CheckUserNameResultMessageComposer.java @@ -3,9 +3,11 @@ package com.eu.habbo.messages.outgoing.users; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class CheckUserNameResultMessageComposer extends MessageComposer { public static final int AVAILABLE = 0; public static final int TOO_SHORT = 2; @@ -18,12 +20,6 @@ public class CheckUserNameResultMessageComposer extends MessageComposer { private final String name; private final List suggestions; - public CheckUserNameResultMessageComposer(int status, String name, List suggestions) { - this.status = status; - this.name = name; - this.suggestions = suggestions; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.checkUserNameResultMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftSelectedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftSelectedComposer.java index 17d04d65..90e49681 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftSelectedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftSelectedComposer.java @@ -5,17 +5,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ClubGiftSelectedComposer extends MessageComposer { //:test 735 s:t i:1 s:s i:230 s:throne i:1 b:1 i:1 i:10; private final String name; private final THashSet items; - public ClubGiftSelectedComposer(String name, THashSet items) { - this.name = name; - this.items = items; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.clubGiftSelectedComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/CreditBalanceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/CreditBalanceComposer.java index 56c8586b..cc917f3a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/CreditBalanceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/CreditBalanceComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CreditBalanceComposer extends MessageComposer { private final Habbo habbo; - public CreditBalanceComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.creditBalanceComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ExtendedProfileMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ExtendedProfileMessageComposer.java index e1d53f2d..51267a31 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ExtendedProfileMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ExtendedProfileMessageComposer.java @@ -9,8 +9,7 @@ import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; @@ -21,12 +20,12 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +@Slf4j public class ExtendedProfileMessageComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(ExtendedProfileMessageComposer.class); private final HabboInfo habboInfo; private Habbo habbo; - private GameClient viewer; + private final GameClient viewer; public ExtendedProfileMessageComposer(HabboInfo habboInfo, GameClient viewer) { this.habboInfo = habboInfo; @@ -64,7 +63,7 @@ public class ExtendedProfileMessageComposer extends MessageComposer { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } this.response.appendInt(achievementScore); @@ -76,8 +75,8 @@ public class ExtendedProfileMessageComposer extends MessageComposer { List guilds = new ArrayList<>(); if (this.habbo != null) { List toRemove = new ArrayList<>(); - for (int index = this.habbo.getHabboStats().guilds.size(); index > 0; index--) { - int i = this.habbo.getHabboStats().guilds.get(index - 1); + for (int index = this.habbo.getHabboStats().getGuilds().size(); index > 0; index--) { + int i = this.habbo.getHabboStats().getGuilds().get(index - 1); if (i == 0) continue; @@ -102,9 +101,9 @@ public class ExtendedProfileMessageComposer extends MessageComposer { this.response.appendInt(guild.getId()); this.response.appendString(guild.getName()); this.response.appendString(guild.getBadge()); - this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).valueA); - this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorTwo()).valueA); - this.response.appendBoolean(this.habbo != null && guild.getId() == this.habbo.getHabboStats().guild); + this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).getValueA()); + this.response.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorTwo()).getValueA()); + this.response.appendBoolean(this.habbo != null && guild.getId() == this.habbo.getHabboStats().getGuild()); this.response.appendInt(guild.getOwnerId()); this.response.appendBoolean(guild.getOwnerId() == this.habboInfo.getId()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java index 2752cad9..367b5763 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java @@ -6,13 +6,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.procedure.TIntProcedure; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FavouriteChangedComposer extends MessageComposer { private final Habbo habbo; - public FavouriteChangedComposer(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/FigureSetIdsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/FigureSetIdsComposer.java index 448b5100..c2f1f37b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/FigureSetIdsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/FigureSetIdsComposer.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.procedure.TIntProcedure; import java.util.ArrayList; @@ -15,21 +14,18 @@ public class FigureSetIdsComposer extends MessageComposer { private final ArrayList nameList = new ArrayList<>(); public FigureSetIdsComposer(Habbo habbo) { - habbo.getInventory().getWardrobeComponent().getClothing().forEach(new TIntProcedure() { - @Override - public boolean execute(int value) { - ClothItem item = Emulator.getGameEnvironment().getCatalogManager().clothing.get(value); + habbo.getInventory().getWardrobeComponent().getClothing().forEach(value -> { + ClothItem item = Emulator.getGameEnvironment().getCatalogManager().clothing.get(value); - if (item != null) { - for (Integer j : item.setId) { - FigureSetIdsComposer.this.idList.add(j); - } - - FigureSetIdsComposer.this.nameList.add(item.name); + if (item != null) { + for (Integer j : item.getSetId()) { + FigureSetIdsComposer.this.idList.add(j); } - return true; + FigureSetIdsComposer.this.nameList.add(item.getName()); } + + return true; }); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/FigureUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/FigureUpdateComposer.java index fe6d300f..8abcde56 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/FigureUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/FigureUpdateComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FigureUpdateComposer extends MessageComposer { private final Habbo habbo; - public FigureUpdateComposer(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/HabboActivityPointNotificationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/HabboActivityPointNotificationMessageComposer.java index 0076d582..1cff9091 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/HabboActivityPointNotificationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/HabboActivityPointNotificationMessageComposer.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.outgoing.users; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboActivityPointNotificationMessageComposer extends MessageComposer { private final int currentAmount; private final int amountAdded; private final int type; - public HabboActivityPointNotificationMessageComposer(int currentAmount, int amountAdded, int type) { - this.currentAmount = currentAmount; - this.amountAdded = amountAdded; - this.type = type; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/NavigatorSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/NavigatorSettingsComposer.java index 54ec1f07..65b3bf7a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/NavigatorSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/NavigatorSettingsComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.users; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class NavigatorSettingsComposer extends MessageComposer { private final int homeRoom; private final int roomToEnter; - public NavigatorSettingsComposer(int homeRoom, int roomToEnter) { - this.homeRoom = homeRoom; - this.roomToEnter = roomToEnter; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.navigatorSettingsComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/RelationshipStatusInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/RelationshipStatusInfoComposer.java index 4d3ac651..e56fff82 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/RelationshipStatusInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/RelationshipStatusInfoComposer.java @@ -8,16 +8,15 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; +@Slf4j public class RelationshipStatusInfoComposer extends MessageComposer { - private static final Logger LOGGER = LoggerFactory.getLogger(RelationshipStatusInfoComposer.class); private final List lovers = new ArrayList<>(); private final List friends = new ArrayList<>(); @@ -39,19 +38,13 @@ public class RelationshipStatusInfoComposer extends MessageComposer { continue; switch (map.getValue().getRelation()) { - case 1: - this.lovers.add(map.getValue()); - break; - case 2: - this.friends.add(map.getValue()); - break; - case 3: - this.haters.add(map.getValue()); - break; + case 1 -> this.lovers.add(map.getValue()); + case 2 -> this.friends.add(map.getValue()); + case 3 -> this.haters.add(map.getValue()); } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } this.userId = habbo.getHabboInfo().getId(); @@ -105,7 +98,7 @@ public class RelationshipStatusInfoComposer extends MessageComposer { this.response.appendString(this.haters.get(hatersIndex).getLook()); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/RemainingMutePeriodComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/RemainingMutePeriodComposer.java index 6923cdcf..f74d4ae6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/RemainingMutePeriodComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/RemainingMutePeriodComposer.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.users; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RemainingMutePeriodComposer extends MessageComposer { private final int seconds; - public RemainingMutePeriodComposer(int seconds) { - this.seconds = seconds; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ScrSendUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ScrSendUserInfoComposer.java index 645a9565..715ac53d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ScrSendUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ScrSendUserInfoComposer.java @@ -7,7 +7,9 @@ import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ScrSendUserInfoComposer extends MessageComposer { private final Habbo habbo; private final String subscriptionType; @@ -31,12 +33,6 @@ public class ScrSendUserInfoComposer extends MessageComposer { this.responseType = 0; } - public ScrSendUserInfoComposer(Habbo habbo, String subscriptionType, int responseType) { - this.habbo = habbo; - this.subscriptionType = subscriptionType; - this.responseType = responseType; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.scrSendUserInfoComposer); @@ -85,8 +81,8 @@ public class ScrSendUserInfoComposer extends MessageComposer { this.response.appendInt(0); // pastClubDays this.response.appendInt((int) Math.floor(pastTimeAsHC / 86400.0)); // pastVIPdays this.response.appendInt(minutes); // minutesTillExpiration - this.response.appendInt((Emulator.getIntUnixTimestamp() - this.habbo.getHabboStats().hcMessageLastModified) / 60); // minutesSinceLastModified - this.habbo.getHabboStats().hcMessageLastModified = Emulator.getIntUnixTimestamp(); + this.response.appendInt((Emulator.getIntUnixTimestamp() - this.habbo.getHabboStats().getHcMessageLastModified()) / 60); // minutesSinceLastModified + this.habbo.getHabboStats().setHcMessageLastModified(Emulator.getIntUnixTimestamp()); // int - daysToPeriodEnd // int - memberPeriods diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/TalentTrackLevelMessageEvent.java b/src/main/java/com/eu/habbo/messages/outgoing/users/TalentTrackLevelMessageEvent.java index bd216321..3766ffe4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/TalentTrackLevelMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/TalentTrackLevelMessageEvent.java @@ -3,13 +3,12 @@ package com.eu.habbo.messages.outgoing.users; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TalentTrackLevelMessageEvent extends MessageComposer { private final String name; - public TalentTrackLevelMessageEvent(String name) { - this.name = name; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserBadgesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserBadgesComposer.java index 24e2621c..7ef8d99f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserBadgesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserBadgesComposer.java @@ -4,18 +4,15 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; import java.util.ArrayList; +@AllArgsConstructor public class UserBadgesComposer extends MessageComposer { private final ArrayList badges; private final int habbo; - public UserBadgesComposer(ArrayList badges, int habbo) { - this.badges = badges; - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userBadgesComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserObjectComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserObjectComposer.java index 5f486dbd..a944b9b8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserObjectComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserObjectComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserObjectComposer extends MessageComposer { private final Habbo habbo; - public UserObjectComposer(Habbo habbo) { - this.habbo = habbo; - } @Override protected ServerMessage composeInternal() { @@ -23,12 +22,12 @@ public class UserObjectComposer extends MessageComposer { this.response.appendString(this.habbo.getHabboInfo().getMotto()); this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendBoolean(false); - this.response.appendInt(this.habbo.getHabboStats().respectPointsReceived); - this.response.appendInt(this.habbo.getHabboStats().respectPointsToGive); - this.response.appendInt(this.habbo.getHabboStats().petRespectPointsToGive); + this.response.appendInt(this.habbo.getHabboStats().getRespectPointsReceived()); + this.response.appendInt(this.habbo.getHabboStats().getRespectPointsToGive()); + this.response.appendInt(this.habbo.getHabboStats().getPetRespectPointsToGive()); this.response.appendBoolean(false); this.response.appendString("01-01-1970 00:00:00"); - this.response.appendBoolean(this.habbo.getHabboStats().allowNameChange); //can change name. + this.response.appendBoolean(this.habbo.getHabboStats().isAllowNameChange()); //can change name. this.response.appendBoolean(false); //safatey locked return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java index 239cb416..7681b354 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java @@ -6,14 +6,11 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class UserPerksComposer extends MessageComposer { private final Habbo habbo; - - public UserPerksComposer(Habbo habbo) { - this.habbo = habbo; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.perkAllowancesComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/WardrobeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/WardrobeMessageComposer.java index 963230c2..a80c8b56 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/WardrobeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/WardrobeMessageComposer.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.inventory.WardrobeComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WardrobeMessageComposer extends MessageComposer { private final WardrobeComponent wardrobeComponent; - public WardrobeMessageComposer(WardrobeComponent wardrobeComponent) { - this.wardrobeComponent = wardrobeComponent; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wardrobeMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/PhoneCollectionStateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/PhoneCollectionStateMessageComposer.java index ce928de4..ad3443dd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/PhoneCollectionStateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/PhoneCollectionStateMessageComposer.java @@ -3,17 +3,15 @@ package com.eu.habbo.messages.outgoing.users.verification; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PhoneCollectionStateMessageComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; private final int unknownInt3; - public PhoneCollectionStateMessageComposer(int unknownInt1, int unknownInt2, int unknownInt3) { - this.unknownInt1 = unknownInt1; - this.unknownInt2 = unknownInt2; - this.unknownInt3 = unknownInt3; - } + @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryPhoneNumberResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryPhoneNumberResultMessageComposer.java index 99d22ec9..66032131 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryPhoneNumberResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryPhoneNumberResultMessageComposer.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.outgoing.users.verification; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TryPhoneNumberResultMessageComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; - public TryPhoneNumberResultMessageComposer(int unknownInt1, int unknownInt2) { - this.unknownInt1 = unknownInt1; - this.unknownInt2 = unknownInt2; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.tryPhoneNumberResultMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryVerificationCodeResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryVerificationCodeResultMessageComposer.java index cd1ba654..acb09e61 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryVerificationCodeResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/TryVerificationCodeResultMessageComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.messages.outgoing.users.verification; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TryVerificationCodeResultMessageComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; - public TryVerificationCodeResultMessageComposer(int unknownInt1, int unknownInt2) { - this.unknownInt1 = unknownInt1; - this.unknownInt2 = unknownInt2; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java index 70ac2d88..1fb6f4ee 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java @@ -4,13 +4,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OpenComposer extends MessageComposer { private final HabboItem item; - public OpenComposer(HabboItem item) { - this.item = item; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java index 27bd703f..a3265514 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredConditionDataComposer extends MessageComposer { private final InteractionWiredCondition condition; private final Room room; - public WiredConditionDataComposer(InteractionWiredCondition condition, Room room) { - this.condition = condition; - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredConditionDataComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java index c9978cf2..0b0757cc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredEffectDataComposer extends MessageComposer { private final InteractionWiredEffect effect; private final Room room; - public WiredEffectDataComposer(InteractionWiredEffect effect, Room room) { - this.effect = effect; - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredEffectDataComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardResultMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardResultMessageComposer.java index f494313c..24c9048e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardResultMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardResultMessageComposer.java @@ -3,7 +3,9 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredRewardResultMessageComposer extends MessageComposer { public static final int LIMITED_NO_MORE_AVAILABLE = 0; public static final int REWARD_ALREADY_RECEIVED = 1; @@ -17,9 +19,6 @@ public class WiredRewardResultMessageComposer extends MessageComposer { private final int code; - public WiredRewardResultMessageComposer(int code) { - this.code = code; - } @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java index 25fc09ab..bea9262c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredTriggerDataComposer extends MessageComposer { private final InteractionWiredTrigger trigger; private final Room room; - public WiredTriggerDataComposer(InteractionWiredTrigger trigger, Room room) { - this.trigger = trigger; - this.room = room; - } - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredTriggerDataComposer); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java b/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java index 24dd7a11..f162a44c 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java @@ -4,15 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class ChangeUsername extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(ChangeUsername.class); public ChangeUsername() { super(ChangeUsername.JSON.class); @@ -34,7 +33,7 @@ public class ChangeUsername extends RCONMessage { if (json.canChange) habbo.alert(Emulator.getTexts().getValue("rcon.alert.user.change_username")); - habbo.getHabboStats().allowNameChange = json.canChange; + habbo.getHabboStats().setAllowNameChange(json.canChange); habbo.getClient().sendResponse(new UserObjectComposer(habbo)); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { @@ -45,11 +44,11 @@ public class ChangeUsername extends RCONMessage { success = statement.executeUpdate() >= 1; } catch (SQLException sqlException) { this.message = "SQL Exception occurred"; - LOGGER.error(this.message, sqlException); + log.error(this.message, sqlException); } } catch (SQLException sqlException) { this.message = "SQL Exception occurred"; - LOGGER.error(this.message, sqlException); + log.error(this.message, sqlException); } } @@ -59,7 +58,7 @@ public class ChangeUsername extends RCONMessage { catch (Exception e) { this.status = RCONMessage.SYSTEM_ERROR; this.message = "Exception occurred"; - LOGGER.error(this.message, e); + log.error(message, e); } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java index fd16a35c..3e2dbecf 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java @@ -4,11 +4,10 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.CommandHandler; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ExecuteCommand extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteCommand.class); public ExecuteCommand() { @@ -29,7 +28,7 @@ public class ExecuteCommand extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GiveBadge.class); public GiveBadge() { @@ -80,7 +79,7 @@ public class GiveBadge extends RCONMessage { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); this.status = RCONMessage.STATUS_ERROR; this.message = e.getMessage(); } diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java index 60e9326a..dfde8b21 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java @@ -3,15 +3,14 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class GiveCredits extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GiveCredits.class); public GiveCredits() { @@ -31,7 +30,7 @@ public class GiveCredits extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java index 45001f98..7b1a5174 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java @@ -3,15 +3,15 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class GivePixels extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GivePixels.class); + public GivePixels() { @@ -31,7 +31,7 @@ public class GivePixels extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java index 2afff479..1e6f0d3b 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java @@ -3,15 +3,15 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class GivePoints extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GivePoints.class); + public GivePoints() { @@ -33,7 +33,7 @@ public class GivePoints extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java index bef769e8..033de7e2 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -4,15 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class GiveRespect extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GiveRespect.class); + public GiveRespect() { @@ -24,9 +24,9 @@ public class GiveRespect extends RCONMessage { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); if (habbo != null) { - habbo.getHabboStats().respectPointsReceived += object.respect_received; - habbo.getHabboStats().respectPointsGiven += object.respect_given; - habbo.getHabboStats().respectPointsToGive += object.daily_respects; + habbo.getHabboStats().increaseRespectPointsReceived(object.respect_received); + habbo.getHabboStats().increaseRespectPointsGiven(object.respect_given); + habbo.getHabboStats().increaseRespectPointsToGive(object.daily_respects); habbo.getClient().sendResponse(new UserObjectComposer(habbo)); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_given + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) { @@ -37,7 +37,7 @@ public class GiveRespect extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java index ce78074e..a50cf22b 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java @@ -3,19 +3,19 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.users.FigureSetIdsComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class GiveUserClothing extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(GiveUserClothing.class); + public GiveUserClothing() { super(GiveUserClothing.JSONGiveUserClothing.class); @@ -30,7 +30,7 @@ public class GiveUserClothing extends RCONMessage { if (serverMessage != null) { for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().isBlockStaffAlerts()) continue; habbo.getClient().sendResponse(serverMessage); diff --git a/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java b/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java index 852a1764..7e2efb60 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java @@ -3,15 +3,14 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class IgnoreUser extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(IgnoreUser.class); public IgnoreUser() { super(JSONIgnoreUser.class); @@ -30,7 +29,7 @@ public class IgnoreUser extends RCONMessage { statement.setInt(2, object.target_id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java index 21fad982..491bf98b 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java @@ -46,7 +46,7 @@ public class ImageHotelAlert extends RCONMessage { for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().isBlockStaffAlerts()) continue; habbo.getClient().sendResponse(message); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java b/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java index 6504725d..4417446d 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java @@ -4,11 +4,10 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.subscriptions.Subscription; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class ModifyUserSubscription extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(ModifyUserSubscription.class); public ModifyUserSubscription() { super(ModifyUserSubscription.JSON.class); @@ -24,7 +23,7 @@ public class ModifyUserSubscription extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(MuteUser.class); public MuteUser() { super(MuteUser.JSON.class); @@ -35,7 +34,7 @@ public class MuteUser extends RCONMessage { this.status = HABBO_NOT_FOUND; } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java b/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java index 736625f7..bc1fad0d 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java +++ b/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.rcon; import com.google.gson.*; +import lombok.Getter; import java.lang.reflect.Type; @@ -21,9 +22,9 @@ public abstract class RCONMessage { public final static int SYSTEM_ERROR = 4; - public final Class type; - public int status = STATUS_OK; - public String message = ""; + @Getter protected final Class type; + @Getter protected int status = STATUS_OK; + @Getter protected String message = ""; public RCONMessage(Class type) { this.type = type; diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java index 8dbf1af5..450e0b38 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -6,16 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j public class SendGift extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(SendGift.class); public SendGift() { super(SendGiftJSON.class); @@ -59,7 +58,7 @@ public class SendGift extends RCONMessage { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } else { username = habbo.getHabboInfo().getUsername(); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java index 340e656c..ec83db61 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -4,15 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class SetMotto extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(SetMotto.class); public SetMotto() { super(SetMottoJSON.class); @@ -33,7 +32,7 @@ public class SetMotto extends RCONMessage { statement.execute(); } } catch (SQLException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java b/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java index 1f190cca..180aebaa 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java @@ -17,18 +17,16 @@ public class TalkUser extends RCONMessage { if (habbo != null) { json.type = json.type.toLowerCase(); switch (json.type) { - case "talk": - habbo.talk(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().chatColor); - break; - case "whisper": - habbo.whisper(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().chatColor); - break; - case "shout": - habbo.shout(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().chatColor); - break; - default: + case "talk" -> + habbo.talk(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().getChatColor()); + case "whisper" -> + habbo.whisper(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().getChatColor()); + case "shout" -> + habbo.shout(json.message, json.bubble_id != -1 ? RoomChatMessageBubbles.getBubble(json.bubble_id) : habbo.getHabboStats().getChatColor()); + default -> { this.status = STATUS_ERROR; this.message = "Talk type: " + json.type + " not found! Use talk, whisper or shout!"; + } } } else { this.status = HABBO_NOT_FOUND; diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java index 143f2fd7..cfb39f08 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -6,15 +6,14 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; import com.eu.habbo.messages.outgoing.users.AccountPreferencesComposer; import com.eu.habbo.messages.outgoing.users.FigureUpdateComposer; import com.google.gson.Gson; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j public class UpdateUser extends RCONMessage { - private static final Logger LOGGER = LoggerFactory.getLogger(UpdateUser.class); public UpdateUser() { super(UpdateUser.JSON.class); @@ -29,23 +28,23 @@ public class UpdateUser extends RCONMessage { habbo.getHabboStats().addAchievementScore(json.achievement_score); if (json.block_following != -1) { - habbo.getHabboStats().blockFollowing = json.block_following == 1; + habbo.getHabboStats().setBlockFollowing(json.block_following == 1); } if (json.block_friendrequests != -1) { - habbo.getHabboStats().blockFriendRequests = json.block_friendrequests == 1; + habbo.getHabboStats().setBlockFriendRequests(json.block_friendrequests == 1); } if (json.block_roominvites != -1) { - habbo.getHabboStats().blockRoomInvites = json.block_roominvites == 1; + habbo.getHabboStats().setBlockRoomInvites(json.block_roominvites == 1); } if (json.old_chat != -1) { - habbo.getHabboStats().preferOldChat = json.old_chat == 1; + habbo.getHabboStats().setPreferOldChat(json.old_chat == 1); } if (json.block_camera_follow != -1) { - habbo.getHabboStats().blockCameraFollow = json.block_camera_follow == 1; + habbo.getHabboStats().setBlockCameraFollow(json.block_camera_follow == 1); } if (!json.look.isEmpty()) { @@ -108,7 +107,7 @@ public class UpdateUser extends RCONMessage { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/networking/Server.java b/src/main/java/com/eu/habbo/networking/Server.java index 49d3d0e1..36e6b1c1 100644 --- a/src/main/java/com/eu/habbo/networking/Server.java +++ b/src/main/java/com/eu/habbo/networking/Server.java @@ -9,23 +9,26 @@ import io.netty.channel.FixedRecvByteBufAllocator; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.util.concurrent.TimeUnit; +@Slf4j public abstract class Server { - - private static final Logger LOGGER = LoggerFactory.getLogger(Server.class); - + @Getter protected final ServerBootstrap serverBootstrap; + @Getter protected final EventLoopGroup bossGroup; + @Getter protected final EventLoopGroup workerGroup; private final String name; + @Getter private final String host; + @Getter private final int port; - public Server(String name, String host, int port, int bossGroupThreads, int workerGroupThreads) throws Exception { + public Server(String name, String host, int port, int bossGroupThreads, int workerGroupThreads) { this.name = name; this.host = host; this.port = port; @@ -55,42 +58,23 @@ public abstract class Server { } if (!channelFuture.isSuccess()) { - LOGGER.info("Failed to connect to the host (" + this.host + ":" + this.port + ")@" + this.name); + log.info("Failed to connect to the host (" + this.host + ":" + this.port + ")@" + this.name); System.exit(0); } else { - LOGGER.info("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); + log.info("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); } } public void stop() { - LOGGER.info("Stopping " + this.name); + log.info("Stopping " + this.name); try { this.workerGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); this.bossGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); } catch(InterruptedException e) { - LOGGER.error("Exception during {} shutdown... HARD STOP", this.name, e); + log.error("Exception during {} shutdown... HARD STOP", this.name, e); Thread.currentThread().interrupt(); } - LOGGER.info("GameServer Stopped!"); + log.info("GameServer Stopped!"); } - public ServerBootstrap getServerBootstrap() { - return this.serverBootstrap; - } - - public EventLoopGroup getBossGroup() { - return this.bossGroup; - } - - public EventLoopGroup getWorkerGroup() { - return this.workerGroup; - } - - public String getHost() { - return this.host; - } - - public int getPort() { - return this.port; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java index 2a5bb499..8e8b5456 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java @@ -7,13 +7,11 @@ import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CameraClient { - - private static final Logger LOGGER = LoggerFactory.getLogger(CameraClient.class); - + private static final String host = "google.com"; private static final int port = 1232; public static ChannelFuture channelFuture; @@ -47,10 +45,10 @@ public class CameraClient { if (CameraClient.channelFuture.isSuccess()) { CameraClient.attemptReconnect = false; CameraClient.channel = channelFuture.channel(); - LOGGER.info("Connected to the Camera Server. Attempting to login."); + log.info("Connected to the Camera Server. Attempting to login."); this.sendMessage(new CameraLoginComposer()); } else { - LOGGER.error("Failed to connect to the Camera Server. Server unreachable."); + log.error("Failed to connect to the Camera Server. Server unreachable."); CameraClient.channel = null; CameraClient.channelFuture.channel().close(); CameraClient.channelFuture = null; @@ -64,7 +62,7 @@ public class CameraClient { channelFuture.channel().close().sync(); channelFuture = null; } catch (Exception e) { - LOGGER.error("Caught Exception: ", e); + log.error("Caught Exception: ", e); Thread.currentThread().interrupt(); } } @@ -72,7 +70,7 @@ public class CameraClient { channel = null; isLoggedIn = false; - LOGGER.info("Disconnected from the camera server."); + log.info("Disconnected from the camera server."); } public void sendMessage(CameraOutgoingMessage outgoingMessage) { diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java b/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java index 6d8abb2d..431345b6 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java @@ -19,18 +19,18 @@ public class CameraHandler extends ChannelInboundHandlerAdapter { try { CameraPacketHandler.instance().handle(ctx.channel(), header, b); - } catch (Exception e) { + } catch (Exception ignored) { } finally { try { b.release(); - } catch (Exception e) { + } catch (Exception ignored) { } try { ((ByteBuf) msg).release(); - } catch (Exception e) { + } catch (Exception ignored) { } } } catch (Exception e) { @@ -39,7 +39,7 @@ public class CameraHandler extends ChannelInboundHandlerAdapter { } @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { + public void channelInactive(ChannelHandlerContext ctx) { CameraClient.attemptReconnect = true; } diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java b/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java index 4625a2ba..50f18dfe 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java @@ -18,7 +18,7 @@ public abstract class CameraIncomingMessage extends CameraMessage { public Integer readInt() { try { return this.buffer.readInt(); - } catch (Exception e) { + } catch (Exception ignored) { } return 0; @@ -27,7 +27,7 @@ public abstract class CameraIncomingMessage extends CameraMessage { public boolean readBoolean() { try { return this.buffer.readByte() == 1; - } catch (Exception e) { + } catch (Exception ignored) { } return false; diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java b/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java index fbcceb17..8a8ed4a2 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java @@ -2,9 +2,10 @@ package com.eu.habbo.networking.camera; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import lombok.Getter; public class CameraMessage { - protected final short header; + @Getter protected final short header; protected final ByteBuf buffer; public CameraMessage(short header) { @@ -12,7 +13,4 @@ public class CameraMessage { this.buffer = Unpooled.buffer(); } - public short getHeader() { - return this.header; - } } diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java b/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java index a1b3f083..45e74359 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java @@ -5,7 +5,7 @@ import io.netty.buffer.ByteBufOutputStream; import io.netty.channel.Channel; import java.io.IOException; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public abstract class CameraOutgoingMessage extends CameraMessage { private final ByteBufOutputStream stream; @@ -17,14 +17,14 @@ public abstract class CameraOutgoingMessage extends CameraMessage { try { this.stream.writeInt(0); this.stream.writeShort(header); - } catch (Exception e) { + } catch (Exception ignored) { } } public void appendRawBytes(byte[] bytes) { try { this.stream.write(bytes); - } catch (IOException e) { + } catch (IOException ignored) { } } @@ -33,70 +33,70 @@ public abstract class CameraOutgoingMessage extends CameraMessage { byte[] data = obj.getBytes(); this.stream.writeInt(data.length); this.stream.write(data); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendChar(int obj) { try { this.stream.writeChar(obj); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendChars(Object obj) { try { this.stream.writeChars(obj.toString()); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendInt32(Integer obj) { try { this.stream.writeInt(obj); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendInt32(Byte obj) { try { this.stream.writeInt((int) obj); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendInt32(Boolean obj) { try { this.stream.writeInt(obj ? 1 : 0); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendShort(int obj) { try { this.stream.writeShort((short) obj); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendByte(Integer b) { try { this.stream.writeByte(b); - } catch (IOException e) { + } catch (IOException ignored) { } } public void appendBoolean(Boolean obj) { try { this.stream.writeBoolean(obj); - } catch (IOException e) { + } catch (IOException ignored) { } } public CameraOutgoingMessage appendResponse(CameraOutgoingMessage obj) { try { this.stream.write(obj.get().array()); - } catch (IOException e) { + } catch (IOException ignored) { } return this; @@ -107,7 +107,7 @@ public abstract class CameraOutgoingMessage extends CameraMessage { buffer.setInt(0, buffer.writerIndex() - 4); - String consoleText = buffer.toString(Charset.forName("UTF-8")); + String consoleText = buffer.toString(StandardCharsets.UTF_8); for (int i = 0; i < 14; i++) { consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java index b0dc0582..79f6a4cf 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java @@ -3,13 +3,12 @@ package com.eu.habbo.networking.camera; import com.eu.habbo.networking.camera.messages.incoming.*; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.HashMap; +@Slf4j public class CameraPacketHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CameraPacketHandler.class); private static CameraPacketHandler INSTANCE; private final HashMap> packetDefinitions; @@ -41,7 +40,7 @@ public class CameraPacketHandler { message.handle(channel); message.buffer.release(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java index a13a5092..5ef3dc14 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java @@ -4,13 +4,11 @@ import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CameraLoginStatusEvent extends CameraIncomingMessage { - - private static final Logger LOGGER = LoggerFactory.getLogger(CameraLoginStatusEvent.class); - + public final static int LOGIN_OK = 0; public final static int LOGIN_ERROR = 1; public final static int NO_ACCOUNT = 2; @@ -28,27 +26,27 @@ public class CameraLoginStatusEvent extends CameraIncomingMessage { int status = this.readInt(); if (status == LOGIN_ERROR) { - LOGGER.error("Failed to login to Camera Server: Incorrect Details"); + log.error("Failed to login to Camera Server: Incorrect Details"); } else if (status == NO_ACCOUNT) { - LOGGER.error("Failed to login to Camera Server: No Account Found. Register for free on the Arcturus Forums! Visit http://arcturus.pw/"); + log.error("Failed to login to Camera Server: No Account Found. Register for free on the Arcturus Forums! Visit http://arcturus.pw/"); } else if (status == BANNED) { - LOGGER.error("Sorry but you seem to be banned from the Arcturus forums and therefor cant use the Camera Server :'("); + log.error("Sorry but you seem to be banned from the Arcturus forums and therefor cant use the Camera Server :'("); } else if (status == ALREADY_LOGGED_IN) { - LOGGER.error("You seem to be already connected to the Camera Server"); + log.error("You seem to be already connected to the Camera Server"); } else if (status == OLD_BUILD) { - LOGGER.error("This version of Arcturus Emulator is no longer supported by the Camera Server. Upgrade your emulator."); + log.error("This version of Arcturus Emulator is no longer supported by the Camera Server. Upgrade your emulator."); } else if (status == NO_CAMERA_SUBSCRIPTION) { - LOGGER.error("You don't have a Camera Subscription and therefor cannot use the camera!"); - LOGGER.error("Please consider making a donation to keep this project going. The emulator can be used free of charge!"); - LOGGER.error("A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); - LOGGER.error("By donating this subscription you support the development of the emulator you are using :)"); - LOGGER.error("Visit http://arcturus.pw/mysubscriptions.php to buy your subscription!"); - LOGGER.error("Please Consider getting a subscription. Regards: The General"); + log.error("You don't have a Camera Subscription and therefor cannot use the camera!"); + log.error("Please consider making a donation to keep this project going. The emulator can be used free of charge!"); + log.error("A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); + log.error("By donating this subscription you support the development of the emulator you are using :)"); + log.error("Visit http://arcturus.pw/mysubscriptions.php to buy your subscription!"); + log.error("Please Consider getting a subscription. Regards: The General"); } if (status == LOGIN_OK) { CameraClient.isLoggedIn = true; - LOGGER.info("Succesfully connected to the Arcturus Camera Server!"); + log.info("Succesfully connected to the Arcturus Camera Server!"); } else { CameraClient.attemptReconnect = false; } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java index c2d662dc..aa0b7e4e 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java @@ -5,13 +5,11 @@ import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageCompos import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CameraUpdateNotification extends CameraIncomingMessage { - - private static final Logger LOGGER = LoggerFactory.getLogger(CameraUpdateNotification.class); - + public CameraUpdateNotification(Short header, ByteBuf body) { super(header, body); } @@ -23,11 +21,11 @@ public class CameraUpdateNotification extends CameraIncomingMessage { int type = this.readInt(); if (type == 0) { - LOGGER.info("Camera update: {}", message); + log.info("Camera update: {}", message); } else if (type == 1) { - LOGGER.warn("Camera update: {}", message); + log.warn("Camera update: {}", message); } else if (type == 2) { - LOGGER.error("Camera update: {}", message); + log.error("Camera update: {}", message); } if (alert) { diff --git a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java index 98647cc7..7c6259d5 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java @@ -11,8 +11,9 @@ import com.eu.habbo.networking.gameserver.handlers.IdleTimeoutHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; import io.netty.handler.logging.LoggingHandler; -import io.netty.handler.timeout.IdleStateHandler; +import lombok.Getter; +@Getter public class GameServer extends Server { private final PacketManager packetManager; private final GameClientManager gameClientManager; @@ -29,7 +30,7 @@ public class GameServer extends Server { this.serverBootstrap.childHandler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception { + public void initChannel(SocketChannel ch) { ch.pipeline().addLast("logger", new LoggingHandler()); // Decoders. @@ -54,11 +55,4 @@ public class GameServer extends Server { }); } - public PacketManager getPacketManager() { - return this.packetManager; - } - - public GameClientManager getGameClientManager() { - return this.gameClientManager; - } } diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteDecryption.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteDecryption.java index b1c91b7c..126648ed 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteDecryption.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteDecryption.java @@ -2,7 +2,6 @@ package com.eu.habbo.networking.gameserver.decoders; import com.eu.habbo.networking.gameserver.GameServerAttributes; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java index bf433250..2cfc74ef 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java @@ -6,14 +6,12 @@ import com.eu.habbo.messages.PacketNames; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.List; +@Slf4j public class GameClientMessageLogger extends MessageToMessageDecoder { - - private static final Logger LOGGER = LoggerFactory.getLogger(GameClientMessageLogger.class); private final PacketNames names; public GameClientMessageLogger() { @@ -22,7 +20,7 @@ public class GameClientMessageLogger extends MessageToMessageDecoder out) { - LOGGER.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + log.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", message.getMessageId(), this.names.getIncomingName(message.getMessageId()), message.getMessageBody())); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index c85f3315..0aca0639 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -8,14 +8,14 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.TooLongFrameException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; @ChannelHandler.Sharable +@Slf4j public class GameMessageHandler extends ChannelInboundHandlerAdapter { - private static final Logger LOGGER = LoggerFactory.getLogger(GameMessageHandler.class); + @Override @@ -31,7 +31,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { ClientMessage message = (ClientMessage) msg; try { @@ -44,12 +44,12 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { handler.run(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { + public void channelInactive(ChannelHandlerContext ctx) { ctx.channel().close(); } @@ -61,9 +61,9 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { } if (Emulator.getConfig().getBoolean("debug.mode")) { if (cause instanceof TooLongFrameException) { - LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); + log.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); } else { - LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); + log.error("Disconnecting client, exception in GameMessageHander.", cause); } } ctx.channel().close(); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java index 7a4c8de2..6f44281c 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java @@ -15,7 +15,7 @@ public class GameMessageRateLimit extends MessageToMessageDecoder private static final int MAX_COUNTER = 10; @Override - protected void decode(ChannelHandlerContext ctx, ClientMessage message, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, ClientMessage message, List out) { GameClient client = ctx.channel().attr(GameServerAttributes.CLIENT).get(); if (client == null) { diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GamePolicyDecoder.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GamePolicyDecoder.java index 82938092..67e80740 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GamePolicyDecoder.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GamePolicyDecoder.java @@ -18,7 +18,7 @@ public class GamePolicyDecoder extends ByteToMessageDecoder { " " + (char) 0; @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { in.markReaderIndex(); byte b = in.readByte(); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameByteEncryption.java b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameByteEncryption.java index 0c20b977..c4f01f0e 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameByteEncryption.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameByteEncryption.java @@ -2,7 +2,6 @@ package com.eu.habbo.networking.gameserver.encoders; import com.eu.habbo.networking.gameserver.GameServerAttributes; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; @@ -11,7 +10,7 @@ import io.netty.util.ReferenceCountUtil; public class GameByteEncryption extends ChannelOutboundHandlerAdapter { @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { // convert to Bytebuf ByteBuf in = (ByteBuf) msg; diff --git a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java index fd351942..440fd039 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java @@ -6,14 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageEncoder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.List; +@Slf4j public class GameServerMessageLogger extends MessageToMessageEncoder { - private static final Logger LOGGER = LoggerFactory.getLogger(GameServerMessageLogger.class); private final PacketNames names; public GameServerMessageLogger() { @@ -22,7 +21,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder out) { - LOGGER.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + log.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", message.getHeader(), this.names.getOutgoingName(message.getHeader()), message.getBodyString())); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java index 493e1ae3..25cc2e42 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java @@ -54,7 +54,7 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { } @Override - public void handlerAdded(ChannelHandlerContext ctx) throws Exception { + public void handlerAdded(ChannelHandlerContext ctx) { if (ctx.channel().isActive() && ctx.channel().isRegistered()) { // channelActvie() event has been fired already, which means this.channelActive() will // not be invoked. We have to initialize here instead. @@ -66,7 +66,7 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { } @Override - public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { + public void handlerRemoved(ChannelHandlerContext ctx) { destroy(); } @@ -101,8 +101,7 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { * TODO: is it the right place to do it? * how to handle it if you are using multi revision? */ - if(msg instanceof ClientMessage) { - ClientMessage packet = (ClientMessage) msg; + if(msg instanceof ClientMessage packet) { if(packet.getMessageId() == Incoming.pongEvent) { this.lastPongTime = System.nanoTime(); } diff --git a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java index fed9aa56..6c9bdb40 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java @@ -9,17 +9,15 @@ import gnu.trove.map.hash.THashMap; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.Collections; import java.util.List; +@Slf4j public class RCONServer extends Server { - - private static final Logger LOGGER = LoggerFactory.getLogger(RCONServer.class); - + private final THashMap> messages; private final GsonBuilder gsonBuilder; List allowedAdresses = new ArrayList<>(); @@ -92,20 +90,20 @@ public class RCONServer extends Server { try { RCONMessage rcon = message.getDeclaredConstructor().newInstance(); Gson gson = this.gsonBuilder.create(); - rcon.handle(gson, gson.fromJson(body, rcon.type)); - LOGGER.info("Handled RCON Message: {}", message.getSimpleName()); + rcon.handle(gson, gson.fromJson(body, rcon.getType())); + log.info("Handled RCON Message: {}", message.getSimpleName()); result = gson.toJson(rcon, RCONMessage.class); if (Emulator.debugging) { - LOGGER.debug("RCON Data {} RCON Result {}", body, result); + log.debug("RCON Data {} RCON Result {}", body, result); } return result; } catch (Exception ex) { - LOGGER.error("Failed to handle RCONMessage", ex); + log.error("Failed to handle RCONMessage", ex); } } else { - LOGGER.error("Couldn't find: {}", key); + log.error("Couldn't find: {}", key); } throw new ArrayIndexOutOfBoundsException("Unhandled RCON Message"); diff --git a/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java b/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java index 0563fe0e..116af540 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java @@ -9,15 +9,13 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class RCONServerHandler extends ChannelInboundHandlerAdapter { - - private static final Logger LOGGER = LoggerFactory.getLogger(RCONServerHandler.class); - + @Override - public void channelRegistered(ChannelHandlerContext ctx) throws Exception { + public void channelRegistered(ChannelHandlerContext ctx) { String adress = ctx.channel().remoteAddress().toString().split(":")[0].replace("/", ""); for (String s : Emulator.getRconServer().allowedAdresses) { @@ -28,11 +26,11 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter { ctx.channel().close(); - LOGGER.warn("RCON Remote connection closed: {}. IP not allowed!", adress); + log.warn("RCON Remote connection closed: {}. IP not allowed!", adress); } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { ByteBuf data = (ByteBuf) msg; byte[] d = new byte[data.readableBytes()]; @@ -46,9 +44,9 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter { key = object.get("key").getAsString(); response = Emulator.getRconServer().handle(ctx, key, object.get("data").toString()); } catch (ArrayIndexOutOfBoundsException e) { - LOGGER.error("Unknown RCON Message: {}", key); + log.error("Unknown RCON Message: {}", key); } catch (Exception e) { - LOGGER.error("Invalid RCON Message: {}", message); + log.error("Invalid RCON Message: {}", message); e.printStackTrace(); } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index b7ed7c78..8ff991c0 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.games.tag.TagGame; import com.eu.habbo.habbohotel.items.ItemManager; @@ -21,9 +20,9 @@ import com.eu.habbo.habbohotel.navigation.EventCategory; import com.eu.habbo.habbohotel.navigation.NavigatorManager; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboManager; +import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; @@ -48,8 +47,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.IOException; @@ -64,10 +62,8 @@ import java.util.Objects; import java.util.regex.Pattern; import java.util.stream.Collectors; +@Slf4j public class PluginManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); - private final THashSet plugins = new THashSet<>(); private final THashSet methods = new THashSet<>(); @@ -126,9 +122,9 @@ public class PluginManager { RoomChatMessage.BANNED_BUBBLES = new int[bannedBubbles.length]; for (int i = 0; i < RoomChatMessage.BANNED_BUBBLES.length; i++) { try { - RoomChatMessage.BANNED_BUBBLES[i] = Integer.valueOf(bannedBubbles[i]); + RoomChatMessage.BANNED_BUBBLES[i] = Integer.parseInt(bannedBubbles[i]); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } @@ -229,7 +225,7 @@ public class PluginManager { Emulator.getGameEnvironment().getPointsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPixelScheduler().reloadConfig(); Emulator.getGameEnvironment().getGotwPointsScheduler().reloadConfig(); - Emulator.getGameEnvironment().subscriptionScheduler.reloadConfig(); + Emulator.getGameEnvironment().getSubscriptionScheduler().reloadConfig(); } } @@ -240,7 +236,7 @@ public class PluginManager { if (!loc.exists()) { if (loc.mkdirs()) { - LOGGER.info("Created plugins directory!"); + log.info("Created plugins directory!"); } } @@ -274,12 +270,12 @@ public class PluginManager { this.plugins.add(plugin); plugin.onEnable(); } catch (Exception e) { - LOGGER.error("Could not load plugin {}!", pluginConfigurtion.name); - LOGGER.error("Caught exception", e); + log.error("Could not load plugin {}!", pluginConfigurtion.name); + log.error("Caught exception", e); } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } @@ -312,8 +308,8 @@ public class PluginManager { try { method.invoke(null, event); } catch (Exception e) { - LOGGER.error("Could not pass default event {} to {}: {}!", event.getClass().getName(), method.getClass().getName(), method.getName()); - LOGGER.error("Caught exception", e); + log.error("Could not pass default event {} to {}: {}!", event.getClass().getName(), method.getClass().getName(), method.getName()); + log.error("Caught exception", e); } } } @@ -331,8 +327,8 @@ public class PluginManager { try { method.invoke(plugin, event); } catch (Exception e) { - LOGGER.error("Could not pass event {} to {}", event.getClass().getName(), plugin.configuration.name); - LOGGER.error("Caught exception", e); + log.error("Could not pass event {} to {}", event.getClass().getName(), plugin.configuration.name); + log.error("Caught exception", e); } } } @@ -371,7 +367,7 @@ public class PluginManager { public void dispose() { this.disposePlugins(); - LOGGER.info("Disposed Plugin Manager!"); + log.info("Disposed Plugin Manager!"); } private void disposePlugins() { @@ -387,9 +383,9 @@ public class PluginManager { p.stream.close(); p.classLoader.close(); } catch (IOException e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } catch (Exception ex) { - LOGGER.error("Failed to disable {} because of an exception.", p.configuration.name, ex); + log.error("Failed to disable {} because of an exception.", p.configuration.name, ex); } } } catch (NoSuchElementException e) { @@ -406,7 +402,7 @@ public class PluginManager { this.loadPlugins(); - LOGGER.info("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); + log.info("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); this.registerDefaultEvents(); } @@ -425,8 +421,8 @@ public class PluginManager { this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); this.methods.add(WiredHighscoreManager.class.getMethod("onEmulatorLoaded", EmulatorLoadedEvent.class)); } catch (NoSuchMethodException e) { - LOGGER.info("Failed to define default events!"); - LOGGER.error("Caught exception", e); + log.info("Failed to define default events!"); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildAcceptedMembershipEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildAcceptedMembershipEvent.java index cd9cac42..ebd23a18 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildAcceptedMembershipEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildAcceptedMembershipEvent.java @@ -1,7 +1,6 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; public class GuildAcceptedMembershipEvent extends GuildEvent { diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserLoginEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserLoginEvent.java index d864a5fb..a8704f89 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserLoginEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserLoginEvent.java @@ -2,8 +2,6 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -import java.net.SocketAddress; - public class UserLoginEvent extends UserEvent { public final String ip; diff --git a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java index 36ccd05a..2fe8e6a1 100644 --- a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java +++ b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java @@ -1,14 +1,13 @@ package com.eu.habbo.threading; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; +@Slf4j public class HabboExecutorService extends ScheduledThreadPoolExecutor { - private static final Logger LOGGER = LoggerFactory.getLogger(HabboExecutorService.class); public HabboExecutorService(int corePoolSize, ThreadFactory threadFactory) { super(corePoolSize, threadFactory); @@ -19,7 +18,7 @@ public class HabboExecutorService extends ScheduledThreadPoolExecutor { super.afterExecute(r, t); if (t != null && !(t instanceof IOException)) { - LOGGER.error("Error in HabboExecutorService", t); + log.error("Error in HabboExecutorService", t); } } } diff --git a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java index 1517ce17..108af35a 100644 --- a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java +++ b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java @@ -1,16 +1,15 @@ package com.eu.habbo.threading; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; +@Slf4j public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(RejectedExecutionHandlerImpl.class); @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { - LOGGER.error(r.toString() + " is rejected"); + log.error(r.toString() + " is rejected"); } } diff --git a/src/main/java/com/eu/habbo/threading/ThreadPooling.java b/src/main/java/com/eu/habbo/threading/ThreadPooling.java index eb7e25c4..44a85901 100644 --- a/src/main/java/com/eu/habbo/threading/ThreadPooling.java +++ b/src/main/java/com/eu/habbo/threading/ThreadPooling.java @@ -2,16 +2,15 @@ package com.eu.habbo.threading; import com.eu.habbo.Emulator; import io.netty.util.concurrent.DefaultThreadFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +@Slf4j public class ThreadPooling { - private static final Logger LOGGER = LoggerFactory.getLogger(ThreadPooling.class); public final int threads; private final ScheduledExecutorService scheduledPool; @@ -21,7 +20,7 @@ public class ThreadPooling { this.threads = threads; this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("HabExec")); this.canAdd = true; - LOGGER.info("Thread Pool -> Loaded!"); + log.info("Thread Pool -> Loaded!"); } public ScheduledFuture run(Runnable run) { @@ -34,7 +33,7 @@ public class ThreadPooling { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; @@ -47,12 +46,12 @@ public class ThreadPooling { try { run.run(); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } }, delay, TimeUnit.MILLISECONDS); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } return null; @@ -62,7 +61,7 @@ public class ThreadPooling { this.canAdd = false; this.scheduledPool.shutdownNow(); - LOGGER.info("Threading -> Disposed!"); + log.info("Threading -> Disposed!"); } public void setCanAdd(boolean canAdd) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java index e3fafa53..2e275877 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java @@ -3,17 +3,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.RequiredArgsConstructor; +@RequiredArgsConstructor public class BackgroundAnimation implements Runnable { private final HabboItem toner; private final Room room; private int length = 1000; private int state = 0; - public BackgroundAnimation(HabboItem toner, Room room) { - this.toner = toner; - this.room = room; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java index d559daed..7c034d46 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -6,20 +6,16 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; import org.slf4j.LoggerFactory; +@AllArgsConstructor public class BanzaiRandomTeleport implements Runnable { private final HabboItem item; private final HabboItem toItem; private final RoomUnit habbo; private final Room room; - public BanzaiRandomTeleport(HabboItem item, HabboItem toItem, RoomUnit habbo, Room room) { - this.item = item; - this.toItem = toItem; - this.habbo = habbo; - this.room = room; - } @Override public void run() { @@ -67,7 +63,7 @@ public class BanzaiRandomTeleport implements Runnable { Emulator.getThreading().run(() -> { this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8))); - this.room.teleportRoomUnitToLocation(this.habbo, newLocation.x, newLocation.y, newLocation.getStackHeight()); + this.room.teleportRoomUnitToLocation(this.habbo, newLocation.getX(), newLocation.getY(), newLocation.getStackHeight()); }, 250); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java index 0993c1b3..8828e86d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -7,7 +7,9 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.items.ItemsDataUpdateComposer; import gnu.trove.set.hash.THashSet; +import lombok.RequiredArgsConstructor; +@RequiredArgsConstructor public class BattleBanzaiTilesFlicker implements Runnable { private final THashSet items; private final GameTeamColors color; @@ -16,11 +18,6 @@ public class BattleBanzaiTilesFlicker implements Runnable { private boolean on = false; private int count = 0; - public BattleBanzaiTilesFlicker(THashSet items, GameTeamColors color, Room room) { - this.items = items; - this.color = color; - this.room = room; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java index 11642074..493497a6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java @@ -7,20 +7,15 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.RequiredArgsConstructor; +@RequiredArgsConstructor public class BotFollowHabbo implements Runnable { private final Bot bot; private final Habbo habbo; private final Room room; private boolean hasReached; - public BotFollowHabbo(Bot bot, Habbo habbo, Room room) { - this.bot = bot; - this.habbo = habbo; - this.room = room; - this.hasReached = false; - } - @Override public void run() { if (this.bot != null) { @@ -31,7 +26,7 @@ public class BotFollowHabbo implements Runnable { RoomTile target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + 4)) % 8); if (target != null) { - if (target.x < 0 || target.y < 0) + if (target.getX() < 0 || target.getY() < 0) target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue()); if(this.habbo.getRoomUnit().getCurrentLocation().distance(this.bot.getRoomUnit().getCurrentLocation()) < 2) { @@ -44,7 +39,7 @@ public class BotFollowHabbo implements Runnable { hasReached = false; } - if (target.x >= 0 && target.y >= 0) { + if (target.getX() >= 0 && target.getY() >= 0) { this.bot.getRoomUnit().setGoalLocation(target); this.bot.getRoomUnit().setCanWalk(true); Emulator.getThreading().run(this, 500); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java b/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java index a3b31144..bcfbe2e1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java @@ -2,18 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.networking.camera.CameraClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class CameraClientAutoReconnect implements Runnable { - - private static final Logger LOGGER = LoggerFactory.getLogger(CameraClientAutoReconnect.class); - + @Override public void run() { if (CameraClient.attemptReconnect && !Emulator.isShuttingDown) { if (!(CameraClient.channelFuture != null && CameraClient.channelFuture.channel().isRegistered())) { - LOGGER.info("Attempting to connect to the Camera server."); + log.info("Attempting to connect to the Camera server."); if (Emulator.getCameraClient() != null) { Emulator.getCameraClient().disconnect(); } else { @@ -23,11 +21,11 @@ public class CameraClientAutoReconnect implements Runnable { try { Emulator.getCameraClient().connect(); } catch (Exception e) { - LOGGER.error("Failed to start the camera client.", e); + log.error("Failed to start the camera client.", e); } } else { CameraClient.attemptReconnect = false; - LOGGER.info("Already connected to the camera. Reconnecting not needed!"); + log.info("Already connected to the camera. Reconnecting not needed!"); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java index 1cd945ec..3ebb9add 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -10,20 +10,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import gnu.trove.map.hash.THashMap; +import lombok.AllArgsConstructor; import java.util.List; +@AllArgsConstructor public class CannonKickAction implements Runnable { private final InteractionCannon cannon; private final Room room; private final GameClient client; - public CannonKickAction(InteractionCannon cannon, Room room, GameClient client) { - this.cannon = cannon; - this.room = room; - this.client = client; - } - @Override public void run() { if(this.cannon == null || this.room == null || this.room.getLayout() == null) return; @@ -41,7 +37,7 @@ public class CannonKickAction implements Runnable { ServerMessage message = new NotificationDialogMessageComposer("cannon.png", dater).compose(); for (RoomTile t : tiles) { - for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) { + for (Habbo habbo : this.room.getHabbosAt(t.getX(), t.getY())) { if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); habbo.getClient().sendResponse(message); //kicked composer diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java index 5155a6ea..8eb29531 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java @@ -1,14 +1,12 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.items.interactions.InteractionCannon; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CannonResetCooldownAction implements Runnable { private final InteractionCannon cannon; - public CannonResetCooldownAction(InteractionCannon cannon) { - this.cannon = cannon; - } - @Override public void run() { if (this.cannon != null) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java b/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java index a4caf09f..1428b4c2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java @@ -5,17 +5,14 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.networking.gameserver.GameServerAttributes; import io.netty.channel.ChannelHandlerContext; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ChannelReadHandler implements Runnable { private final ChannelHandlerContext ctx; private final ClientMessage message; - public ChannelReadHandler(ChannelHandlerContext ctx, ClientMessage message) { - this.ctx = ctx; - this.message = message; - } - public void run() { try { GameClient client = this.ctx.channel().attr(GameServerAttributes.CLIENT).get(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index 08a61aae..4d4ff335 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -8,16 +8,13 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class ClearRentedSpace implements Runnable { private final InteractionRentableSpace item; private final Room room; - public ClearRentedSpace(InteractionRentableSpace item, Room room) { - this.item = item; - this.room = room; - } - @Override public void run() { THashSet items = new THashSet<>(); @@ -36,8 +33,8 @@ public class ClearRentedSpace implements Runnable { if (owner != null) { owner.getClient().sendResponse(new UnseenItemsComposer(items)); - owner.getHabboStats().rentedItemId = 0; - owner.getHabboStats().rentedTimeEnd = 0; + owner.getHabboStats().setRentedItemId(0); + owner.getHabboStats().setRentedTimeEnd(0); } else { for (HabboItem i : items) { i.run(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java index 1637bc7f..2a092f01 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java @@ -2,16 +2,13 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CloseGate implements Runnable { private final HabboItem gate; private final Room room; - public CloseGate(HabboItem gate, Room room) { - this.gate = gate; - this.room = room; - } - @Override public void run() { if (this.gate.getRoomId() == this.room.getId()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index 827b2ad9..22d9aafa 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -7,11 +7,13 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class CrackableExplode implements Runnable { private final Room room; private final InteractionCrackable habboItem; @@ -20,16 +22,6 @@ public class CrackableExplode implements Runnable { private final short x; private final short y; - public CrackableExplode(Room room, InteractionCrackable item, Habbo habbo, boolean toInventory, short x, short y) { - this.room = room; - this.habboItem = item; - this.habbo = habbo; - this.toInventory = toInventory; - - this.x = x; - this.y = y; - } - @Override public void run() { if (this.habboItem.getRoomId() == 0) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java b/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java index 8885ef9f..7dc8da5e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.guides.GuardianTicket; import com.eu.habbo.habbohotel.guides.GuardianVote; import com.eu.habbo.habbohotel.guides.GuardianVoteType; import com.eu.habbo.habbohotel.users.Habbo; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuardianNotAccepted implements Runnable { private final GuardianTicket ticket; private final Habbo habbo; - public GuardianNotAccepted(GuardianTicket ticket, Habbo habbo) { - this.ticket = ticket; - this.habbo = habbo; - } - @Override public void run() { GuardianVote vote = this.ticket.getVoteForGuardian(this.habbo); diff --git a/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java b/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java index b0434c6a..d9e8039d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java @@ -2,13 +2,12 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuardianTicket; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GuardianTicketFindMoreSlaves implements Runnable { private final GuardianTicket ticket; - public GuardianTicketFindMoreSlaves(GuardianTicket ticket) { - this.ticket = ticket; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java b/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java index 15a361ea..96fe155a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.guides.GuardianTicket; public class GuardianVotingFinish implements Runnable { private final GuardianTicket ticket; - private int checkSum; + private final int checkSum; public GuardianVotingFinish(GuardianTicket ticket) { this.ticket = ticket; diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java index 645e3155..bdc2b307 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java @@ -3,16 +3,13 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.HandItemReceivedMessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboGiveHandItemToHabbo implements Runnable { private final Habbo target; private final Habbo from; - public HabboGiveHandItemToHabbo(Habbo from, Habbo target) { - this.target = target; - this.from = from; - } - @Override public void run() { if (this.from.getHabboInfo().getCurrentRoom() == null || this.target.getHabboInfo().getCurrentRoom() == null) diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java index 4bb3875e..8a6492c5 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java @@ -2,18 +2,14 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HabboItemNewState implements Runnable { private final HabboItem item; private final Room room; private final String state; - public HabboItemNewState(HabboItem item, Room room, String state) { - this.item = item; - this.room = room; - this.state = state; - } - @Override public void run() { this.item.setExtradata(this.state); diff --git a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java index 56742599..c30853d6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -2,21 +2,18 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.*; +@Slf4j +@AllArgsConstructor public class InsertModToolIssue implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(InsertModToolIssue.class); private final ModToolIssue issue; - public InsertModToolIssue(ModToolIssue issue) { - this.issue = issue; - } - @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id, photo_item_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { @@ -41,7 +38,7 @@ public class InsertModToolIssue implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); @@ -49,7 +46,7 @@ public class InsertModToolIssue implements Runnable { statement.setInt(1, this.issue.senderId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java index 0bc85056..d1305f7e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java @@ -63,7 +63,7 @@ public class KickBallAction implements Runnable { this.room.sendComposer(new FloorItemOnRollerComposer(this.ball, null, next, next.getStackHeight() - this.ball.getZ(), this.room).compose()); - Emulator.getThreading().run(this, (long) delay); + Emulator.getThreading().run(this, delay); } else { this.currentStep = this.totalSteps; //End the move sequence, the ball can't bounce anywhere this.run(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java b/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java index 5de407fa..a85ef7b9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java +++ b/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java @@ -2,14 +2,11 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class LoadCustomHeightMap implements Runnable { private final Room room; - - public LoadCustomHeightMap(Room room) { - this.room = room; - } - @Override public void run() { this.room.setLayout(Emulator.getGameEnvironment().getRoomManager().loadCustomLayout(this.room)); diff --git a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java index 317622c7..a0c7c226 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class OneWayGateActionOne implements Runnable { - private HabboItem oneWayGate; - private Room room; - private GameClient client; + private final GameClient client; + private final Room room; + private final HabboItem oneWayGate; - public OneWayGateActionOne(GameClient client, Room room, HabboItem item) { - this.oneWayGate = item; - this.room = room; - this.client = client; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index bc09a18b..e711e000 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -6,32 +6,27 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; -import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListAddOrUpdateComposer; +import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.PresentOpenedMessageComposer; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +@Slf4j +@AllArgsConstructor public class OpenGift implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(OpenGift.class); private final HabboItem item; private final Habbo habbo; private final Room room; - public OpenGift(HabboItem item, Habbo habbo, Room room) { - this.item = item; - this.habbo = habbo; - this.room = room; - } - @Override public void run() { try { @@ -65,35 +60,26 @@ public class OpenGift implements Runnable { for (HabboItem item : items) { switch (item.getBaseItem().getType()) { - case WALL: - case FLOOR: + case WALL, FLOOR -> { if (!unseenItems.containsKey(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI)) unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, new ArrayList<>()); - unseenItems.get(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI).add(item.getGiftAdjustedId()); - - break; - - case BADGE: + } + case BADGE -> { if (!unseenItems.containsKey(UnseenItemsComposer.AddHabboItemCategory.BADGE)) unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.BADGE, new ArrayList<>()); - unseenItems.get(UnseenItemsComposer.AddHabboItemCategory.BADGE).add(item.getId()); // badges cannot be placed so no need for gift adjusted ID - break; - - case PET: + } + case PET -> { if (!unseenItems.containsKey(UnseenItemsComposer.AddHabboItemCategory.PET)) unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.PET, new ArrayList<>()); - unseenItems.get(UnseenItemsComposer.AddHabboItemCategory.PET).add(item.getGiftAdjustedId()); - break; - - case ROBOT: + } + case ROBOT -> { if (!unseenItems.containsKey(UnseenItemsComposer.AddHabboItemCategory.BOT)) unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.BOT, new ArrayList<>()); - unseenItems.get(UnseenItemsComposer.AddHabboItemCategory.BOT).add(item.getGiftAdjustedId()); - break; + } } } @@ -104,7 +90,7 @@ public class OpenGift implements Runnable { this.habbo.getClient().sendResponse(new PresentOpenedMessageComposer(inside, "", false)); } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java b/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java index 199faf45..5b09e553 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java @@ -3,20 +3,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetClearPosture implements Runnable { private final Pet pet; private final RoomUnitStatus key; private final PetTasks newTask; private final boolean clearTask; - public PetClearPosture(Pet pet, RoomUnitStatus key, PetTasks newTask, boolean clearTask) { - this.pet = pet; - this.key = key; - this.newTask = newTask; - this.clearTask = clearTask; - } - @Override public void run() { if (this.pet != null) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java index afcd662c..dba130aa 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java @@ -9,25 +9,23 @@ import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetEatAction implements Runnable { private final Pet pet; private final InteractionPetFood food; - public PetEatAction(Pet pet, InteractionPetFood food) { - this.pet = pet; - this.food = food; - } @Override public void run() { if (this.pet.getRoomUnit() != null && this.pet.getRoom() != null) { - if (this.pet.levelHunger >= 20 && this.food != null && Integer.valueOf(this.food.getExtradata()) < this.food.getBaseItem().getStateCount()) { + if (this.pet.levelHunger >= 20 && this.food != null && Integer.parseInt(this.food.getExtradata()) < this.food.getBaseItem().getStateCount()) { this.pet.addHunger(-20); this.pet.setTask(PetTasks.EAT); this.pet.getRoomUnit().setCanWalk(false); - this.food.setExtradata(Integer.valueOf(this.food.getExtradata()) + 1 + ""); + this.food.setExtradata(Integer.parseInt(this.food.getExtradata()) + 1 + ""); this.pet.getRoom().updateItem(this.food); if (this.pet instanceof GnomePet) { @@ -42,7 +40,7 @@ public class PetEatAction implements Runnable { Emulator.getThreading().run(this, 1000); } else { - if (this.food != null && Integer.valueOf(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) { + if (this.food != null && Integer.parseInt(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.food.getId()), 500); if (this.pet.getRoom() != null) { this.pet.getRoom().removeHabboItem(this.food); diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java index d5a0ebe2..3cf9613e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -5,17 +5,13 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class PetFollowHabbo implements Runnable { - private final int directionOffset; - private final Habbo habbo; private final Pet pet; - - public PetFollowHabbo(Pet pet, Habbo habbo, int offset) { - this.pet = pet; - this.habbo = habbo; - this.directionOffset = offset; - } + private final Habbo habbo; + private final int directionOffset; @Override public void run() { @@ -29,11 +25,11 @@ public class PetFollowHabbo implements Runnable { RoomTile target = this.habbo.getHabboInfo().getCurrentRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + this.directionOffset + 4) % 8)); if (target != null) { - if (target.x < 0 || target.y < 0) + if (target.getX() < 0 || target.getY() < 0) target = this.habbo.getHabboInfo().getCurrentRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue()); - if (target.x >= 0 && target.y >= 0) { - if (this.pet.getRoom().getLayout().tileWalkable(target.x, target.y)) { + if (target.getX() >= 0 && target.getY() >= 0) { + if (this.pet.getRoom().getLayout().tileWalkable(target.getX(), target.getY())) { this.pet.getRoomUnit().setGoalLocation(target); this.pet.getRoomUnit().setCanWalk(true); this.pet.setTask(PetTasks.FOLLOW); diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java index c938f8f3..28216298 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java @@ -2,23 +2,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor class QueryDeleteHabboBadge implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboBadge.class); - private final String name; private final Habbo habbo; - - public QueryDeleteHabboBadge(Habbo habbo, String name) { - this.name = name; - this.habbo = habbo; - } + private final String name; @Override public void run() { @@ -27,7 +23,7 @@ class QueryDeleteHabboBadge implements Runnable { statement.setString(2, this.name); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java index 91579bfd..f0493e9f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -2,21 +2,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor public class QueryDeleteHabboItem implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItem.class); private final int itemId; - public QueryDeleteHabboItem(int itemId) { - this.itemId = itemId; - } public QueryDeleteHabboItem(HabboItem item) { this.itemId = item.getId(); @@ -28,7 +26,7 @@ public class QueryDeleteHabboItem implements Runnable { statement.setInt(1, this.itemId); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java index 71e30aca..6ee3bc53 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -3,21 +3,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.TIntObjectMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor public class QueryDeleteHabboItems implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItems.class); private TIntObjectMap items; - public QueryDeleteHabboItems(TIntObjectMap items) { - this.items = items; - } @Override public void run() { @@ -32,7 +30,7 @@ public class QueryDeleteHabboItems implements Runnable { statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } this.items.clear(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java index 15d72f9e..27d26b3b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -5,15 +5,13 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor class RemoveFloorItemTask implements Runnable { private final Room room; private final HabboItem item; - public RemoveFloorItemTask(Room room, HabboItem item) { - this.room = room; - this.item = item; - } @Override public void run() { @@ -24,6 +22,6 @@ class RemoveFloorItemTask implements Runnable { this.room.removeHabboItem(this.item); this.room.updateTile(tile); this.room.sendComposer(new RemoveFloorItemComposer(this.item, true).compose()); - this.room.sendComposer(new HeightMapUpdateMessageComposer(this.item.getX(), this.item.getY(), tile.z, tile.relativeHeight()).compose()); + this.room.sendComposer(new HeightMapUpdateMessageComposer(this.item.getX(), this.item.getY(), tile.getZ(), tile.relativeHeight()).compose()); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java index 4e645380..ba50a1d9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java @@ -46,9 +46,9 @@ public class RoomTrashing implements Runnable { RoomTile t = null; while (offset > 0) { - t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.x, event.toLocation.y), event.habbo.getRoomUnit().getBodyRotation().getValue(), (short) offset); + t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.getX(), event.toLocation.getY()), event.habbo.getRoomUnit().getBodyRotation().getValue(), (short) offset); - if (!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) { + if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { offset--; } else { break; @@ -56,7 +56,7 @@ public class RoomTrashing implements Runnable { } for (HabboItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); + double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } @@ -66,9 +66,9 @@ public class RoomTrashing implements Runnable { t = null; while (offset > 0) { - t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.x, event.toLocation.y), event.habbo.getRoomUnit().getBodyRotation().getValue() + 7, (short) offset); + t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.getX(), event.toLocation.getY()), event.habbo.getRoomUnit().getBodyRotation().getValue() + 7, (short) offset); - if (!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) { + if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { offset--; } else { break; @@ -82,7 +82,7 @@ public class RoomTrashing implements Runnable { } for (HabboItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); + double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } @@ -93,7 +93,7 @@ public class RoomTrashing implements Runnable { while (offset > 0) { t = INSTANCE.getRoom().getLayout().getTileInFront(event.toLocation, event.habbo.getRoomUnit().getBodyRotation().getValue() + 1, (short) offset); - if (!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) { + if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { offset--; } else { break; @@ -104,7 +104,7 @@ public class RoomTrashing implements Runnable { items = INSTANCE.room.getItemsAt(s); for (HabboItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); + double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java index 0f6491fd..8fe54bec 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java @@ -3,18 +3,14 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomUnitGiveHanditem implements Runnable { private final RoomUnit roomUnit; private final Room room; private final int itemId; - public RoomUnitGiveHanditem(RoomUnit roomUnit, Room room, int itemId) { - this.roomUnit = roomUnit; - this.room = room; - this.itemId = itemId; - } - @Override public void run() { if (this.room != null && this.roomUnit.isInRoom()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java index 7d2cce57..e290ab01 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java @@ -3,18 +3,14 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomUnitKick implements Runnable { private final Habbo habbo; private final Room room; private final boolean removeEffect; - public RoomUnitKick(Habbo habbo, Room room, boolean removeEffect) { - this.habbo = habbo; - this.room = room; - this.removeEffect = removeEffect; - } - @Override public void run() { if (this.removeEffect) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 898d44e7..f9d8ea6b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -7,17 +7,14 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class RoomUnitRidePet implements Runnable { - private RideablePet pet; - private Habbo habbo; - private RoomTile goalTile; + private final RideablePet pet; + private final Habbo habbo; + private final RoomTile goalTile; - public RoomUnitRidePet(RideablePet pet, Habbo habbo, RoomTile goalTile) { - this.pet = pet; - this.habbo = habbo; - this.goalTile = goalTile; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index d315d6d0..4d2ecf8b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -5,32 +5,23 @@ 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.users.HabboItem; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.util.LinkedList; +@Slf4j +@AllArgsConstructor public class RoomUnitTeleport implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitTeleport.class); - private RoomUnit roomUnit; - private Room room; - private int x; - private int y; - private double z; + + private final RoomUnit roomUnit; + private final Room room; + private final int x; + private final int y; + private final double z; - private int newEffect; - - public RoomUnitTeleport(RoomUnit roomUnit, Room room, int x, int y, double z, int newEffect) { - this.roomUnit = roomUnit; - this.room = room; - this.x = x; - this.y = y; - this.z = z; - this.newEffect = newEffect; - } + private final int newEffect; @Override public void run() { @@ -45,12 +36,12 @@ public class RoomUnitTeleport implements Runnable { RoomTile lastLocation = this.roomUnit.getCurrentLocation(); RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y); - HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); + HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().getX(), this.roomUnit.getCurrentLocation().getY()); if (topItem != null) { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } this.roomUnit.setPath(new LinkedList<>()); @@ -65,14 +56,14 @@ public class RoomUnitTeleport implements Runnable { this.roomUnit.statusUpdate(true); roomUnit.isWiredTeleporting = false; - this.room.updateHabbosAt(newLocation.x, newLocation.y); - this.room.updateBotsAt(newLocation.x, newLocation.y); + this.room.updateHabbosAt(newLocation.getX(), newLocation.getY()); + this.room.updateBotsAt(newLocation.getX(), newLocation.getY()); topItem = room.getTopItemAt(x, y); if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) { try { topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this }); - } catch (Exception e) { + } catch (Exception ignored) { } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 32c393eb..6d61abd4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -5,21 +5,17 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor public class RoomUnitTeleportWalkToAction implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitTeleportWalkToAction.class); private final Habbo habbo; private final HabboItem habboItem; private final Room room; - public RoomUnitTeleportWalkToAction(Habbo habbo, HabboItem habboItem, Room room) { - this.habbo = habbo; - this.habboItem = habboItem; - this.room = room; - } @Override public void run() { @@ -33,7 +29,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } else { if (tile.isWalkable()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index ab5c1e3a..c3a131c4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -5,22 +5,17 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor public class RoomUnitVendingMachineAction implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitVendingMachineAction.class); private final Habbo habbo; private final HabboItem habboItem; private final Room room; - public RoomUnitVendingMachineAction(Habbo habbo, HabboItem habboItem, Room room) { - this.habbo = habbo; - this.habboItem = habboItem; - this.room = room; - } - @Override public void run() { if (this.habbo.getHabboInfo().getCurrentRoom() == this.room) { @@ -32,10 +27,10 @@ public class RoomUnitVendingMachineAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } else { - if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { + if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) { this.habbo.getRoomUnit().setGoalLocation(tile); Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index a2f65db7..80689fa4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -5,16 +5,18 @@ 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 lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.List; +@AllArgsConstructor public class RoomUnitWalkToLocation implements Runnable { - private RoomUnit walker; - private RoomTile goalTile; - private Room room; - private List targetReached; - private List failedReached; + private final RoomUnit walker; + private final RoomTile goalTile; + private final Room room; + private final List targetReached; + private final List failedReached; public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, Runnable targetReached, Runnable failedReached) { this.walker = walker; @@ -28,13 +30,6 @@ public class RoomUnitWalkToLocation implements Runnable { if (failedReached != null) this.targetReached.add(failedReached); } - public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List targetReached, List failedReached) { - this.walker = walker; - this.goalTile = goalTile; - this.room = room; - this.targetReached = targetReached; - this.failedReached = failedReached; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index 3ff6ae37..d59a433e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -6,16 +6,18 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.RequiredArgsConstructor; import java.util.List; +@RequiredArgsConstructor public class RoomUnitWalkToRoomUnit implements Runnable { + private final RoomUnit walker; + private final RoomUnit target; + private final Room room; + private final List targetReached; + private final List failedReached; private final int minDistance; - private RoomUnit walker; - private RoomUnit target; - private Room room; - private List targetReached; - private List failedReached; private RoomTile goalTile = null; @@ -28,15 +30,6 @@ public class RoomUnitWalkToRoomUnit implements Runnable { this.minDistance = 1; } - public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List targetReached, List failedReached, int minDistance) { - this.walker = walker; - this.target = target; - this.room = room; - this.targetReached = targetReached; - this.failedReached = failedReached; - this.minDistance = minDistance; - } - @Override public void run() { if (this.goalTile == null) { @@ -59,7 +52,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { } private void findNewLocation() { - this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true); + this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().getX(), this.target.getCurrentLocation().getY(), true); if (this.goalTile == null) { if (this.failedReached != null) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java index 44151ae6..8871b071 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -4,23 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor public class SaveScoreForTeam implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(SaveScoreForTeam.class); public final GameTeam team; public final Game game; - - public SaveScoreForTeam(GameTeam team, Game game) { - this.team = team; - this.game = game; - } + @Override public void run() { @@ -38,7 +35,7 @@ public class SaveScoreForTeam implements Runnable { statement.executeBatch(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java b/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java index 0f12ea12..ec90782f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java @@ -3,15 +3,13 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class SendRoomUnitEffectComposer implements Runnable { private final Room room; private final RoomUnit roomUnit; - public SendRoomUnitEffectComposer(Room room, RoomUnit roomUnit) { - this.room = room; - this.roomUnit = roomUnit; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index c9745ee6..01366809 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -8,14 +8,13 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j class TeleportInteraction extends Thread { - private static final Logger LOGGER = LoggerFactory.getLogger(TeleportInteraction.class); private final Room room; private final GameClient client; @@ -107,7 +106,7 @@ class TeleportInteraction extends Thread { } else if (this.state == 1) { RoomTile loc = HabboItem.getSquareInFront(this.room.getLayout(), this.teleportOne); - if (this.client.getHabbo().getRoomUnit().getX() == loc.x && this.client.getHabbo().getRoomUnit().getY() == loc.y) { + if (this.client.getHabbo().getRoomUnit().getX() == loc.getX() && this.client.getHabbo().getRoomUnit().getY() == loc.getY()) { this.teleportOne.setExtradata("1"); this.room.updateItem(this.teleportOne); this.state = 2; @@ -116,7 +115,7 @@ class TeleportInteraction extends Thread { } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java index 2a26db69..02e19b7c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java @@ -2,21 +2,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor public class UpdateModToolIssue implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(UpdateModToolIssue.class); private final ModToolIssue issue; - public UpdateModToolIssue(ModToolIssue issue) { - this.issue = issue; - } @Override public void run() { @@ -29,7 +27,7 @@ public class UpdateModToolIssue implements Runnable { statement.setInt(5, this.issue.id); statement.execute(); } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java b/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java index 26fb4c90..126371c6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java @@ -4,17 +4,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredCollissionRunnable implements Runnable { public final RoomUnit roomUnit; public final Room room; public final Object[] objects; - public WiredCollissionRunnable(RoomUnit roomUnit, Room room, Object[] objects) { - this.roomUnit = roomUnit; - this.room = room; - this.objects = objects; - } @Override diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java b/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java index a6ccde40..36ee8c67 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java @@ -3,17 +3,14 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; +import lombok.AllArgsConstructor; +@AllArgsConstructor class WiredRepeatEffectTask implements Runnable { private final InteractionWiredEffect effect; private final Room room; private final int delay; - public WiredRepeatEffectTask(InteractionWiredEffect effect, Room room, int delay) { - this.effect = effect; - this.room = room; - this.delay = delay; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java b/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java index 7ea428b1..0fa42f04 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java @@ -3,13 +3,11 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.wired.WiredHandler; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class WiredResetTimers implements Runnable { - private Room room; - - public WiredResetTimers(Room room) { - this.room = room; - } + private final Room room; @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java index 40ecf450..9f60fa0c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java @@ -4,14 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class YoutubeAdvanceVideo implements Runnable { private final InteractionYoutubeTV tv; - public YoutubeAdvanceVideo(InteractionYoutubeTV tv) { - this.tv = tv; - } - @Override public void run() { if (this.tv.autoAdvance == null) return; diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java index 56db4c7e..b02f2d17 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java @@ -2,13 +2,12 @@ package com.eu.habbo.threading.runnables.freeze; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class FreezeClearEffects implements Runnable { private final Habbo habbo; - public FreezeClearEffects(Habbo habbo) { - this.habbo = habbo; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index c8ba4612..dde9430e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -10,17 +10,15 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@AllArgsConstructor class FreezeHandleSnowballExplosion implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(FreezeHandleSnowballExplosion.class); private final FreezeThrowSnowball thrownData; - public FreezeHandleSnowballExplosion(FreezeThrowSnowball thrownData) { - this.thrownData = thrownData; - } @Override public void run() { @@ -75,8 +73,7 @@ class FreezeHandleSnowballExplosion implements Runnable { habbos.addAll(this.thrownData.room.getHabbosAt(freezeTile.getX(), freezeTile.getY())); for (Habbo habbo : habbos) { - if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getGamePlayer() instanceof FreezeGamePlayer) { - FreezeGamePlayer hPlayer = (FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer(); + if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getGamePlayer() instanceof FreezeGamePlayer hPlayer) { if (!hPlayer.canGetFrozen()) continue; @@ -92,7 +89,7 @@ class FreezeHandleSnowballExplosion implements Runnable { } } } - } else if (freezeTile instanceof InteractionFreezeBlock) { + } else { if (freezeTile.getExtradata().equalsIgnoreCase("0")) { game.explodeBox((InteractionFreezeBlock) freezeTile, distance * 100); player.addScore(FreezeGame.DESTROY_BLOCK_POINTS); @@ -104,7 +101,7 @@ class FreezeHandleSnowballExplosion implements Runnable { Emulator.getThreading().run(new FreezeResetExplosionTiles(freezeTiles, this.thrownData.room), 1000); } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java index 80b06f71..b81932ac 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; +import lombok.AllArgsConstructor; +@AllArgsConstructor class FreezeResetExplosionTiles implements Runnable { private final THashSet tiles; private final Room room; - public FreezeResetExplosionTiles(THashSet tiles, Room room) { - this.tiles = tiles; - this.room = room; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java b/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java index f1e903e7..fe8124ab 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java +++ b/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java @@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class GameTimer implements Runnable { private final InteractionGameTimer timer; - public GameTimer(InteractionGameTimer timer) { - this.timer = timer; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java index 15ac8316..da74c398 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java @@ -6,18 +6,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.HabboItemNewState; +import lombok.AllArgsConstructor; +@AllArgsConstructor class HopperActionFive implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public HopperActionFive(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } - @Override public void run() { this.client.getHabbo().getRoomUnit().isTeleporting = false; diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java index 2938a6d7..d0584b75 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java @@ -4,18 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +@AllArgsConstructor class HopperActionFour implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public HopperActionFour(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } - @Override public void run() { this.currentTeleport.setExtradata("1"); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java index f05c5545..88df9fa3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java @@ -7,18 +7,14 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class HopperActionOne implements Runnable { private final HabboItem teleportOne; private final Room room; private final GameClient client; - public HopperActionOne(HabboItem teleportOne, Room room, GameClient client) { - this.teleportOne = teleportOne; - this.room = room; - this.client = client; - } - @Override public void run() { //this.client.getHabbo().getRoomUnit().setGoalLocation(this.teleportOne.getX(), this.teleportOne.getY()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java index ebb6d41c..2af1f7f6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java @@ -10,7 +10,9 @@ import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; +import lombok.AllArgsConstructor; +@AllArgsConstructor class HopperActionThree implements Runnable { private final HabboItem teleportOne; private final Room room; @@ -18,13 +20,6 @@ class HopperActionThree implements Runnable { private final int targetRoomId; private final int targetItemId; - public HopperActionThree(HabboItem teleportOne, Room room, GameClient client, int targetRoomId, int targetItemId) { - this.teleportOne = teleportOne; - this.room = room; - this.client = client; - this.targetRoomId = targetRoomId; - this.targetItemId = targetItemId; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index 97b04dca..65798cbc 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -4,27 +4,22 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor class HopperActionTwo implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(HopperActionTwo.class); private final HabboItem teleportOne; private final Room room; private final GameClient client; - - public HopperActionTwo(HabboItem teleportOne, Room room, GameClient client) { - this.teleportOne = teleportOne; - this.room = room; - this.client = client; - } - + @Override public void run() { this.teleportOne.setExtradata("2"); @@ -43,7 +38,7 @@ class HopperActionTwo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } if (targetRoomId != 0 && targetItemId != 0) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index 67268db8..0fa0b246 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -3,24 +3,24 @@ package com.eu.habbo.threading.runnables.teleport; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; -import com.eu.habbo.habbohotel.rooms.*; +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.threading.runnables.HabboItemNewState; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; +import lombok.AllArgsConstructor; import java.util.ArrayList; import java.util.List; +@AllArgsConstructor class TeleportActionFive implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionFive(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } + @Override public void run() { @@ -41,13 +41,11 @@ class TeleportActionFive implements Runnable { RoomTile tile = this.room.getLayout().getTileInFront(currentLocation, this.currentTeleport.getRotation()); if (tile != null) { - List onSuccess = new ArrayList(); + List onSuccess = new ArrayList<>(); onSuccess.add(() -> { unit.setCanLeaveRoomByDoor(true); - Emulator.getThreading().run(() -> { - unit.isLeavingTeleporter = false; - }, 300); + Emulator.getThreading().run(() -> unit.isLeavingTeleporter = false, 300); }); unit.setCanLeaveRoomByDoor(false); @@ -64,7 +62,7 @@ class TeleportActionFive implements Runnable { HabboItem teleportTile = this.room.getTopItemAt(unit.getX(), unit.getY()); - if (teleportTile != null && teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { + if (teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { try { teleportTile.onWalkOn(unit, this.room, new Object[]{}); } catch (Exception e) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java index 6379fa98..9cc6b86b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java @@ -4,17 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +@AllArgsConstructor class TeleportActionFour implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionFour(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } @Override public void run() { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java index 730b7c69..03128e18 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java @@ -8,18 +8,14 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import lombok.AllArgsConstructor; +@AllArgsConstructor public class TeleportActionOne implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionOne(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } - @Override public void run() { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index ad3cee43..1083f9af 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -9,18 +9,14 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; +import lombok.AllArgsConstructor; +@AllArgsConstructor class TeleportActionThree implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionThree(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } - @Override public void run() { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index 332d9fb2..377a4812 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -9,26 +9,22 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +@Slf4j +@AllArgsConstructor class TeleportActionTwo implements Runnable { - private static final Logger LOGGER = LoggerFactory.getLogger(TeleportActionTwo.class); private final HabboItem currentTeleport; private final Room room; private final GameClient client; - - public TeleportActionTwo(HabboItem currentTeleport, Room room, GameClient client) { - this.currentTeleport = currentTeleport; - this.client = client; - this.room = room; - } + @Override public void run() { @@ -76,7 +72,7 @@ class TeleportActionTwo implements Runnable { } } } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); + log.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/util/HexUtils.java b/src/main/java/com/eu/habbo/util/HexUtils.java index 2e5bccb4..a2145324 100644 --- a/src/main/java/com/eu/habbo/util/HexUtils.java +++ b/src/main/java/com/eu/habbo/util/HexUtils.java @@ -35,7 +35,7 @@ public class HexUtils { sb.append(Integer.toHexString(r.nextInt())); } - return sb.toString().substring(0, length); + return sb.substring(0, length); } } diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java b/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java deleted file mode 100644 index 2d1760f5..00000000 --- a/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.eu.habbo.util.callback; - -/* public class HTTPPostError implements Runnable -{ - public Throwable stackTrace; - - public HTTPPostError(Throwable stackTrace) - { - this.stackTrace = stackTrace; - } - - private void sendPost() - { - try - { - if (!Emulator.isReady) - return; - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - this.stackTrace.printStackTrace(pw); - String url = "http://arcturus.pw/callback/error.php"; - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - con.setRequestMethod("POST"); - con.setRequestProperty("User-Agent", "arcturus"); - String urlParameters = "errors=1&version=" + Emulator.version + "&stacktrace=" + sw.toString() + "&users=" + Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "&rooms=" + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "&username=" + Emulator.getConfig().getValue("username"); - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(urlParameters); - wr.flush(); - wr.close(); - pw.close(); - sw.close(); - - int responseCode = con.getResponseCode(); - con.disconnect(); - } - catch (Exception e) - { - } - } - - @Override - public void run() - { - try - { - this.sendPost(); - } - catch (Exception e) - { - } - } -} */ diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPPostStatus.java b/src/main/java/com/eu/habbo/util/callback/HTTPPostStatus.java deleted file mode 100644 index fec700e5..00000000 --- a/src/main/java/com/eu/habbo/util/callback/HTTPPostStatus.java +++ /dev/null @@ -1,40 +0,0 @@ -/* package com.eu.habbo.util.callback; - -import com.eu.habbo.Emulator; - -import java.io.DataOutputStream; -import java.net.HttpURLConnection; -import java.net.URL; - - public class HTTPPostStatus implements Runnable -{ - private void sendPost() throws Exception - { - String url = "http://arcturus.pw/callback/status.php"; - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - con.setRequestMethod("POST"); - con.setRequestProperty("User-Agent", "arcturus"); - String urlParameters = "users=" + Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "&rooms=" + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "&username=" + Emulator.getConfig().getValue("username") + "&version=" + Emulator.version; - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(urlParameters); - wr.flush(); - wr.close(); - int responseCode = con.getResponseCode(); - con.disconnect(); - } - - @Override - public void run() - { - try - { - this.sendPost(); - } - catch (Exception e) - { - } - } -} -*/ \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java b/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java deleted file mode 100644 index 8ac8ef34..00000000 --- a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.eu.habbo.util.callback; - -/* public class HTTPVersionCheck implements Runnable -{ - private void sendPost() - { - try - { - if (!Emulator.isReady) - return; - - String url = "http://arcturus.pw/callback/check.php"; - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - con.setRequestMethod("POST"); - con.setRequestProperty("User-Agent", "arcturus"); - String urlParameters = "&major=" + Emulator.MAJOR + "&minor=" + Emulator.MINOR + "&build=" + Emulator.BUILD + "&version=" + Emulator.version + "&users=" + Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "&rooms=" + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "&username=" + Emulator.getConfig().getValue("username"); - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(urlParameters); - wr.flush(); - - int responseCode = con.getResponseCode(); - if (responseCode == 102) - { - StringBuilder text = new StringBuilder(); - InputStreamReader in = new InputStreamReader((InputStream) con.getContent()); - BufferedReader buff = new BufferedReader(in); - String line; - do { - line = buff.readLine(); - - if (line != null) - { - text.append(line).append("\n"); - } - } while (line != null); - buff.close(); - in.close(); - - logger.info(text.toString()); - Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new GenericAlertComposer(text.toString())); - } - wr.close(); - con.disconnect(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void run() - { - - - - - - - - - - } - -} - */ diff --git a/src/main/java/com/eu/habbo/util/figure/FigureUtil.java b/src/main/java/com/eu/habbo/util/figure/FigureUtil.java index efbb779a..14117676 100644 --- a/src/main/java/com/eu/habbo/util/figure/FigureUtil.java +++ b/src/main/java/com/eu/habbo/util/figure/FigureUtil.java @@ -33,7 +33,7 @@ public class FigureUtil { String[] pieces = set.split("-"); try { - if (pieces.length >= 2 && blacklist.contains(Integer.valueOf(pieces[1]))) { + if (pieces.length >= 2 && blacklist.contains(Integer.parseInt(pieces[1]))) { return true; } } catch (NumberFormatException ignored) { diff --git a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java index 616f6978..2f3c3f22 100644 --- a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java +++ b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.GuildPart; import com.eu.habbo.habbohotel.guilds.GuildPartType; import gnu.trove.map.hash.THashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import javax.imageio.ImageIO; import java.awt.*; @@ -17,18 +16,17 @@ import java.awt.image.WritableRaster; import java.io.File; import java.util.Map; +@Slf4j public class BadgeImager { - - private static final Logger LOGGER = LoggerFactory.getLogger(BadgeImager.class); - + final THashMap cachedImages = new THashMap<>(); public BadgeImager() { if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { if (this.reload()) { - LOGGER.info("Badge Imager -> Loaded!"); + log.info("Badge Imager -> Loaded!"); } else { - LOGGER.warn("Badge Imager -> Disabled! Please check your configuration!"); + log.warn("Badge Imager -> Disabled! Please check your configuration!"); } } } @@ -69,7 +67,7 @@ public class BadgeImager { public static Color colorFromHexString(String colorStr) { try { return new Color( - Integer.valueOf(colorStr, 16)); + Integer.parseInt(colorStr, 16)); } catch (Exception e) { return new Color(0xffffff); } @@ -117,7 +115,7 @@ public class BadgeImager { public synchronized boolean reload() { File file = new File(Emulator.getConfig().getValue("imager.location.badgeparts")); if (!file.exists()) { - LOGGER.error("BadgeImager output folder: {} does not exist!", Emulator.getConfig().getValue("imager.location.badgeparts")); + log.error("BadgeImager output folder: {} does not exist!", Emulator.getConfig().getValue("imager.location.badgeparts")); return false; } @@ -126,26 +124,26 @@ public class BadgeImager { for (Map.Entry> set : Emulator.getGameEnvironment().getGuildManager().getGuildParts().entrySet()) { if (set.getKey() == GuildPartType.SYMBOL || set.getKey() == GuildPartType.BASE) { for (Map.Entry map : set.getValue().entrySet()) { - if (!map.getValue().valueA.isEmpty()) { + if (!map.getValue().getValueA().isEmpty()) { try { - this.cachedImages.put(map.getValue().valueA, ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().valueA.replace(".gif", ".png")))); + this.cachedImages.put(map.getValue().getValueA(), ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().getValueA().replace(".gif", ".png")))); } catch (Exception e) { - LOGGER.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueA.replace(".gif", ".png"))); + log.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().getValueA().replace(".gif", ".png"))); } } - if (!map.getValue().valueB.isEmpty()) { + if (!map.getValue().getValueB().isEmpty()) { try { - this.cachedImages.put(map.getValue().valueB, ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().valueB.replace(".gif", ".png")))); + this.cachedImages.put(map.getValue().getValueB(), ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().getValueB().replace(".gif", ".png")))); } catch (Exception e) { - LOGGER.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueB.replace(".gif", ".png"))); + log.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().getValueB().replace(".gif", ".png"))); } } } } } } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return false; } @@ -161,7 +159,7 @@ public class BadgeImager { if (outputFile.exists()) return; } catch (Exception e) { - LOGGER.error("Caught exception", e); + log.error("Caught exception", e); return; } @@ -191,9 +189,9 @@ public class BadgeImager { continue; String type = s.charAt(0) + ""; - int id = Integer.valueOf(s.substring(1, 4)); - int c = Integer.valueOf(s.substring(4, 6)); - int position = Integer.valueOf(s.substring(6)); + int id = Integer.parseInt(s.substring(1, 4)); + int c = Integer.parseInt(s.substring(4, 6)); + int position = Integer.parseInt(s.substring(6)); GuildPart part; GuildPart color = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.BASE_COLOR, c); @@ -206,7 +204,7 @@ public class BadgeImager { if (part == null) continue; - BufferedImage imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.valueA)); + BufferedImage imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.getValueA())); Point point; @@ -217,13 +215,13 @@ public class BadgeImager { point = getPoint(image, imagePart, position); - recolor(imagePart, colorFromHexString(color.valueA)); + recolor(imagePart, colorFromHexString(color.getValueA())); graphics.drawImage(imagePart, point.x, point.y, null); } - if (!part.valueB.isEmpty()) { - imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.valueB)); + if (!part.getValueB().isEmpty()) { + imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.getValueB())); if (imagePart != null) { if (imagePart.getColorModel().getPixelSize() < 32) { @@ -239,7 +237,7 @@ public class BadgeImager { try { ImageIO.write(image, "PNG", outputFile); } catch (Exception e) { - LOGGER.error("Failed to generate guild badge: {}.png Make sure the output folder exists and is writable!", outputFile); + log.error("Failed to generate guild badge: {}.png Make sure the output folder exists and is writable!", outputFile); } graphics.dispose();