From d145601c0a345807488a0702b256e0327586a7dc Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 23 May 2019 19:16:30 +0100 Subject: [PATCH 001/112] Start 2.1.0 --- src/main/java/com/eu/habbo/Emulator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 04cafd27..4c364d06 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -38,15 +38,15 @@ public final class Emulator public final static int MAJOR = 2; - public final static int MINOR = 0; + public final static int MINOR = 1; public final static int BUILD = 0; - public final static String PREVIEW = ""; + public final static String PREVIEW = "RC-1"; - public static final String version = "Arcturus Morningstar"+ " " + MAJOR + "." + MINOR + "." + BUILD; + public static final String version = "Arcturus Morningstar"+ " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; public static String build = ""; @@ -164,7 +164,7 @@ public final class Emulator @Override public void run() { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a Release Candidate for 2.0.0, if you find any bugs please place them on our git repository."); + Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a Release Candidate for 2.1.0, if you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); System.out.println("Waiting for commands: "); From 2e66d305d4c926a08210ef4034b5b273266f2088 Mon Sep 17 00:00:00 2001 From: Beny Date: Thu, 23 May 2019 23:57:22 +0100 Subject: [PATCH 002/112] Possible database leaks fixed --- .../habbohotel/catalog/CatalogManager.java | 61 ++++++++++--------- .../habbo/habbohotel/catalog/CatalogPage.java | 4 ++ .../catalog/layouts/CatalogRootLayout.java | 5 ++ .../catalog/marketplace/MarketPlace.java | 32 +++++----- .../catalog/marketplace/MarketPlaceOffer.java | 6 +- .../habbohotel/guilds/forums/ForumThread.java | 24 ++++---- .../guilds/forums/ForumThreadComment.java | 9 +-- .../habbohotel/modtool/ModToolManager.java | 24 ++++++-- .../eu/habbo/habbohotel/pets/PetManager.java | 44 +++++++++++-- .../com/eu/habbo/habbohotel/rooms/Room.java | 42 ++++++++----- .../guilds/forums/GuildForumDataComposer.java | 2 +- .../guilds/forums/GuildForumListComposer.java | 6 +- 12 files changed, 166 insertions(+), 93 deletions(-) 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 edaedd7e..6acfe1c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -212,27 +212,20 @@ public class CatalogManager { Emulator.getPluginManager().fireEvent(new EmulatorLoadCatalogManagerEvent()); - try - { - this.loadLimitedNumbers(); - this.loadCatalogPages(); - this.loadCatalogFeaturedPages(); - this.loadCatalogItems(); - this.loadClubOffers(); - this.loadTargetOffers(); - this.loadVouchers(); - this.loadClothing(); - this.loadRecycler(); - this.loadGiftWrappers(); - this.loadCalendarRewards(); - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } + this.loadLimitedNumbers(); + this.loadCatalogPages(); + this.loadCatalogFeaturedPages(); + this.loadCatalogItems(); + this.loadClubOffers(); + this.loadTargetOffers(); + this.loadVouchers(); + this.loadClothing(); + this.loadRecycler(); + this.loadGiftWrappers(); + this.loadCalendarRewards(); } - private synchronized void loadLimitedNumbers() throws SQLException + private synchronized void loadLimitedNumbers() { this.limitedNumbers.clear(); @@ -270,12 +263,12 @@ public class CatalogManager } - private synchronized void loadCatalogPages() throws SQLException + private synchronized void loadCatalogPages() { this.catalogPages.clear(); final THashMap pages = new THashMap<>(); - pages.put(-1, new CatalogRootLayout(null)); + pages.put(-1, new CatalogRootLayout()); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_pages ORDER BY parent_id, id")) { try (ResultSet set = statement.executeQuery()) @@ -338,7 +331,7 @@ public class CatalogManager } - private synchronized void loadCatalogFeaturedPages() throws SQLException + private synchronized void loadCatalogFeaturedPages() { this.catalogFeaturedPages.clear(); @@ -364,7 +357,7 @@ public class CatalogManager } } - private synchronized void loadCatalogItems() throws SQLException + private synchronized void loadCatalogItems() { this.clubItems.clear(); catalogItemAmount = 0; @@ -431,7 +424,7 @@ public class CatalogManager } } - private void loadClubOffers() throws SQLException + private void loadClubOffers() { this.clubOffers.clear(); @@ -446,9 +439,13 @@ public class CatalogManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadTargetOffers() throws SQLException + private void loadTargetOffers() { synchronized (this.targetOffers) { @@ -465,11 +462,15 @@ public class CatalogManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } } - private void loadVouchers() throws SQLException + private void loadVouchers() { synchronized (this.vouchers) { @@ -482,11 +483,15 @@ public class CatalogManager this.vouchers.add(new Voucher(set)); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } } - public void loadRecycler() throws SQLException + public void loadRecycler() { synchronized (this.prizes) { @@ -520,7 +525,7 @@ public class CatalogManager } - public void loadGiftWrappers() throws SQLException + public void loadGiftWrappers() { synchronized (this.giftWrappers) { 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 640b74a4..c0e847ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -39,6 +39,10 @@ public abstract class CatalogPage implements Comparable, ISerialize private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final ArrayList included = new ArrayList<>(); + public CatalogPage() + { + } + public CatalogPage(ResultSet set) throws SQLException { if (set == null) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java index c303ef78..02c39bee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java @@ -8,6 +8,11 @@ import java.sql.SQLException; public class CatalogRootLayout extends CatalogPage { + public CatalogRootLayout() + { + super(); + } + public CatalogRootLayout(ResultSet set) throws SQLException { super(null); 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 92a79c4d..7660b824 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 @@ -368,7 +368,7 @@ public class MarketPlace } - public static void sendErrorMessage(GameClient client, int baseItemId, int offerId) throws SQLException + 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" + @@ -394,6 +394,10 @@ public class MarketPlace } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } @@ -412,24 +416,18 @@ public class MarketPlace } RequestOffersEvent.cachedResults.clear(); - try - { - client.sendResponse(new RemoveHabboItemComposer(event.item.getGiftAdjustedId())); - client.sendResponse(new InventoryRefreshComposer()); - event.item.setFromGift(false); + client.sendResponse(new RemoveHabboItemComposer(event.item.getGiftAdjustedId())); + client.sendResponse(new InventoryRefreshComposer()); - MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo()); - client.getHabbo().getInventory().addMarketplaceOffer(offer); - client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item); - item.setUserId(-1); - item.needsUpdate(true); - Emulator.getThreading().run(item); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } + event.item.setFromGift(false); + + MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo()); + client.getHabbo().getInventory().addMarketplaceOffer(offer); + client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item); + item.setUserId(-1); + item.needsUpdate(true); + Emulator.getThreading().run(item); return true; } 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 52c87d58..62985faa 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 @@ -48,7 +48,7 @@ public class MarketPlaceOffer implements Runnable } } - public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) throws SQLException + public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) { this.price = price; this.baseItem = item.getBaseItem(); @@ -76,6 +76,10 @@ public class MarketPlaceOffer implements Runnable } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } public int getOfferId() 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 4b54271a..0a308002 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 @@ -349,7 +349,7 @@ public class ForumThread implements Runnable, ISerialize { return createdThread; } - public static THashSet getByGuildId(int guildId) throws SQLException { + public static THashSet getByGuildId(int guildId) { THashSet threads = null; if(guildThreadsCache.containsKey(guildId)) { @@ -381,14 +381,15 @@ public class ForumThread implements Runnable, ISerialize { )) { statement.setInt(1, guildId); - ResultSet set = statement.executeQuery(); - while(set.next()) { - ForumThread thread = new ForumThread(set); - synchronized (threads) { - threads.add(thread); + try(ResultSet set = statement.executeQuery()) { + while (set.next()) { + ForumThread thread = new ForumThread(set); + synchronized (threads) { + threads.add(thread); + } + cacheThread(thread); } - cacheThread(thread); } } catch (SQLException e) @@ -425,11 +426,12 @@ public class ForumThread implements Runnable, ISerialize { )) { statement.setInt(1, threadId); - ResultSet set = statement.executeQuery(); - while(set.next()) { - foundThread = new ForumThread(set); - cacheThread(foundThread); + try(ResultSet set = statement.executeQuery()) { + while (set.next()) { + foundThread = new ForumThread(set); + cacheThread(foundThread); + } } } catch (SQLException 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 4db3e0fa..1e320d5f 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 @@ -57,11 +57,12 @@ public class ForumThreadComment implements Runnable, ISerialize { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM `guilds_forums_comments` WHERE `id` = ? LIMIT 1")) { statement.setInt(1, id); - ResultSet set = statement.executeQuery(); - while(set.next()) { - foundComment = new ForumThreadComment(set); - cacheComment(foundComment); + try(ResultSet set = statement.executeQuery()) { + while (set.next()) { + foundComment = new ForumThreadComment(set); + cacheComment(foundComment); + } } } catch (SQLException e) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 2ef67048..081d35b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -68,7 +68,7 @@ public class ModToolManager } } - private void loadCategory(Connection connection) throws SQLException + private void loadCategory(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM support_issue_categories")) { @@ -89,9 +89,13 @@ public class ModToolManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadPresets(Connection connection) throws SQLException + private void loadPresets(Connection connection) { synchronized (this.presets) { @@ -102,10 +106,14 @@ public class ModToolManager this.presets.get(set.getString("type")).add(set.getString("preset")); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } } - private void loadTickets(Connection connection) throws SQLException + private void loadTickets(Connection connection) { synchronized (this.tickets) { @@ -116,10 +124,14 @@ public class ModToolManager this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } } - private void loadCfhCategories(Connection connection) throws SQLException + private void loadCfhCategories(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT " + "support_cfh_topics.id, " + @@ -144,6 +156,10 @@ public class ModToolManager this.cfhCategories.get(set.getInt("support_cfh_category_id")).addTopic(new CfhTopic(set, this.getIssuePreset(set.getInt("default_sanction")))); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } public CfhTopic getCfhTopic(int topicId) 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 0125b947..a8564f34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -106,7 +106,7 @@ public class PetManager } } - private void loadRaces(Connection connection) throws SQLException + private void loadRaces(Connection connection) { this.petRaces.clear(); @@ -120,9 +120,13 @@ public class PetManager this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadPetData(Connection connection) throws SQLException + private void loadPetData(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_actions ORDER BY pet_type ASC")) { @@ -131,13 +135,17 @@ public class PetManager this.petData.put(set.getInt("pet_type"), new PetData(set)); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } this.loadPetItems(connection); this.loadPetVocals(connection); } - private void loadPetItems(Connection connection) throws SQLException + private void loadPetItems(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_items")) { @@ -169,9 +177,13 @@ public class PetManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadPetVocals(Connection connection) throws SQLException + private void loadPetVocals(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_vocals")) { @@ -206,9 +218,13 @@ public class PetManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadPetCommands(Connection connection) throws SQLException + private void loadPetCommands(Connection connection) { THashMap commandsList = new THashMap<>(); try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands_data")) @@ -218,6 +234,10 @@ public class PetManager commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) { @@ -231,9 +251,13 @@ public class PetManager } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private void loadPetBreeding(Connection connection) throws SQLException + private void loadPetBreeding(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding")) { @@ -242,6 +266,10 @@ public class PetManager this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) { @@ -261,6 +289,10 @@ public class PetManager this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } public THashSet getBreeds(String petName) 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 0aa1fd87..e1a292db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -242,17 +242,6 @@ public class Room implements Comparable, ISerialize, Runnable this.bannedHabbos = new TIntObjectHashMap<>(); - - - - - - - - - - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) { if(this.promoted) @@ -273,6 +262,11 @@ public class Room implements Comparable, ISerialize, Runnable this.loadBans(connection); } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } + this.tradeMode = set.getInt("trade_mode"); this.moveDiagonally = set.getString("move_diagonally").equals("1"); @@ -456,7 +450,7 @@ public class Room implements Comparable, ISerialize, Runnable } } - private synchronized void loadItems(Connection connection) throws SQLException + private synchronized void loadItems(Connection connection) { this.roomItems.clear(); @@ -471,9 +465,13 @@ public class Room implements Comparable, ISerialize, Runnable } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private synchronized void loadWiredData(Connection connection) throws SQLException + private synchronized void loadWiredData(Connection connection) { try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) { @@ -499,13 +497,17 @@ public class Room implements Comparable, ISerialize, Runnable } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - private synchronized void loadBots(Connection connection) throws SQLException + private synchronized void loadBots(Connection connection) { this.currentBots.clear(); @@ -550,7 +552,7 @@ public class Room implements Comparable, ISerialize, Runnable } } - private synchronized void loadPets(Connection connection) throws SQLException + private synchronized void loadPets(Connection connection) { this.currentPets.clear(); @@ -591,9 +593,13 @@ public class Room implements Comparable, ISerialize, Runnable } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } - private synchronized void loadWordFilter(Connection connection) throws SQLException + private synchronized void loadWordFilter(Connection connection) { this.wordFilterWords.clear(); @@ -608,6 +614,10 @@ public class Room implements Comparable, ISerialize, Runnable } } } + catch (SQLException e) + { + Emulator.getLogging().logSQLException(e); + } } public void updateTile(RoomTile tile) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java index 7fb4d878..fc8370e2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java @@ -93,7 +93,7 @@ public class GuildForumDataComposer extends MessageComposer { return this.response; } - public static void serializeForumData(ServerMessage response, Guild guild, Habbo habbo) throws SQLException { + public static void serializeForumData(ServerMessage response, Guild guild, Habbo habbo) { final THashSet forumThreads = ForumThread.getByGuildId(guild.getId()); int lastSeenAt = 0; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java index c885547d..a4d7a8ae 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java @@ -47,11 +47,7 @@ public class GuildForumListComposer extends MessageComposer { if(!it.hasNext()) break; - try { - GuildForumDataComposer.serializeForumData(this.response, it.next(), habbo); - } catch (SQLException e) { - return new ConnectionErrorComposer(500).compose(); - } + GuildForumDataComposer.serializeForumData(this.response, it.next(), habbo); } return this.response; From 6999db4542534f590e413b9c2b181ab3b3fa3646 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 09:51:47 +0100 Subject: [PATCH 003/112] Updated netty. Should fix the "event executor terminated" error --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 74543bbf..a8a1dc64 100644 --- a/pom.xml +++ b/pom.xml @@ -88,27 +88,27 @@ io.netty netty-all - 4.1.24.Final + 4.1.36.Final io.netty netty-codec-http - 4.1.24.Final + 4.1.36.Final compile io.netty netty-codec-http2 - 4.1.24.Final + 4.1.36.Final compile io.netty netty-handler - 4.1.24.Final + 4.1.36.Final compile From 91170650931ed40585bcabf08feac1b095385430 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 11:36:17 +0100 Subject: [PATCH 004/112] Optimization on wired teleport --- .../wired/effects/WiredEffectTeleport.java | 16 ---------------- .../threading/runnables/RoomUnitTeleport.java | 8 ++++++++ 2 files changed, 8 insertions(+), 16 deletions(-) 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 c7559458..6e66c93d 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 @@ -150,22 +150,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect } 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 Runnable() { - @Override - public void run() { - try { - if(roomUnit == null || roomUnit.getRoom() == null) - return; - - HabboItem topItem = room.getTopItemAt(roomUnit.getX(), roomUnit.getY()); - if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile(topItem.getX(), topItem.getY()))) { - topItem.onWalkOn(roomUnit, room, new Object[]{}); - } - } catch (Exception e) { - } - } - }, WiredHandler.TELEPORT_DELAY); } @Override 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 eec23e80..df10d433 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -62,5 +62,13 @@ public class RoomUnitTeleport implements Runnable this.room.sendComposer(teleportMessage); this.room.updateHabbosAt(t.x, t.y); + + 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[]{}); + } catch (Exception e) { + } + } } } From 4caedc516b0acd5c2403aa19299850949b201688 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 11:51:41 +0100 Subject: [PATCH 005/112] Reset state on creation for special interactions --- .../habbo/habbohotel/items/interactions/InteractionCannon.java | 2 ++ .../habbohotel/items/interactions/InteractionEffectGiver.java | 2 ++ .../habbo/habbohotel/items/interactions/InteractionFXBox.java | 2 ++ .../habbohotel/items/interactions/InteractionGuildGate.java | 2 ++ .../habbohotel/items/interactions/InteractionHabboClubGate.java | 2 ++ .../habbo/habbohotel/items/interactions/InteractionHopper.java | 2 ++ .../habbohotel/items/interactions/InteractionObstacle.java | 2 ++ .../habbohotel/items/interactions/InteractionOneWayGate.java | 2 ++ .../habbo/habbohotel/items/interactions/InteractionPetToy.java | 2 ++ .../habbohotel/items/interactions/InteractionPressurePlate.java | 2 ++ .../habbohotel/items/interactions/InteractionPushable.java | 2 ++ .../habbo/habbohotel/items/interactions/InteractionRoller.java | 2 ++ .../habbohotel/items/interactions/InteractionTeleport.java | 2 ++ .../habbo/habbohotel/items/interactions/InteractionWired.java | 2 ++ .../items/interactions/games/InteractionGameScoreboard.java | 2 ++ .../games/battlebanzai/InteractionBattleBanzaiSphere.java | 2 ++ .../games/battlebanzai/InteractionBattleBanzaiTeleporter.java | 2 ++ .../games/battlebanzai/InteractionBattleBanzaiTile.java | 2 ++ .../items/interactions/games/freeze/InteractionFreezeBlock.java | 2 ++ .../interactions/games/freeze/InteractionFreezeExitTile.java | 2 ++ .../items/interactions/games/freeze/InteractionFreezeTile.java | 2 ++ 21 files changed, 42 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java index b7070ec4..bde3b555 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java @@ -22,11 +22,13 @@ public class InteractionCannon extends HabboItem public InteractionCannon(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionCannon(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 fcaf8e3c..30672f87 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 @@ -16,11 +16,13 @@ public class InteractionEffectGiver extends InteractionDefault public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 5b3de90a..ff235711 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 @@ -17,11 +17,13 @@ public class InteractionFXBox extends InteractionDefault public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java index ed4f241d..14bfe977 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java @@ -17,11 +17,13 @@ public class InteractionGuildGate extends InteractionGuildFurni public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionGuildGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java index 22262bb1..b980c8be 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java @@ -17,11 +17,13 @@ public class InteractionHabboClubGate extends InteractionGate public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 8d87ccea..d875904e 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 @@ -18,11 +18,13 @@ public class InteractionHopper extends HabboItem public InteractionHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 8d65b93c..069cf12b 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 @@ -24,11 +24,13 @@ public class InteractionObstacle extends HabboItem public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 a1c75eb9..01bb9101 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 @@ -23,11 +23,13 @@ public class InteractionOneWayGate extends HabboItem public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionOneWayGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java index f3480976..d7ed49e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java @@ -19,11 +19,13 @@ public class InteractionPetToy extends InteractionDefault public InteractionPetToy(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionPetToy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 276fb788..320d1b8a 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 @@ -18,11 +18,13 @@ public class InteractionPressurePlate extends HabboItem public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java index ce249088..4fe2a4f1 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 @@ -18,11 +18,13 @@ public abstract class InteractionPushable extends InteractionDefault { public InteractionPushable(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionPushable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java index 0bc1b7fb..0eb24d07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java @@ -21,11 +21,13 @@ public class InteractionRoller extends HabboItem public InteractionRoller(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionRoller(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 e2648655..40ac0a73 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 @@ -30,12 +30,14 @@ public class InteractionTeleport extends HabboItem { super(set, baseItem); walkable = baseItem.allowWalk(); + this.setExtradata("0"); } public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); walkable = item.allowWalk(); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index d08f47c2..5e01f723 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 @@ -20,11 +20,13 @@ public abstract class InteractionWired extends HabboItem InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java index cfad891b..a418d9ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java @@ -13,11 +13,13 @@ public abstract class InteractionGameScoreboard extends InteractionGameTeamItem protected InteractionGameScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); + this.setExtradata("0"); } protected InteractionGameScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java index 1bf15a3d..b1bafc2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java @@ -14,11 +14,13 @@ public class InteractionBattleBanzaiSphere extends HabboItem public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionBattleBanzaiSphere(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index a49b0eff..d88b9603 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -19,11 +19,13 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionBattleBanzaiTeleporter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 ac5525fa..f955e4cc 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 @@ -21,11 +21,13 @@ public class InteractionBattleBanzaiTile extends HabboItem public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionBattleBanzaiTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 0b753421..a1c97f8b 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 @@ -22,11 +22,13 @@ public class InteractionFreezeBlock extends HabboItem public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionFreezeBlock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java index db721966..0ca61680 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java @@ -14,11 +14,13 @@ public class InteractionFreezeExitTile extends HabboItem public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionFreezeExitTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override 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 7f795c76..5f7b3de4 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 @@ -20,11 +20,13 @@ public class InteractionFreezeTile extends HabboItem public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.setExtradata("0"); } public InteractionFreezeTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); } @Override From ca3cdb8bc7a2079df73dc6b4d3335b6f7b33597c Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 11:58:46 +0100 Subject: [PATCH 006/112] Fix banzai game not ending on all tiles locked --- .../eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java | 1 + 1 file changed, 1 insertion(+) 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 97850d70..b59e0be7 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 @@ -253,6 +253,7 @@ public class BattleBanzaiGame extends Game private synchronized void resetMap() { + this.tileCount = 0; for (HabboItem item : this.room.getFloorItems()) { if (item instanceof InteractionBattleBanzaiTile) From f89a0b318dc1297c0469d8d8f88f1b45f691959e Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 12:12:22 +0100 Subject: [PATCH 007/112] Fix timers running twice --- .../games/InteractionGameTimer.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) 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 6fec1c99..b87bf269 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 @@ -29,6 +29,7 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable private int timeNow = 0; private boolean isRunning = false; private boolean isPaused = false; + private boolean threadActive = false; public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException { @@ -59,15 +60,20 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable super.run(); } - if(this.getRoomId() == 0) + if(this.getRoomId() == 0) { + this.threadActive = false; return; + } Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null || !this.isRunning || this.isPaused) + if(room == null || !this.isRunning || this.isPaused) { + this.threadActive = false; return; + } if(this.timeNow > 0) { + this.threadActive = true; Emulator.getThreading().run(this, 1000); this.timeNow--; room.updateItem(this); @@ -75,6 +81,7 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable else { this.isRunning = false; this.isPaused = false; + this.threadActive = false; endGamesIfLastTimer(room); } } @@ -178,7 +185,10 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable room.updateItem(this); WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { }); - Emulator.getThreading().run(this); + if(!this.threadActive) { + this.threadActive = true; + Emulator.getThreading().run(this); + } } else if(client != null) { @@ -217,7 +227,11 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable this.isRunning = true; timeNow = this.baseTime; room.updateItem(this); - Emulator.getThreading().run(this); + + if(!this.threadActive) { + this.threadActive = true; + Emulator.getThreading().run(this); + } } } @@ -233,7 +247,11 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable this.isRunning = true; timeNow = this.baseTime; room.updateItem(this); - Emulator.getThreading().run(this); + + if(!this.threadActive) { + this.threadActive = true; + Emulator.getThreading().run(this); + } } break; From 0c05af80c2907cc2bdaeeb1c7ada5162ceab09f1 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 24 May 2019 23:11:18 +0100 Subject: [PATCH 008/112] Added walking onto InteractionInformationTerminal --- .../interactions/InteractionInformationTerminal.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 8a11945f..e54442b0 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 @@ -3,6 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; import gnu.trove.map.hash.THashMap; @@ -36,4 +38,14 @@ public class InteractionInformationTerminal extends InteractionCustomValues client.sendResponse(new NuxAlertComposer(this.values.get("internalLink"))); } } + + @Override + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalk(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if(habbo != null && this.values.containsKey("internalLink")) { + habbo.getClient().sendResponse(new NuxAlertComposer(this.values.get("internalLink"))); + } + } } From c38f689e393efe73dbbf9b24ee884dec9fbdbb0c Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sat, 25 May 2019 00:26:58 +0100 Subject: [PATCH 009/112] Fixed deleting photos. --- .../habbo/messages/incoming/rooms/items/PostItDeleteEvent.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java index 18f46d0f..00770fce 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionExternalImage; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; @@ -22,7 +23,7 @@ public class PostItDeleteEvent extends MessageHandler HabboItem item = room.getHabboItem(itemId); - if (item instanceof InteractionPostIt) + if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId() || room.isOwner(this.client.getHabbo())) { From 40f546e3fdbefa043b4b4198a8015a6adc35e8d7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 25 May 2019 11:24:26 +0300 Subject: [PATCH 010/112] Fix NullPointerException in TraxManager --- src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 06d01baf..5387e341 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -23,7 +23,7 @@ public class TraxManager implements Disposable private final Room room; private final List songs = new ArrayList<>(0); private int totalLength = 0; - private int startedTimestamp; + private int startedTimestamp = 0; private InteractionMusicDisc currentlyPlaying = null; private int playingIndex = 0; @@ -70,7 +70,7 @@ public class TraxManager implements Disposable //restart } - if (Emulator.getIntUnixTimestamp() >= this.startedTimestamp + this.currentSong().getLength()) + if (this.currentSong() != null && Emulator.getIntUnixTimestamp() >= this.startedTimestamp + this.currentSong().getLength()) { this.play((this.playingIndex + 1) % this.songs.size()); } From 3c9a81d0649ed17d7c1800a4c4ac12afe211139d Mon Sep 17 00:00:00 2001 From: Beny Date: Sat, 25 May 2019 13:51:51 +0100 Subject: [PATCH 011/112] Removed unnecessary NuxAlertComposer from InteractionInformationTerminal. Client side does it. --- .../interactions/InteractionInformationTerminal.java | 9 --------- 1 file changed, 9 deletions(-) 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 e54442b0..f69be678 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 @@ -30,15 +30,6 @@ public class InteractionInformationTerminal extends InteractionCustomValues super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - - if(this.values.containsKey("internalLink")) { - client.sendResponse(new NuxAlertComposer(this.values.get("internalLink"))); - } - } - @Override public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalk(roomUnit, room, objects); From ab65865d734a9db0863c81deeedd431650cccda0 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 19:27:11 +0300 Subject: [PATCH 012/112] Fix NullPointerException in RedeemClothingEvent --- .../messages/incoming/rooms/items/RedeemClothingEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index 612360cf..99c40950 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -29,7 +29,7 @@ public class RedeemClothingEvent extends MessageHandler { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) + if(item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { if(item instanceof InteractionClothing) { From 8dda7e811104f521bdf5b9911a21e51a24842562 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 19:28:51 +0300 Subject: [PATCH 013/112] Fix NullPointerException in Banzai refreshCounters --- .../habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java | 2 ++ 1 file changed, 2 insertions(+) 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 b59e0be7..4d4c57e5 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 @@ -405,6 +405,8 @@ public class BattleBanzaiGame extends Game public void refreshCounters(GameTeamColors teamColors) { + if (!this.teams.containsKey(teamColors)) return; + int totalScore = this.teams.get(teamColors).getTotalScore(); THashMap scoreBoards = this.room.getRoomSpecialTypes().getBattleBanzaiScoreboards(teamColors); From 6caadebe3303039be81fd6a9d52e8cfa8e22a53b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 19:31:14 +0300 Subject: [PATCH 014/112] Fix NullPointerException in RoomUnit canOverrideTile --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 2 ++ 1 file changed, 2 insertions(+) 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 5fea11e4..f6afd05c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -806,6 +806,8 @@ public class RoomUnit } public boolean canOverrideTile(RoomTile tile) { + if (tile == null || room == null || room.getLayout() == null) return false; + int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1; return this.overridableTiles.contains(tileIndex); } From 811041a2112fa17b65695e3ff493c8d281899a77 Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 17:36:27 +0100 Subject: [PATCH 015/112] Added animation delay to WiredEffectTeleport --- .../items/interactions/wired/effects/WiredEffectTeleport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6e66c93d..dcfa0198 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 @@ -131,7 +131,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect // makes a temporary effect room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose()); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) { RoomTile alternativeTile = null; From e4b43f3c53e63772e3e318d25eec16be10ecd5f7 Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 17:36:54 +0100 Subject: [PATCH 016/112] Fixed all users able to modify guild furni states --- .../interactions/InteractionGuildFurni.java | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) 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 624c5b27..c5c51b9f 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 @@ -12,7 +12,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGuildFurni extends HabboItem +public class InteractionGuildFurni extends InteractionDefault { private int guildId; @@ -70,45 +70,6 @@ public class InteractionGuildFurni extends HabboItem return this.getBaseItem().allowWalk(); } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - super.onClick(client, room, objects); - - if (objects.length > 0) - { - if (objects[0] instanceof Integer && room != null) - { - if(this.getExtradata().length() == 0) - this.setExtradata("0"); - - if(this.getBaseItem().getStateCount() > 1) - { - this.setExtradata("" + (Integer.valueOf(this.getExtradata()) + 1) % this.getBaseItem().getStateCount()); - this.needsUpdate(true); - room.updateItemState(this); - } - } - } - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { - } - - @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { - super.onWalkOn(roomUnit, room, objects); - } - - @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { - super.onWalkOff(roomUnit, room, objects); - } - public int getGuildId() { return this.guildId; From f7196df08b2db509723e793741c8d41c08e1271b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 20:00:47 +0300 Subject: [PATCH 017/112] Add MusicPlayer achievement --- .../interactions/InteractionJukeBox.java | 2 +- .../habbo/habbohotel/rooms/TraxManager.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index 55bcfcbf..57fffaa4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -63,7 +63,7 @@ public class InteractionJukeBox extends HabboItem room.getTraxManager().stop(); } else { - room.getTraxManager().play(0); + room.getTraxManager().play(0, client.getHabbo()); } } } 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 5387e341..db20caac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.core.Disposable; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; @@ -26,6 +27,8 @@ public class TraxManager implements Disposable private int startedTimestamp = 0; private InteractionMusicDisc currentlyPlaying = null; private int playingIndex = 0; + private int cycleStartedTimestamp = 0; + private Habbo starter = null; private boolean disposed = false; @@ -78,6 +81,11 @@ public class TraxManager implements Disposable } public void play(int index) + { + this.play(index, null); + } + + public void play(int index, Habbo starter) { if (this.currentlyPlaying == null) { @@ -99,6 +107,11 @@ public class TraxManager implements Disposable this.room.setJukeBoxActive(true); this.startedTimestamp = Emulator.getIntUnixTimestamp(); this.playingIndex = index; + + if (starter != null) { + this.starter = starter; + this.cycleStartedTimestamp = Emulator.getIntUnixTimestamp(); + } } this.room.sendComposer(new JukeBoxNowPlayingMessageComposer(Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.currentlyPlaying.getSongId()), this.playingIndex, 0).compose()); @@ -111,9 +124,15 @@ public class TraxManager implements Disposable public void stop() { + if (this.starter != null && this.cycleStartedTimestamp > 0) { + AchievementManager.progressAchievement(this.starter, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicPlayer"), (Emulator.getIntUnixTimestamp() - cycleStartedTimestamp) / 60); + } + this.room.setJukeBoxActive(false); this.currentlyPlaying = null; this.startedTimestamp = 0; + this.cycleStartedTimestamp = 0; + this.starter = null; this.playingIndex = 0; for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) From d1bad8ea15da9243d2a3e00bf2ef3532c79b3022 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 20:14:38 +0300 Subject: [PATCH 018/112] Make BB teleporters work like in Habbo --- .../games/battlebanzai/InteractionBattleBanzaiTeleporter.java | 2 +- .../com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index d88b9603..a3213f07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -76,7 +76,7 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem room.updateItem(target); roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), roomUnit.getY())); roomUnit.setCanWalk(false); - Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500); + Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 1000); } @Override 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 d870ce2c..3b601716 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -1,7 +1,9 @@ package com.eu.habbo.threading.runnables; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -28,6 +30,7 @@ public class BanzaiRandomTeleport implements Runnable this.toItem.setExtradata("0"); this.room.updateItem(this.item); this.room.updateItem(this.toItem); + this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8))); this.room.teleportRoomUnitToItem(this.habbo, this.toItem); } } From f774e73cf9f62404c7a59a140b87ae760f833004 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 20:25:43 +0300 Subject: [PATCH 019/112] Remove dancing status when walking on a bed or a chair --- src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 e3c3e9ed..561bf7c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -17,6 +17,7 @@ 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.outgoing.rooms.users.RoomUserDanceComposer; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -339,6 +340,11 @@ public abstract class HabboItem implements Runnable, IEventTriggers return; WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, roomUnit, room, new Object[]{this}); + + if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && roomUnit.getDanceType() != DanceType.NONE) { + roomUnit.setDanceType(DanceType.NONE); + room.sendComposer(new RoomUserDanceComposer(roomUnit).compose()); + } } @Override From 892900af33a6fd232ff66f251bac8e8641dc550f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 21:08:03 +0300 Subject: [PATCH 020/112] Make teleporters work more like in Habbo --- .../interactions/InteractionTeleport.java | 2 +- .../interactions/InteractionTeleportTile.java | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) 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 40ac0a73..bae4d4ea 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 @@ -230,7 +230,7 @@ public class InteractionTeleport extends HabboItem this.roomUnitID = -1; habbo.getRoomUnit().isTeleporting = true; - room.scheduledTasks.add(new TeleportActionOne(this, room, habbo.getClient())); + Emulator.getThreading().run(new TeleportActionOne(this, room, habbo.getClient()), 500); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java index fa646222..2ed23f67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java @@ -36,23 +36,19 @@ public class InteractionTeleportTile extends InteractionTeleport @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - if (roomUnit != null) + if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) { - RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); + Habbo habbo = room.getHabbo(roomUnit); - if (roomUnit.getGoal().equals(currentLocation) && this.canWalkOn(roomUnit, room, objects)) + if (habbo != null) { - Habbo habbo = room.getHabbo(roomUnit); + if(!canUseTeleport(habbo.getClient(), room)) + return; - if (habbo != null) + if (!habbo.getRoomUnit().isTeleporting) { - if(!canUseTeleport(habbo.getClient(), room)) - return; - - if (!habbo.getRoomUnit().isTeleporting) - { - this.startTeleport(room, habbo); - } + habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation()); + this.startTeleport(room, habbo); } } } From cf5330ae15b56b8d73eebe7ac7f159c55fccb169 Mon Sep 17 00:00:00 2001 From: Reformatter Date: Sun, 26 May 2019 21:14:53 +0300 Subject: [PATCH 021/112] Reformat --- src/main/java/com/eu/habbo/Emulator.java | 291 +- .../java/com/eu/habbo/core/CleanerThread.java | 92 +- .../java/com/eu/habbo/core/CommandLog.java | 9 +- .../eu/habbo/core/ConfigurationManager.java | 136 +- .../com/eu/habbo/core/CreditsScheduler.java | 38 +- .../java/com/eu/habbo/core/Disposable.java | 4 +- src/main/java/com/eu/habbo/core/Easter.java | 9 +- src/main/java/com/eu/habbo/core/ErrorLog.java | 18 +- src/main/java/com/eu/habbo/core/Loggable.java | 3 +- src/main/java/com/eu/habbo/core/Logging.java | 284 +- .../com/eu/habbo/core/PixelScheduler.java | 95 +- .../com/eu/habbo/core/PointsScheduler.java | 95 +- .../eu/habbo/core/RoomUserPetComposer.java | 9 +- .../java/com/eu/habbo/core/Scheduler.java | 21 +- .../java/com/eu/habbo/core/TextsManager.java | 78 +- .../core/consolecommands/ConsoleCommand.java | 50 +- .../consolecommands/ConsoleInfoCommand.java | 15 +- .../ConsoleReconnectCameraCommand.java | 9 +- .../ConsoleShutdownCommand.java | 9 +- .../consolecommands/ConsoleTestCommand.java | 14 +- .../ShowInteractionsCommand.java | 12 +- .../consolecommands/ShowRCONCommands.java | 12 +- .../java/com/eu/habbo/database/Database.java | 34 +- .../com/eu/habbo/database/DatabasePool.java | 23 +- .../eu/habbo/habbohotel/GameEnvironment.java | 103 +- .../habbohotel/achievements/Achievement.java | 44 +- .../achievements/AchievementCategories.java | 3 +- .../achievements/AchievementLevel.java | 12 +- .../achievements/AchievementManager.java | 390 +- .../achievements/TalentTrackLevel.java | 43 +- .../achievements/TalentTrackType.java | 3 +- .../com/eu/habbo/habbohotel/bots/Bot.java | 447 +-- .../eu/habbo/habbohotel/bots/BotManager.java | 187 +- .../eu/habbo/habbohotel/bots/ButlerBot.java | 69 +- .../eu/habbo/habbohotel/bots/VisitorBot.java | 46 +- .../catalog/CalendarRewardObject.java | 48 +- .../catalog/CatalogFeaturedPage.java | 47 +- .../habbo/habbohotel/catalog/CatalogItem.java | 352 +- .../catalog/CatalogLimitedConfiguration.java | 75 +- .../habbohotel/catalog/CatalogManager.java | 854 ++-- .../habbo/habbohotel/catalog/CatalogPage.java | 151 +- .../catalog/CatalogPageLayouts.java | 3 +- .../habbohotel/catalog/CatalogPageType.java | 3 +- .../habbo/habbohotel/catalog/ClothItem.java | 13 +- .../habbo/habbohotel/catalog/ClubOffer.java | 30 +- .../habbo/habbohotel/catalog/TargetOffer.java | 51 +- .../eu/habbo/habbohotel/catalog/Voucher.java | 16 +- .../catalog/layouts/BadgeDisplayLayout.java | 6 +- .../catalog/layouts/BotsLayout.java | 9 +- .../layouts/BuildersClubAddonsLayout.java | 9 +- .../layouts/BuildersClubFrontPageLayout.java | 9 +- .../layouts/BuildersClubLoyaltyLayout.java | 9 +- .../catalog/layouts/CatalogRootLayout.java | 12 +- .../catalog/layouts/ClubBuyLayout.java | 9 +- .../catalog/layouts/ClubGiftsLayout.java | 9 +- .../catalog/layouts/ColorGroupingLayout.java | 6 +- .../catalog/layouts/Default_3x3Layout.java | 6 +- .../layouts/FrontPageFeaturedLayout.java | 21 +- .../catalog/layouts/FrontpageLayout.java | 3 +- .../catalog/layouts/GuildForumLayout.java | 9 +- .../catalog/layouts/GuildFrontpageLayout.java | 9 +- .../catalog/layouts/GuildFurnitureLayout.java | 9 +- .../catalog/layouts/InfoDucketsLayout.java | 9 +- .../catalog/layouts/InfoLoyaltyLayout.java | 9 +- .../catalog/layouts/InfoPetsLayout.java | 9 +- .../catalog/layouts/InfoRentablesLayout.java | 9 +- .../catalog/layouts/LoyaltyVipBuyLayout.java | 9 +- .../catalog/layouts/MarketplaceLayout.java | 9 +- .../catalog/layouts/MarketplaceOwnItems.java | 9 +- .../layouts/PetCustomizationLayout.java | 9 +- .../catalog/layouts/Pets2Layout.java | 9 +- .../catalog/layouts/Pets3Layout.java | 9 +- .../catalog/layouts/PetsLayout.java | 9 +- .../catalog/layouts/ProductPage1Layout.java | 9 +- .../layouts/RecentPurchasesLayout.java | 6 +- .../catalog/layouts/RecyclerInfoLayout.java | 9 +- .../catalog/layouts/RecyclerLayout.java | 9 +- .../catalog/layouts/RecyclerPrizesLayout.java | 9 +- .../catalog/layouts/RoomAdsLayout.java | 9 +- .../catalog/layouts/RoomBundleLayout.java | 135 +- .../catalog/layouts/SingleBundle.java | 9 +- .../catalog/layouts/SoldLTDItemsLayout.java | 9 +- .../catalog/layouts/SpacesLayout.java | 6 +- .../catalog/layouts/TraxLayout.java | 9 +- .../catalog/layouts/TrophiesLayout.java | 6 +- .../catalog/layouts/VipBuyLayout.java | 9 +- .../catalog/marketplace/MarketPlace.java | 248 +- .../catalog/marketplace/MarketPlaceOffer.java | 222 +- .../catalog/marketplace/MarketPlaceState.java | 31 +- .../habbohotel/commands/AboutCommand.java | 22 +- .../habbohotel/commands/AlertCommand.java | 16 +- .../commands/AllowTradingCommand.java | 35 +- .../habbohotel/commands/ArcturusCommand.java | 25 +- .../habbohotel/commands/BadgeCommand.java | 55 +- .../habbo/habbohotel/commands/BanCommand.java | 47 +- .../commands/BlockAlertCommand.java | 12 +- .../habbohotel/commands/BotsCommand.java | 18 +- .../habbohotel/commands/CalendarCommand.java | 14 +- .../commands/ChangeNameCommand.java | 9 +- .../habbohotel/commands/ChatTypeCommand.java | 38 +- .../eu/habbo/habbohotel/commands/Command.java | 6 +- .../habbohotel/commands/CommandHandler.java | 333 +- .../habbohotel/commands/CommandsCommand.java | 12 +- .../commands/ConnectCameraCommand.java | 11 +- .../habbohotel/commands/ControlCommand.java | 35 +- .../habbohotel/commands/CoordsCommand.java | 39 +- .../habbohotel/commands/CreditsCommand.java | 59 +- .../habbohotel/commands/DiagonalCommand.java | 22 +- .../commands/DisconnectCommand.java | 21 +- .../habbohotel/commands/EjectAllCommand.java | 15 +- .../commands/EmptyBotsInventoryCommand.java | 38 +- .../commands/EmptyInventoryCommand.java | 40 +- .../commands/EmptyPetsInventoryCommand.java | 38 +- .../habbohotel/commands/EnableCommand.java | 44 +- .../habbohotel/commands/EventCommand.java | 23 +- .../habbohotel/commands/FacelessCommand.java | 25 +- .../habbohotel/commands/FastwalkCommand.java | 21 +- .../commands/FilterWordCommand.java | 22 +- .../commands/FreezeBotsCommand.java | 19 +- .../habbohotel/commands/FreezeCommand.java | 30 +- .../habbohotel/commands/GiftCommand.java | 41 +- .../habbohotel/commands/GiveRankCommand.java | 43 +- .../habbohotel/commands/HabnamCommand.java | 17 +- .../habbohotel/commands/HandItemCommand.java | 31 +- .../habbohotel/commands/HappyHourCommand.java | 12 +- .../habbohotel/commands/HideWiredCommand.java | 19 +- .../commands/HotelAlertCommand.java | 16 +- .../commands/HotelAlertLinkCommand.java | 17 +- .../habbohotel/commands/IPBanCommand.java | 49 +- .../habbohotel/commands/InvisibleCommand.java | 14 +- .../habbo/habbohotel/commands/LayCommand.java | 20 +- .../commands/MachineBanCommand.java | 44 +- .../habbohotel/commands/MassBadgeCommand.java | 27 +- .../commands/MassCreditsCommand.java | 27 +- .../habbohotel/commands/MassGiftCommand.java | 42 +- .../commands/MassPixelsCommand.java | 27 +- .../commands/MassPointsCommand.java | 51 +- .../habbohotel/commands/MimicCommand.java | 13 +- .../habbohotel/commands/MoonwalkCommand.java | 12 +- .../habbohotel/commands/MultiCommand.java | 9 +- .../habbohotel/commands/MuteBotsCommand.java | 11 +- .../habbohotel/commands/MuteCommand.java | 37 +- .../habbohotel/commands/MutePetsCommand.java | 11 +- .../habbohotel/commands/PetInfoCommand.java | 30 +- .../habbohotel/commands/PickallCommand.java | 15 +- .../habbohotel/commands/PixelCommand.java | 39 +- .../habbohotel/commands/PluginsCommand.java | 18 +- .../habbohotel/commands/PointsCommand.java | 59 +- .../commands/PromoteTargetOfferCommand.java | 54 +- .../habbohotel/commands/PullCommand.java | 36 +- .../habbohotel/commands/PushCommand.java | 39 +- .../habbohotel/commands/RedeemCommand.java | 63 +- .../commands/ReloadRoomCommand.java | 21 +- .../habbohotel/commands/RoomAlertCommand.java | 21 +- .../commands/RoomBundleCommand.java | 42 +- .../commands/RoomCreditsCommand.java | 25 +- .../habbohotel/commands/RoomDanceCommand.java | 29 +- .../commands/RoomEffectCommand.java | 29 +- .../habbohotel/commands/RoomGiftCommand.java | 38 +- .../habbohotel/commands/RoomItemCommand.java | 32 +- .../habbohotel/commands/RoomKickCommand.java | 26 +- .../habbohotel/commands/RoomMuteCommand.java | 12 +- .../commands/RoomPixelsCommand.java | 25 +- .../commands/RoomPointsCommand.java | 48 +- .../habbohotel/commands/SayAllCommand.java | 18 +- .../habbo/habbohotel/commands/SayCommand.java | 28 +- .../habbohotel/commands/SetMaxCommand.java | 30 +- .../habbohotel/commands/SetPollCommand.java | 40 +- .../habbohotel/commands/SetSpeedCommand.java | 25 +- .../habbohotel/commands/ShoutAllCommand.java | 18 +- .../habbohotel/commands/ShoutCommand.java | 28 +- .../habbohotel/commands/ShutdownCommand.java | 36 +- .../habbo/habbohotel/commands/SitCommand.java | 11 +- .../habbohotel/commands/SitDownCommand.java | 22 +- .../commands/StaffAlertCommand.java | 19 +- .../commands/StaffOnlineCommand.java | 46 +- .../habbohotel/commands/StalkCommand.java | 30 +- .../habbohotel/commands/SummonCommand.java | 31 +- .../commands/SummonRankCommand.java | 27 +- .../habbohotel/commands/SuperPullCommand.java | 29 +- .../habbohotel/commands/SuperbanCommand.java | 40 +- .../habbohotel/commands/TakeBadgeCommand.java | 28 +- .../habbohotel/commands/TeleportCommand.java | 30 +- .../habbohotel/commands/TestCommand.java | 275 +- .../habbohotel/commands/TransformCommand.java | 39 +- .../habbohotel/commands/TrashCommand.java | 9 +- .../habbohotel/commands/UnbanCommand.java | 23 +- .../commands/UnloadRoomCommand.java | 9 +- .../habbohotel/commands/UnmuteCommand.java | 32 +- .../commands/UpdateAchievements.java | 9 +- .../commands/UpdateBotsCommand.java | 9 +- .../commands/UpdateCatalogCommand.java | 7 +- .../commands/UpdateConfigCommand.java | 9 +- .../commands/UpdateGuildPartsCommand.java | 9 +- .../commands/UpdateHotelViewCommand.java | 9 +- .../commands/UpdateItemsCommand.java | 20 +- .../commands/UpdateNavigatorCommand.java | 9 +- .../commands/UpdatePermissionsCommand.java | 9 +- .../commands/UpdatePetDataCommand.java | 9 +- .../commands/UpdatePluginsCommand.java | 10 +- .../commands/UpdatePollsCommand.java | 9 +- .../commands/UpdateTextsCommand.java | 16 +- .../commands/UpdateWordFilterCommand.java | 9 +- .../habbohotel/commands/UserInfoCommand.java | 52 +- .../habbohotel/commands/WordQuizCommand.java | 29 +- .../habbohotel/crafting/CraftingAltar.java | 91 +- .../habbohotel/crafting/CraftingManager.java | 161 +- .../habbohotel/crafting/CraftingRecipe.java | 51 +- .../habbohotel/gameclients/GameClient.java | 94 +- .../gameclients/GameClientManager.java | 118 +- .../com/eu/habbo/habbohotel/games/Game.java | 162 +- .../eu/habbo/habbohotel/games/GamePlayer.java | 26 +- .../eu/habbo/habbohotel/games/GameState.java | 3 +- .../eu/habbo/habbohotel/games/GameTeam.java | 66 +- .../habbohotel/games/GameTeamColors.java | 15 +- .../games/battlebanzai/BattleBanzaiGame.java | 225 +- .../battlebanzai/BattleBanzaiGamePlayer.java | 6 +- .../battlebanzai/BattleBanzaiGameTeam.java | 14 +- .../games/football/FootballGame.java | 28 +- .../habbohotel/games/freeze/FreezeGame.java | 218 +- .../games/freeze/FreezeGamePlayer.java | 146 +- .../games/freeze/FreezeGameTeam.java | 14 +- .../habbohotel/games/tag/BunnyrunGame.java | 21 +- .../habbohotel/games/tag/IceTagGame.java | 22 +- .../habbohotel/games/tag/RollerskateGame.java | 21 +- .../habbo/habbohotel/games/tag/TagGame.java | 304 +- .../habbohotel/games/tag/TagGamePlayer.java | 6 +- .../habbohotel/games/wired/WiredGame.java | 18 +- .../habbohotel/guides/GuardianTicket.java | 156 +- .../habbo/habbohotel/guides/GuardianVote.java | 20 +- .../habbohotel/guides/GuardianVoteType.java | 9 +- .../habbohotel/guides/GuideChatMessage.java | 6 +- .../habbo/habbohotel/guides/GuideManager.java | 280 +- .../guides/GuideRecommendStatus.java | 3 +- .../eu/habbo/habbohotel/guides/GuideTour.java | 64 +- .../com/eu/habbo/habbohotel/guilds/Guild.java | 169 +- .../habbo/habbohotel/guilds/GuildMember.java | 36 +- .../eu/habbo/habbohotel/guilds/GuildPart.java | 6 +- .../habbohotel/guilds/GuildPartType.java | 3 +- .../eu/habbo/habbohotel/guilds/GuildRank.java | 16 +- .../habbo/habbohotel/guilds/GuildState.java | 16 +- .../habbohotel/guilds/SettingsState.java | 19 +- .../habbohotel/guilds/forums/ForumThread.java | 367 +- .../guilds/forums/ForumThreadComment.java | 87 +- .../guilds/forums/ForumThreadState.java | 21 +- .../habbohotel/hotelview/HallOfFame.java | 31 +- .../hotelview/HallOfFameWinner.java | 21 +- .../hotelview/HotelViewManager.java | 15 +- .../habbo/habbohotel/hotelview/NewsList.java | 25 +- .../habbohotel/hotelview/NewsWidget.java | 27 +- .../habbohotel/items/CrackableReward.java | 34 +- .../habbo/habbohotel/items/FurnitureType.java | 12 +- .../eu/habbo/habbohotel/items/ICycleable.java | 3 +- .../habbohotel/items/IEventTriggers.java | 3 +- .../com/eu/habbo/habbohotel/items/Item.java | 149 +- .../habbohotel/items/ItemInteraction.java | 12 +- .../habbo/habbohotel/items/ItemManager.java | 867 ++-- .../habbo/habbohotel/items/NewUserGift.java | 50 +- .../habbo/habbohotel/items/PostItColor.java | 17 +- .../items/RedeemableSubscriptionType.java | 3 +- .../eu/habbo/habbohotel/items/SoundTrack.java | 24 +- .../habbohotel/items/YoutubeManager.java | 73 +- .../InteractionBackgroundToner.java | 50 +- .../interactions/InteractionBadgeDisplay.java | 37 +- .../interactions/InteractionBlackHole.java | 29 +- .../items/interactions/InteractionCannon.java | 53 +- .../interactions/InteractionClothing.java | 21 +- .../interactions/InteractionColorPlate.java | 34 +- .../interactions/InteractionColorWheel.java | 36 +- .../InteractionCostumeHopper.java | 19 +- .../interactions/InteractionCrackable.java | 76 +- .../InteractionCrackableMaster.java | 18 +- .../interactions/InteractionCustomValues.java | 42 +- .../interactions/InteractionDefault.java | 132 +- .../items/interactions/InteractionDice.java | 49 +- .../interactions/InteractionEffectGiver.java | 27 +- .../interactions/InteractionEffectTile.java | 49 +- .../interactions/InteractionEffectToggle.java | 27 +- .../InteractionEffectVendingMachine.java | 46 +- .../InteractionExternalImage.java | 24 +- .../items/interactions/InteractionFXBox.java | 33 +- .../interactions/InteractionFireworks.java | 29 +- .../items/interactions/InteractionGate.java | 42 +- .../items/interactions/InteractionGift.java | 68 +- .../InteractionGroupEffectTile.java | 12 +- .../InteractionGroupPressurePlate.java | 12 +- .../interactions/InteractionGuildFurni.java | 39 +- .../interactions/InteractionGuildGate.java | 30 +- .../interactions/InteractionGymEquipment.java | 97 +- .../InteractionHabboClubGate.java | 48 +- .../InteractionHabboClubHopper.java | 22 +- .../InteractionHabboClubTeleportTile.java | 18 +- .../interactions/InteractionHanditem.java | 27 +- .../interactions/InteractionHanditemTile.java | 21 +- .../items/interactions/InteractionHopper.java | 60 +- .../InteractionInformationTerminal.java | 15 +- .../interactions/InteractionJukeBox.java | 48 +- .../interactions/InteractionLoveLock.java | 57 +- .../interactions/InteractionMannequin.java | 52 +- .../InteractionMonsterCrackable.java | 34 +- .../InteractionMonsterPlantSeed.java | 59 +- .../interactions/InteractionMoodLight.java | 36 +- .../interactions/InteractionMultiHeight.java | 109 +- .../interactions/InteractionMusicDisc.java | 55 +- .../interactions/InteractionMuteArea.java | 45 +- .../items/interactions/InteractionNest.java | 39 +- .../interactions/InteractionObstacle.java | 89 +- .../interactions/InteractionOneWayGate.java | 60 +- .../InteractionPetBreedingNest.java | 88 +- .../interactions/InteractionPetDrink.java | 24 +- .../interactions/InteractionPetFood.java | 26 +- .../items/interactions/InteractionPetToy.java | 33 +- .../items/interactions/InteractionPostIt.java | 23 +- .../items/interactions/InteractionPoster.java | 21 +- .../InteractionPressurePlate.java | 63 +- .../interactions/InteractionPushable.java | 46 +- .../interactions/InteractionPuzzleBox.java | 39 +- .../interactions/InteractionPyramid.java | 29 +- .../InteractionRedeemableSubscriptionBox.java | 7 - .../InteractionRentableSpace.java | 167 +- .../items/interactions/InteractionRoller.java | 48 +- .../interactions/InteractionRoomAds.java | 37 +- .../interactions/InteractionRoomOMatic.java | 15 +- .../InteractionSnowboardSlope.java | 49 +- .../interactions/InteractionStackHelper.java | 24 +- .../interactions/InteractionStickyPole.java | 9 +- .../items/interactions/InteractionSwitch.java | 35 +- .../InteractionTalkingFurniture.java | 9 +- .../interactions/InteractionTeleport.java | 80 +- .../interactions/InteractionTeleportTile.java | 28 +- .../items/interactions/InteractionTent.java | 9 +- .../InteractionTileEffectProvider.java | 35 +- .../items/interactions/InteractionTrap.java | 42 +- .../items/interactions/InteractionTrophy.java | 30 +- .../InteractionVendingMachine.java | 76 +- .../interactions/InteractionVikingCotie.java | 30 +- .../items/interactions/InteractionWater.java | 146 +- .../interactions/InteractionWaterItem.java | 47 +- .../items/interactions/InteractionWired.java | 63 +- .../InteractionWiredCondition.java | 36 +- .../interactions/InteractionWiredEffect.java | 49 +- .../interactions/InteractionWiredExtra.java | 24 +- .../InteractionWiredHighscore.java | 105 +- .../interactions/InteractionWiredTrigger.java | 48 +- .../interactions/InteractionYoutubeTV.java | 23 +- .../games/InteractionGameGate.java | 22 +- .../games/InteractionGameScoreboard.java | 15 +- .../games/InteractionGameTeamItem.java | 9 +- .../games/InteractionGameTimer.java | 230 +- .../InteractionBattleBanzaiPuck.java | 107 +- .../InteractionBattleBanzaiSphere.java | 21 +- .../InteractionBattleBanzaiTeleporter.java | 31 +- .../InteractionBattleBanzaiTile.java | 52 +- .../InteractionBattleBanzaiTimer.java | 21 +- .../gates/InteractionBattleBanzaiGate.java | 39 +- .../InteractionBattleBanzaiGateBlue.java | 9 +- .../InteractionBattleBanzaiGateGreen.java | 9 +- .../gates/InteractionBattleBanzaiGateRed.java | 9 +- .../InteractionBattleBanzaiGateYellow.java | 9 +- .../InteractionBattleBanzaiScoreboard.java | 18 +- ...InteractionBattleBanzaiScoreboardBlue.java | 9 +- ...nteractionBattleBanzaiScoreboardGreen.java | 9 +- .../InteractionBattleBanzaiScoreboardRed.java | 9 +- ...teractionBattleBanzaiScoreboardYellow.java | 9 +- .../games/football/InteractionFootball.java | 111 +- .../football/InteractionFootballGate.java | 124 +- .../goals/InteractionFootballGoal.java | 21 +- .../goals/InteractionFootballGoalBlue.java | 9 +- .../goals/InteractionFootballGoalGreen.java | 9 +- .../goals/InteractionFootballGoalRed.java | 9 +- .../goals/InteractionFootballGoalYellow.java | 9 +- .../InteractionFootballScoreboard.java | 88 +- .../InteractionFootballScoreboardBlue.java | 9 +- .../InteractionFootballScoreboardGreen.java | 9 +- .../InteractionFootballScoreboardRed.java | 11 +- .../InteractionFootballScoreboardYellow.java | 9 +- .../games/freeze/InteractionFreezeBlock.java | 63 +- .../freeze/InteractionFreezeExitTile.java | 24 +- .../games/freeze/InteractionFreezeTile.java | 39 +- .../games/freeze/InteractionFreezeTimer.java | 24 +- .../freeze/gates/InteractionFreezeGate.java | 37 +- .../gates/InteractionFreezeGateBlue.java | 9 +- .../gates/InteractionFreezeGateGreen.java | 9 +- .../gates/InteractionFreezeGateRed.java | 9 +- .../gates/InteractionFreezeGateYellow.java | 9 +- .../InteractionFreezeScoreboard.java | 18 +- .../InteractionFreezeScoreboardBlue.java | 9 +- .../InteractionFreezeScoreboardGreen.java | 9 +- .../InteractionFreezeScoreboardRed.java | 9 +- .../InteractionFreezeScoreboardYellow.java | 9 +- .../games/tag/InteractionTagField.java | 41 +- .../games/tag/InteractionTagPole.java | 24 +- .../bunnyrun/InteractionBunnyrunField.java | 9 +- .../tag/bunnyrun/InteractionBunnyrunPole.java | 9 +- .../tag/icetag/InteractionIceTagField.java | 9 +- .../tag/icetag/InteractionIceTagPole.java | 9 +- .../InteractionRollerskateField.java | 9 +- .../interactions/wired/WiredTriggerReset.java | 3 +- .../WiredConditionBattleBanzaiGameActive.java | 30 +- .../WiredConditionDateRangeActive.java | 40 +- .../WiredConditionFreezeGameActive.java | 30 +- .../WiredConditionFurniHaveFurni.java | 95 +- .../WiredConditionFurniHaveHabbo.java | 102 +- .../WiredConditionFurniTypeMatch.java | 72 +- .../conditions/WiredConditionGroupMember.java | 32 +- .../conditions/WiredConditionHabboCount.java | 34 +- .../WiredConditionHabboHasCredits.java | 15 +- .../WiredConditionHabboHasDiamonds.java | 15 +- .../WiredConditionHabboHasDuckets.java | 15 +- .../WiredConditionHabboHasEffect.java | 30 +- .../WiredConditionHabboHasHandItem.java | 37 +- .../WiredConditionHabboHasRank.java | 25 +- .../WiredConditionHabboIsDancing.java | 15 +- .../WiredConditionHabboNotRank.java | 25 +- .../WiredConditionHabboOwnsBadge.java | 15 +- .../WiredConditionHabboWearsBadge.java | 42 +- .../WiredConditionLessTimeElapsed.java | 37 +- .../WiredConditionMatchStatePosition.java | 105 +- .../WiredConditionMoreTimeElapsed.java | 37 +- .../WiredConditionMottoContains.java | 33 +- ...redConditionNotBattleBanzaiGameActive.java | 30 +- .../WiredConditionNotFreezeGameActive.java | 30 +- .../WiredConditionNotFurniHaveFurni.java | 80 +- .../WiredConditionNotFurniHaveHabbo.java | 105 +- .../WiredConditionNotFurniTypeMatch.java | 72 +- .../WiredConditionNotHabboCount.java | 34 +- .../WiredConditionNotHabboHasCredits.java | 15 +- .../WiredConditionNotHabboHasDiamonds.java | 15 +- .../WiredConditionNotHabboHasDuckets.java | 15 +- .../WiredConditionNotHabboHasEffect.java | 30 +- .../WiredConditionNotHabboIsDancing.java | 15 +- .../WiredConditionNotHabboOwnsBadge.java | 15 +- .../WiredConditionNotHabboWearsBadge.java | 39 +- .../conditions/WiredConditionNotInGroup.java | 32 +- .../conditions/WiredConditionNotInTeam.java | 43 +- .../WiredConditionNotMatchStatePosition.java | 84 +- .../WiredConditionNotTriggerOnFurni.java | 69 +- .../conditions/WiredConditionTeamMember.java | 43 +- .../WiredConditionTriggerOnFurni.java | 73 +- .../wired/effects/WiredEffectAlert.java | 16 +- .../wired/effects/WiredEffectBotClothes.java | 55 +- .../effects/WiredEffectBotFollowHabbo.java | 65 +- .../effects/WiredEffectBotGiveHandItem.java | 65 +- .../wired/effects/WiredEffectBotTalk.java | 69 +- .../effects/WiredEffectBotTalkToHabbo.java | 73 +- .../wired/effects/WiredEffectBotTeleport.java | 82 +- .../effects/WiredEffectBotWalkToFurni.java | 75 +- .../WiredEffectChangeFurniDirection.java | 106 +- .../effects/WiredEffectForwardToRoom.java | 21 +- .../effects/WiredEffectGiveAchievement.java | 91 +- .../wired/effects/WiredEffectGiveBadge.java | 64 +- .../wired/effects/WiredEffectGiveCredits.java | 71 +- .../effects/WiredEffectGiveDiamonds.java | 80 +- .../wired/effects/WiredEffectGiveDuckets.java | 71 +- .../wired/effects/WiredEffectGiveEffect.java | 21 +- .../effects/WiredEffectGiveHandItem.java | 22 +- ...redEffectGiveHotelviewBonusRarePoints.java | 73 +- .../WiredEffectGiveHotelviewHofPoints.java | 73 +- .../wired/effects/WiredEffectGiveRespect.java | 71 +- .../wired/effects/WiredEffectGiveReward.java | 112 +- .../wired/effects/WiredEffectGiveScore.java | 79 +- .../effects/WiredEffectGiveScoreToTeam.java | 54 +- .../wired/effects/WiredEffectJoinTeam.java | 69 +- .../wired/effects/WiredEffectKickHabbo.java | 78 +- .../wired/effects/WiredEffectLeaveTeam.java | 61 +- .../wired/effects/WiredEffectLowerFurni.java | 78 +- .../wired/effects/WiredEffectMatchFurni.java | 113 +- .../effects/WiredEffectMatchFurniStaff.java | 9 +- .../effects/WiredEffectMoveFurniAway.java | 114 +- .../wired/effects/WiredEffectMoveFurniTo.java | 215 +- .../effects/WiredEffectMoveFurniTowards.java | 135 +- .../effects/WiredEffectMoveRotateFurni.java | 279 +- .../wired/effects/WiredEffectMuteHabbo.java | 47 +- .../effects/WiredEffectOpenHabboPages.java | 15 +- .../wired/effects/WiredEffectRaiseFurni.java | 74 +- .../wired/effects/WiredEffectResetTimers.java | 56 +- .../wired/effects/WiredEffectRollerSpeed.java | 66 +- .../wired/effects/WiredEffectTeleport.java | 201 +- .../wired/effects/WiredEffectToggleFurni.java | 239 +- .../effects/WiredEffectToggleRandom.java | 116 +- .../effects/WiredEffectTriggerStacks.java | 99 +- .../wired/effects/WiredEffectWhisper.java | 74 +- .../interactions/wired/extra/WiredBlob.java | 36 +- .../wired/extra/WiredExtraRandom.java | 27 +- .../wired/extra/WiredExtraUnseen.java | 52 +- .../wired/triggers/WiredTriggerAtSetTime.java | 58 +- .../triggers/WiredTriggerAtTimeLong.java | 61 +- .../triggers/WiredTriggerBotReachedFurni.java | 102 +- .../triggers/WiredTriggerBotReachedHabbo.java | 40 +- .../wired/triggers/WiredTriggerCollision.java | 33 +- .../WiredTriggerFurniStateToggled.java | 86 +- .../wired/triggers/WiredTriggerGameEnds.java | 49 +- .../triggers/WiredTriggerGameStarts.java | 49 +- .../triggers/WiredTriggerHabboEntersRoom.java | 39 +- .../wired/triggers/WiredTriggerHabboIdle.java | 33 +- .../WiredTriggerHabboSaysCommand.java | 54 +- .../WiredTriggerHabboSaysKeyword.java | 48 +- .../WiredTriggerHabboStartsDancing.java | 17 +- .../WiredTriggerHabboStopsDancing.java | 15 +- .../triggers/WiredTriggerHabboUnidle.java | 33 +- .../WiredTriggerHabboWalkOffFurni.java | 92 +- .../WiredTriggerHabboWalkOnFurni.java | 92 +- .../wired/triggers/WiredTriggerRepeater.java | 70 +- .../triggers/WiredTriggerRepeaterLong.java | 69 +- .../triggers/WiredTriggerScoreAchieved.java | 45 +- .../wired/triggers/WiredTriggerTeamLoses.java | 12 +- .../wired/triggers/WiredTriggerTeamWins.java | 12 +- .../habbohotel/messenger/FriendRequest.java | 18 +- .../habbo/habbohotel/messenger/Message.java | 27 +- .../habbo/habbohotel/messenger/Messenger.java | 583 ++- .../habbohotel/messenger/MessengerBuddy.java | 100 +- .../habbohotel/modtool/CfhActionType.java | 23 +- .../habbo/habbohotel/modtool/CfhCategory.java | 15 +- .../eu/habbo/habbohotel/modtool/CfhTopic.java | 6 +- .../habbo/habbohotel/modtool/ModToolBan.java | 61 +- .../habbohotel/modtool/ModToolBanType.java | 24 +- .../habbohotel/modtool/ModToolCategory.java | 15 +- .../habbohotel/modtool/ModToolChatLog.java | 9 +- .../modtool/ModToolChatRecordDataContext.java | 9 +- .../modtool/ModToolChatRecordDataType.java | 6 +- .../modtool/ModToolChatlogType.java | 6 +- .../habbohotel/modtool/ModToolIssue.java | 28 +- .../habbohotel/modtool/ModToolManager.java | 563 +-- .../habbohotel/modtool/ModToolPreset.java | 6 +- .../habbohotel/modtool/ModToolRoomVisit.java | 12 +- .../modtool/ModToolTicketState.java | 23 +- .../habbohotel/modtool/ModToolTicketType.java | 9 +- .../habbo/habbohotel/modtool/WordFilter.java | 127 +- .../habbohotel/modtool/WordFilterWord.java | 21 +- .../habbohotel/navigation/DisplayMode.java | 3 +- .../habbohotel/navigation/DisplayOrder.java | 3 +- .../habbo/habbohotel/navigation/ListMode.java | 15 +- .../navigation/NavigatorFavoriteFilter.java | 9 +- .../navigation/NavigatorFilter.java | 100 +- .../navigation/NavigatorFilterComparator.java | 3 +- .../navigation/NavigatorFilterField.java | 6 +- .../navigation/NavigatorHotelFilter.java | 37 +- .../navigation/NavigatorManager.java | 98 +- .../navigation/NavigatorPublicCategory.java | 12 +- .../navigation/NavigatorPublicFilter.java | 15 +- .../navigation/NavigatorRoomAdsFilter.java | 9 +- .../navigation/NavigatorUserFilter.java | 21 +- .../habbohotel/navigation/SearchAction.java | 6 +- .../navigation/SearchResultList.java | 33 +- .../habbohotel/permissions/Permission.java | 97 +- .../permissions/PermissionSetting.java | 9 +- .../permissions/PermissionsManager.java | 96 +- .../eu/habbo/habbohotel/permissions/Rank.java | 72 +- .../eu/habbo/habbohotel/pets/GnomePet.java | 54 +- .../eu/habbo/habbohotel/pets/HorsePet.java | 34 +- .../eu/habbo/habbohotel/pets/IPetLook.java | 3 +- .../habbohotel/pets/MonsterplantPet.java | 220 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 500 +-- .../eu/habbo/habbohotel/pets/PetAction.java | 24 +- .../habbohotel/pets/PetBreedingReward.java | 6 +- .../eu/habbo/habbohotel/pets/PetCommand.java | 47 +- .../com/eu/habbo/habbohotel/pets/PetData.java | 211 +- .../eu/habbo/habbohotel/pets/PetGestures.java | 9 +- .../eu/habbo/habbohotel/pets/PetManager.java | 456 +-- .../com/eu/habbo/habbohotel/pets/PetRace.java | 6 +- .../eu/habbo/habbohotel/pets/PetTasks.java | 9 +- .../eu/habbo/habbohotel/pets/PetVocal.java | 6 +- .../habbo/habbohotel/pets/PetVocalsType.java | 3 +- .../eu/habbo/habbohotel/pets/RideablePet.java | 18 +- .../habbohotel/pets/actions/ActionBeg.java | 11 +- .../pets/actions/ActionBreatheFire.java | 11 +- .../habbohotel/pets/actions/ActionBreed.java | 25 +- .../habbohotel/pets/actions/ActionCroak.java | 11 +- .../habbohotel/pets/actions/ActionDip.java | 9 +- .../habbohotel/pets/actions/ActionDown.java | 11 +- .../habbohotel/pets/actions/ActionDrink.java | 18 +- .../habbohotel/pets/actions/ActionEat.java | 16 +- .../habbohotel/pets/actions/ActionFollow.java | 11 +- .../pets/actions/ActionFollowLeft.java | 13 +- .../pets/actions/ActionFollowRight.java | 13 +- .../habbohotel/pets/actions/ActionFree.java | 9 +- .../habbohotel/pets/actions/ActionHere.java | 11 +- .../habbohotel/pets/actions/ActionJump.java | 11 +- .../pets/actions/ActionMoveForward.java | 9 +- .../habbohotel/pets/actions/ActionNest.java | 16 +- .../habbohotel/pets/actions/ActionPlay.java | 14 +- .../pets/actions/ActionPlayDead.java | 11 +- .../pets/actions/ActionPlayFootball.java | 11 +- .../habbohotel/pets/actions/ActionRelax.java | 13 +- .../habbohotel/pets/actions/ActionSilent.java | 9 +- .../habbohotel/pets/actions/ActionSit.java | 12 +- .../habbohotel/pets/actions/ActionSpeak.java | 21 +- .../habbohotel/pets/actions/ActionStand.java | 11 +- .../habbohotel/pets/actions/ActionStay.java | 9 +- .../habbohotel/pets/actions/ActionTorch.java | 12 +- .../pets/actions/ActionTurnLeft.java | 11 +- .../pets/actions/ActionTurnRight.java | 11 +- .../habbohotel/pets/actions/ActionWave.java | 12 +- .../habbohotel/pets/actions/ActionWings.java | 11 +- .../com/eu/habbo/habbohotel/polls/Poll.java | 21 +- .../habbo/habbohotel/polls/PollManager.java | 87 +- .../habbo/habbohotel/polls/PollQuestion.java | 33 +- .../habbohotel/rooms/CustomRoomLayout.java | 27 +- .../rooms/FurnitureMovementError.java | 10 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 3574 ++++++----------- .../eu/habbo/habbohotel/rooms/RoomBan.java | 29 +- .../habbo/habbohotel/rooms/RoomCategory.java | 21 +- .../habbohotel/rooms/RoomChatMessage.java | 183 +- .../rooms/RoomChatMessageBubbles.java | 51 +- .../habbo/habbohotel/rooms/RoomChatType.java | 3 +- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 569 +-- .../habbo/habbohotel/rooms/RoomManager.java | 1030 ++--- .../habbohotel/rooms/RoomMoodlightData.java | 124 +- .../habbo/habbohotel/rooms/RoomPromotion.java | 48 +- .../habbohotel/rooms/RoomRightLevels.java | 24 +- .../habbohotel/rooms/RoomSpecialTypes.java | 526 +-- .../eu/habbo/habbohotel/rooms/RoomState.java | 9 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 126 +- .../habbo/habbohotel/rooms/RoomTileState.java | 3 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 173 +- .../habbo/habbohotel/rooms/RoomTradeUser.java | 61 +- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 470 +-- .../habbohotel/rooms/RoomUnitEffect.java | 25 +- .../habbohotel/rooms/RoomUnitStatus.java | 29 +- .../habbo/habbohotel/rooms/RoomUnitType.java | 9 +- .../habbohotel/rooms/RoomUserAction.java | 25 +- .../habbohotel/rooms/RoomUserRotation.java | 52 +- .../habbo/habbohotel/rooms/TraxManager.java | 168 +- .../eu/habbo/habbohotel/users/DanceType.java | 9 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 233 +- .../eu/habbo/habbohotel/users/HabboBadge.java | 65 +- .../habbo/habbohotel/users/HabboGender.java | 3 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 258 +- .../habbohotel/users/HabboInventory.java | 124 +- .../eu/habbo/habbohotel/users/HabboItem.java | 268 +- .../habbo/habbohotel/users/HabboManager.java | 289 +- .../HabboNavigatorPersonalDisplayMode.java | 9 +- .../users/HabboNavigatorWindowSettings.java | 83 +- .../eu/habbo/habbohotel/users/HabboStats.java | 527 +-- .../eu/habbo/habbohotel/users/SignType.java | 9 +- .../users/cache/HabboOfferPurchase.java | 123 +- .../users/inventory/BadgesComponent.java | 214 +- .../users/inventory/BotsComponent.java | 55 +- .../users/inventory/EffectsComponent.java | 147 +- .../users/inventory/ItemsComponent.java | 133 +- .../users/inventory/PetsComponent.java | 70 +- .../users/inventory/WardrobeComponent.java | 101 +- .../wired/WiredConditionOperator.java | 3 +- .../habbohotel/wired/WiredConditionType.java | 6 +- .../habbohotel/wired/WiredEffectType.java | 6 +- .../habbohotel/wired/WiredGiveRewardItem.java | 15 +- .../habbo/habbohotel/wired/WiredHandler.java | 300 +- .../wired/WiredHighscoreClearType.java | 6 +- .../habbohotel/wired/WiredHighscoreData.java | 6 +- .../wired/WiredHighscoreScoreType.java | 6 +- .../wired/WiredMatchFurniSetting.java | 12 +- .../habbohotel/wired/WiredTriggerType.java | 6 +- .../com/eu/habbo/messages/ClientMessage.java | 75 +- .../java/com/eu/habbo/messages/ICallable.java | 3 +- .../com/eu/habbo/messages/ISerialize.java | 3 +- .../com/eu/habbo/messages/PacketManager.java | 834 ++-- .../eu/habbo/messages/PacketManager_1006.java | 91 +- .../com/eu/habbo/messages/ServerMessage.java | 176 +- .../eu/habbo/messages/incoming/Incoming.java | 3 +- .../messages/incoming/MessageHandler.java | 3 +- .../RequestAchievementConfigurationEvent.java | 6 +- .../RequestAchievementsEvent.java | 6 +- .../AmbassadorAlertCommandEvent.java | 10 +- .../AmbassadorVisitCommandEvent.java | 15 +- .../camera/CameraPublishToWebEvent.java | 36 +- .../incoming/camera/CameraPurchaseEvent.java | 24 +- .../camera/CameraRoomPictureEvent.java | 19 +- .../camera/CameraRoomThumbnailEvent.java | 17 +- .../RequestCameraConfigurationEvent.java | 6 +- .../catalog/CatalogBuyItemAsGiftEvent.java | 234 +- .../incoming/catalog/CatalogBuyItemEvent.java | 89 +- .../catalog/CatalogSearchedItemEvent.java | 18 +- .../incoming/catalog/CheckPetNameEvent.java | 21 +- .../catalog/JukeBoxRequestTrackCodeEvent.java | 9 +- .../catalog/JukeBoxRequestTrackDataEvent.java | 11 +- .../catalog/PurchaseTargetOfferEvent.java | 18 +- .../incoming/catalog/RedeemVoucherEvent.java | 12 +- .../catalog/RequestCatalogIndexEvent.java | 6 +- .../catalog/RequestCatalogModeEvent.java | 10 +- .../catalog/RequestCatalogPageEvent.java | 19 +- .../catalog/RequestClubDataEvent.java | 6 +- .../catalog/RequestClubGiftsEvent.java | 6 +- .../catalog/RequestDiscountEvent.java | 6 +- .../RequestGiftConfigurationEvent.java | 6 +- .../RequestMarketplaceConfigEvent.java | 6 +- .../catalog/RequestPetBreedsEvent.java | 6 +- .../catalog/TargetOfferStateEvent.java | 9 +- .../catalog/marketplace/BuyItemEvent.java | 6 +- .../marketplace/RequestCreditsEvent.java | 6 +- .../marketplace/RequestItemInfoEvent.java | 6 +- .../marketplace/RequestOffersEvent.java | 19 +- .../marketplace/RequestOwnItemsEvent.java | 6 +- .../marketplace/RequestSellItemEvent.java | 8 +- .../catalog/marketplace/SellItemEvent.java | 26 +- .../marketplace/TakeBackItemEvent.java | 6 +- .../catalog/recycler/OpenRecycleBoxEvent.java | 35 +- .../catalog/recycler/RecycleEvent.java | 35 +- .../catalog/recycler/ReloadRecyclerEvent.java | 6 +- .../recycler/RequestRecyclerLogicEvent.java | 6 +- .../crafting/CraftingAddRecipeEvent.java | 12 +- .../crafting/CraftingCraftItemEvent.java | 36 +- .../crafting/CraftingCraftSecretEvent.java | 42 +- .../RequestCraftingRecipesAvailableEvent.java | 30 +- .../crafting/RequestCraftingRecipesEvent.java | 12 +- .../AdventCalendarForceOpenEvent.java | 6 +- .../calendar/AdventCalendarOpenDayEvent.java | 6 +- ...oorPlanEditorRequestBlockedTilesEvent.java | 8 +- ...oorPlanEditorRequestDoorSettingsEvent.java | 8 +- .../FloorPlanEditorSaveEvent.java | 86 +- .../friends/AcceptFriendRequestEvent.java | 16 +- .../incoming/friends/ChangeRelationEvent.java | 12 +- .../friends/DeclineFriendRequestEvent.java | 16 +- .../incoming/friends/FindNewFriendsEvent.java | 15 +- .../friends/FriendPrivateMessageEvent.java | 19 +- .../incoming/friends/FriendRequestEvent.java | 50 +- .../incoming/friends/InviteFriendsEvent.java | 21 +- .../incoming/friends/RemoveFriendEvent.java | 15 +- .../friends/RequestFriendRequestsEvent.java | 6 +- .../incoming/friends/RequestFriendsEvent.java | 6 +- .../friends/RequestInitFriendsEvent.java | 6 +- .../incoming/friends/SearchUserEvent.java | 15 +- .../incoming/friends/StalkFriendEvent.java | 25 +- .../incoming/gamecenter/GameCenterEvent.java | 6 +- .../gamecenter/GameCenterJoinGameEvent.java | 10 +- .../gamecenter/GameCenterLeaveGameEvent.java | 6 +- .../gamecenter/GameCenterLoadGameEvent.java | 9 +- .../GameCenterRequestAccountStatusEvent.java | 6 +- .../GameCenterRequestGameStatusEvent.java | 6 +- .../GameCenterRequestGamesEvent.java | 6 +- .../guardians/GuardianAcceptRequestEvent.java | 6 +- .../GuardianNoUpdatesWantedEvent.java | 6 +- .../incoming/guardians/GuardianVoteEvent.java | 24 +- .../guides/GuideCancelHelpRequestEvent.java | 9 +- .../guides/GuideCloseHelpRequestEvent.java | 9 +- .../guides/GuideHandleHelpRequestEvent.java | 16 +- .../incoming/guides/GuideInviteUserEvent.java | 9 +- .../guides/GuideRecommendHelperEvent.java | 9 +- .../guides/GuideReportHelperEvent.java | 12 +- .../guides/GuideUserMessageEvent.java | 9 +- .../incoming/guides/GuideUserTypingEvent.java | 16 +- .../incoming/guides/GuideVisitUserEvent.java | 9 +- .../guides/RequestGuideAssistanceEvent.java | 9 +- .../guides/RequestGuideToolEvent.java | 25 +- .../GetHabboGuildBadgesMessageEvent.java | 6 +- .../guilds/GuildAcceptMembershipEvent.java | 40 +- .../guilds/GuildChangeBadgeEvent.java | 24 +- .../guilds/GuildChangeColorsEvent.java | 18 +- .../guilds/GuildChangeNameDescEvent.java | 15 +- .../guilds/GuildChangeSettingsEvent.java | 12 +- .../guilds/GuildConfirmRemoveMemberEvent.java | 15 +- .../guilds/GuildDeclineMembershipEvent.java | 21 +- .../incoming/guilds/GuildDeleteEvent.java | 15 +- .../guilds/GuildRemoveAdminEvent.java | 15 +- .../guilds/GuildRemoveFavoriteEvent.java | 11 +- .../guilds/GuildRemoveMemberEvent.java | 27 +- .../incoming/guilds/GuildSetAdminEvent.java | 21 +- .../guilds/GuildSetFavoriteEvent.java | 17 +- .../incoming/guilds/RequestGuildBuyEvent.java | 59 +- .../guilds/RequestGuildBuyRoomsEvent.java | 11 +- .../guilds/RequestGuildFurniWidgetEvent.java | 11 +- .../guilds/RequestGuildInfoEvent.java | 9 +- .../guilds/RequestGuildJoinEvent.java | 15 +- .../guilds/RequestGuildManageEvent.java | 6 +- .../guilds/RequestGuildMembersEvent.java | 12 +- .../guilds/RequestGuildPartsEvent.java | 6 +- .../guilds/RequestOwnGuildsEvent.java | 14 +- .../guilds/forums/GuildForumDataEvent.java | 8 +- .../guilds/forums/GuildForumListEvent.java | 24 +- .../GuildForumModerateMessageEvent.java | 8 +- .../forums/GuildForumModerateThreadEvent.java | 6 +- .../forums/GuildForumPostThreadEvent.java | 11 +- .../forums/GuildForumThreadUpdateEvent.java | 7 +- .../guilds/forums/GuildForumThreadsEvent.java | 8 +- .../GuildForumThreadsMessagesEvent.java | 15 +- .../forums/GuildForumUpdateSettingsEvent.java | 10 +- .../handshake/IsFirstLoginOfDayComposer.java | 9 +- .../incoming/handshake/PingEvent.java | 6 +- .../handshake/ReleaseVersionEvent.java | 3 +- .../handshake/RequestBannerToken.java | 3 +- .../incoming/handshake/SecureLoginEvent.java | 73 +- .../handshake/SecureLoginEvent_BACKUP.java | 28 +- .../incoming/handshake/UnknownComposer5.java | 6 +- .../incoming/handshake/UsernameEvent.java | 70 +- .../helper/RequestTalentTrackEvent.java | 9 +- .../HotelViewClaimBadgeRewardEvent.java | 17 +- .../hotelview/HotelViewDataEvent.java | 27 +- .../incoming/hotelview/HotelViewEvent.java | 22 +- .../HotelViewRequestBadgeRewardEvent.java | 6 +- .../HotelViewRequestBonusRareEvent.java | 6 +- .../HotelViewRequestLTDAvailabilityEvent.java | 13 +- .../hotelview/RequestNewsListEvent.java | 6 +- .../RequestInventoryBadgesEvent.java | 6 +- .../inventory/RequestInventoryBotsEvent.java | 6 +- .../inventory/RequestInventoryItemsEvent.java | 28 +- .../inventory/RequestInventoryPetsEvent.java | 6 +- .../incoming/modtool/ModToolAlertEvent.java | 15 +- .../ModToolChangeRoomSettingsEvent.java | 16 +- .../modtool/ModToolCloseTicketEvent.java | 16 +- .../modtool/ModToolIssueChangeTopicEvent.java | 12 +- .../ModToolIssueDefaultSanctionEvent.java | 32 +- .../incoming/modtool/ModToolKickEvent.java | 6 +- .../modtool/ModToolPickTicketEvent.java | 25 +- .../modtool/ModToolReleaseTicketEvent.java | 16 +- .../ModToolRequestIssueChatlogEvent.java | 32 +- .../ModToolRequestRoomChatlogEvent.java | 15 +- .../modtool/ModToolRequestRoomInfoEvent.java | 16 +- .../ModToolRequestRoomUserChatlogEvent.java | 19 +- .../ModToolRequestRoomVisitsEvent.java | 11 +- .../ModToolRequestUserChatlogEvent.java | 13 +- .../modtool/ModToolRequestUserInfoEvent.java | 13 +- .../modtool/ModToolRoomAlertEvent.java | 16 +- .../modtool/ModToolSanctionAlertEvent.java | 16 +- .../modtool/ModToolSanctionBanEvent.java | 27 +- .../modtool/ModToolSanctionMuteEvent.java | 16 +- .../ModToolSanctionTradeLockEvent.java | 16 +- .../incoming/modtool/ModToolWarnEvent.java | 15 +- .../incoming/modtool/ReportBullyEvent.java | 24 +- .../incoming/modtool/ReportEvent.java | 74 +- .../modtool/ReportFriendPrivateChatEvent.java | 22 +- .../modtool/RequestReportRoomEvent.java | 8 +- .../RequestReportUserBullyingEvent.java | 15 +- .../modtool/StartSafetyQuizEvent.java | 6 +- .../NavigatorCategoryListModeEvent.java | 6 +- .../NavigatorCollapseCategoryEvent.java | 6 +- .../NavigatorUncollapseCategoryEvent.java | 6 +- .../navigator/NewNavigatorActionEvent.java | 20 +- .../navigator/RequestCanCreateRoomEvent.java | 6 +- .../navigator/RequestCreateRoomEvent.java | 28 +- .../navigator/RequestDeleteRoomEvent.java | 50 +- .../RequestHighestScoreRoomsEvent.java | 6 +- .../navigator/RequestMyRoomsEvent.java | 6 +- .../RequestNavigatorSettingsEvent.java | 9 +- .../RequestNewNavigatorDataEvent.java | 6 +- .../RequestNewNavigatorRoomsEvent.java | 75 +- .../navigator/RequestPopularRoomsEvent.java | 6 +- .../navigator/RequestPromotedRoomsEvent.java | 6 +- .../navigator/RequestRoomCategoriesEvent.java | 6 +- .../incoming/navigator/RequestTagsEvent.java | 6 +- .../navigator/SaveWindowSettingsEvent.java | 6 +- .../navigator/SearchRoomsByTagEvent.java | 6 +- .../incoming/navigator/SearchRoomsEvent.java | 37 +- .../navigator/SearchRoomsFriendsNowEvent.java | 6 +- .../navigator/SearchRoomsFriendsOwnEvent.java | 6 +- .../navigator/SearchRoomsInGroupEvent.java | 6 +- .../SearchRoomsMyFavouriteEvent.java | 6 +- .../navigator/SearchRoomsVisitedEvent.java | 6 +- .../navigator/SearchRoomsWithRightsEvent.java | 6 +- .../incoming/polls/AnswerPollEvent.java | 37 +- .../incoming/polls/CancelPollEvent.java | 16 +- .../incoming/polls/GetPollDataEvent.java | 9 +- .../incoming/rooms/HandleDoorbellEvent.java | 19 +- .../incoming/rooms/RequestHeightmapEvent.java | 9 +- .../incoming/rooms/RequestRoomDataEvent.java | 12 +- .../rooms/RequestRoomHeightmapEvent.java | 12 +- .../incoming/rooms/RequestRoomLoadEvent.java | 16 +- .../rooms/RequestRoomRightsEvent.java | 11 +- .../rooms/RequestRoomSettingsEvent.java | 8 +- .../rooms/RequestRoomWordFilterEvent.java | 9 +- .../incoming/rooms/RoomBackgroundEvent.java | 25 +- .../incoming/rooms/RoomFavoriteEvent.java | 19 +- .../incoming/rooms/RoomMuteEvent.java | 12 +- .../incoming/rooms/RoomPlacePaintEvent.java | 28 +- .../rooms/RoomRemoveAllRightsEvent.java | 20 +- .../incoming/rooms/RoomRemoveRightsEvent.java | 6 +- .../rooms/RoomRequestBannedUsersEvent.java | 9 +- .../incoming/rooms/RoomSettingsSaveEvent.java | 54 +- .../incoming/rooms/RoomStaffPickEvent.java | 28 +- .../incoming/rooms/RoomUnFavoriteEvent.java | 12 +- .../incoming/rooms/RoomVoteEvent.java | 6 +- .../rooms/RoomWordFilterModifyEvent.java | 19 +- .../incoming/rooms/SetHomeRoomEvent.java | 9 +- .../incoming/rooms/bots/BotPickupEvent.java | 8 +- .../incoming/rooms/bots/BotPlaceEvent.java | 10 +- .../rooms/bots/BotSaveSettingsEvent.java | 74 +- .../incoming/rooms/bots/BotSettingsEvent.java | 9 +- .../rooms/items/AdvertisingSaveEvent.java | 18 +- .../incoming/rooms/items/CloseDiceEvent.java | 24 +- .../items/FootballGateSaveLookEvent.java | 17 +- .../rooms/items/MannequinSaveLookEvent.java | 26 +- .../rooms/items/MannequinSaveNameEvent.java | 17 +- .../items/MoodLightSaveSettingsEvent.java | 21 +- .../rooms/items/MoodLightSettingsEvent.java | 8 +- .../rooms/items/MoodLightTurnOnEvent.java | 17 +- .../rooms/items/MoveWallItemEvent.java | 15 +- .../rooms/items/PostItDeleteEvent.java | 14 +- .../rooms/items/PostItPlaceEvent.java | 18 +- .../rooms/items/PostItRequestDataEvent.java | 12 +- .../rooms/items/PostItSaveDataEvent.java | 36 +- .../rooms/items/RedeemClothingEvent.java | 38 +- .../incoming/rooms/items/RedeemItemEvent.java | 80 +- .../rooms/items/RoomPickupItemEvent.java | 21 +- .../rooms/items/RoomPlaceItemEvent.java | 51 +- .../rooms/items/RotateMoveItemEvent.java | 12 +- .../items/SavePostItStickyPoleEvent.java | 35 +- .../items/SetStackHelperHeightEvent.java | 37 +- .../rooms/items/ToggleFloorItemEvent.java | 79 +- .../rooms/items/ToggleWallItemEvent.java | 8 +- .../rooms/items/TriggerColorWheelEvent.java | 11 +- .../rooms/items/TriggerDiceEvent.java | 18 +- .../rooms/items/TriggerOneWayGateEvent.java | 15 +- .../jukebox/JukeBoxAddSoundTrackEvent.java | 15 +- .../rooms/items/jukebox/JukeBoxEventOne.java | 6 +- .../rooms/items/jukebox/JukeBoxEventTwo.java | 6 +- .../jukebox/JukeBoxRemoveSoundTrackEvent.java | 9 +- .../jukebox/JukeBoxRequestPlayListEvent.java | 6 +- .../lovelock/LoveLockStartConfirmEvent.java | 24 +- .../rentablespace/RentSpaceCancelEvent.java | 16 +- .../items/rentablespace/RentSpaceEvent.java | 10 +- .../youtube/YoutubeRequestNextVideoEvent.java | 15 +- .../youtube/YoutubeRequestPlayListEvent.java | 12 +- .../youtube/YoutubeRequestVideoDataEvent.java | 15 +- .../rooms/pets/BreedMonsterplantsEvent.java | 15 +- .../rooms/pets/CompostMonsterplantEvent.java | 29 +- .../rooms/pets/ConfirmPetBreedingEvent.java | 11 +- .../incoming/rooms/pets/MovePetEvent.java | 20 +- .../rooms/pets/PetPackageNameEvent.java | 47 +- .../incoming/rooms/pets/PetPickupEvent.java | 34 +- .../incoming/rooms/pets/PetPlaceEvent.java | 42 +- .../incoming/rooms/pets/PetRideEvent.java | 23 +- .../rooms/pets/PetRideSettingsEvent.java | 14 +- .../incoming/rooms/pets/PetUseItemEvent.java | 89 +- .../pets/RequestPetInformationEvent.java | 11 +- .../pets/RequestPetTrainingPanelEvent.java | 10 +- .../incoming/rooms/pets/ScratchPetEvent.java | 14 +- .../rooms/pets/StopBreedingEvent.java | 9 +- .../ToggleMonsterplantBreedableEvent.java | 15 +- .../promotions/BuyRoomPromotionEvent.java | 31 +- .../RequestPromotionRoomsEvent.java | 6 +- .../promotions/UpdateRoomPromotionEvent.java | 12 +- .../rooms/users/IgnoreRoomUserEvent.java | 14 +- .../rooms/users/RequestRoomUserTagsEvent.java | 12 +- .../rooms/users/RoomUserActionEvent.java | 40 +- .../rooms/users/RoomUserBanEvent.java | 6 +- .../rooms/users/RoomUserDanceEvent.java | 23 +- .../users/RoomUserDropHandItemEvent.java | 9 +- .../users/RoomUserGiveHandItemEvent.java | 12 +- .../rooms/users/RoomUserGiveRespectEvent.java | 13 +- .../rooms/users/RoomUserGiveRightsEvent.java | 24 +- .../rooms/users/RoomUserKickEvent.java | 21 +- .../rooms/users/RoomUserLookAtPoint.java | 31 +- .../rooms/users/RoomUserMuteEvent.java | 15 +- .../users/RoomUserRemoveRightsEvent.java | 14 +- .../rooms/users/RoomUserShoutEvent.java | 26 +- .../rooms/users/RoomUserSignEvent.java | 5 +- .../rooms/users/RoomUserSitEvent.java | 18 +- .../rooms/users/RoomUserStartTypingEvent.java | 12 +- .../rooms/users/RoomUserStopTypingEvent.java | 12 +- .../rooms/users/RoomUserTalkEvent.java | 23 +- .../rooms/users/RoomUserWalkEvent.java | 44 +- .../rooms/users/RoomUserWhisperEvent.java | 21 +- .../rooms/users/UnIgnoreRoomUserEvent.java | 15 +- .../rooms/users/UnbanRoomUserEvent.java | 12 +- .../incoming/trading/TradeAcceptEvent.java | 10 +- .../incoming/trading/TradeCancelEvent.java | 10 +- .../trading/TradeCancelOfferItemEvent.java | 12 +- .../incoming/trading/TradeCloseEvent.java | 10 +- .../incoming/trading/TradeConfirmEvent.java | 8 +- .../incoming/trading/TradeOfferItemEvent.java | 10 +- .../trading/TradeOfferMultipleItemsEvent.java | 18 +- .../incoming/trading/TradeStartEvent.java | 48 +- .../incoming/trading/TradeUnAcceptEvent.java | 8 +- .../unknown/RequestResolutionEvent.java | 9 +- .../incoming/unknown/UnknownEvent1.java | 6 +- .../incoming/unknown/UnknownEvent2.java | 6 +- .../incoming/users/ActivateEffectEvent.java | 9 +- .../incoming/users/ChangeChatBubbleEvent.java | 15 +- .../users/ChangeNameCheckUsernameEvent.java | 42 +- .../users/ConfirmChangeNameEvent.java | 42 +- .../incoming/users/EnableEffectEvent.java | 19 +- .../incoming/users/PickNewUserGiftEvent.java | 15 +- .../users/RequestMeMenuSettingsEvent.java | 6 +- .../users/RequestProfileFriendsEvent.java | 8 +- .../users/RequestUserCitizinShipEvent.java | 6 +- .../incoming/users/RequestUserClubEvent.java | 6 +- .../users/RequestUserCreditsEvent.java | 6 +- .../incoming/users/RequestUserDataEvent.java | 57 +- .../users/RequestUserProfileEvent.java | 8 +- .../users/RequestUserWardrobeEvent.java | 6 +- .../users/RequestWearingBadgesEvent.java | 8 +- .../users/SaveBlockCameraFollowEvent.java | 6 +- .../users/SaveIgnoreRoomInvitesEvent.java | 6 +- .../incoming/users/SaveMottoEvent.java | 13 +- .../users/SavePreferOldChatEvent.java | 6 +- .../incoming/users/SaveUserVolumesEvent.java | 6 +- .../incoming/users/SaveWardrobeEvent.java | 13 +- .../incoming/users/UserActivityEvent.java | 12 +- .../messages/incoming/users/UserNuxEvent.java | 31 +- .../incoming/users/UserSaveLookEvent.java | 19 +- .../incoming/users/UserWearBadgeEvent.java | 23 +- .../wired/WiredConditionSaveDataEvent.java | 18 +- .../wired/WiredEffectSaveDataEvent.java | 18 +- .../wired/WiredTriggerSaveDataEvent.java | 18 +- .../messages/outgoing/MessageComposer.java | 10 +- .../eu/habbo/messages/outgoing/Outgoing.java | 28 +- .../achievements/AchievementListComposer.java | 19 +- .../AchievementProgressComposer.java | 15 +- .../AchievementUnlockedComposer.java | 9 +- .../TalentLevelUpdateComposer.java | 22 +- .../talenttrack/TalentTrackComposer.java | 104 +- .../CameraCompetitionStatusComposer.java | 9 +- .../outgoing/camera/CameraPriceComposer.java | 9 +- .../CameraPublishWaitMessageComposer.java | 12 +- .../CameraPurchaseSuccesfullComposer.java | 6 +- .../CameraRoomThumbnailSavedComposer.java | 6 +- .../outgoing/camera/CameraURLComposer.java | 9 +- .../catalog/AlertLimitedSoldOutComposer.java | 6 +- .../catalog/AlertPurchaseFailedComposer.java | 9 +- .../AlertPurchaseUnavailableComposer.java | 9 +- .../outgoing/catalog/CatalogModeComposer.java | 9 +- .../outgoing/catalog/CatalogPageComposer.java | 31 +- .../catalog/CatalogPagesListComposer.java | 28 +- .../catalog/CatalogSearchResultComposer.java | 9 +- .../catalog/CatalogUpdatedComposer.java | 6 +- .../catalog/ClubCenterDataComposer.java | 9 +- .../outgoing/catalog/ClubDataComposer.java | 21 +- .../outgoing/catalog/ClubGiftsComposer.java | 43 +- .../outgoing/catalog/DiscountComposer.java | 6 +- .../catalog/GiftConfigurationComposer.java | 12 +- .../catalog/GiftReceiverNotFoundComposer.java | 6 +- .../catalog/NotEnoughPointsTypeComposer.java | 9 +- .../PetBoughtNotificationComposer.java | 9 +- .../outgoing/catalog/PetBreedsComposer.java | 14 +- .../catalog/PetNameErrorComposer.java | 9 +- .../outgoing/catalog/PurchaseOKComposer.java | 19 +- .../catalog/RecyclerCompleteComposer.java | 9 +- .../catalog/RecyclerLogicComposer.java | 12 +- .../catalog/RedeemVoucherErrorComposer.java | 9 +- .../catalog/RedeemVoucherOKComposer.java | 6 +- .../catalog/ReloadRecyclerComposer.java | 6 +- .../catalog/TargetedOfferComposer.java | 9 +- .../MarketplaceBuyErrorComposer.java | 9 +- .../MarketplaceCancelSaleComposer.java | 9 +- .../MarketplaceConfigComposer.java | 6 +- .../MarketplaceItemInfoComposer.java | 9 +- .../MarketplaceItemPostedComposer.java | 9 +- .../MarketplaceOffersComposer.java | 23 +- .../MarketplaceOwnItemsComposer.java | 36 +- .../MarketplaceSellItemComposer.java | 9 +- .../crafting/CraftableProductsComposer.java | 15 +- .../crafting/CraftingRecipeComposer.java | 12 +- .../CraftingRecipesAvailableComposer.java | 9 +- .../crafting/CraftingResultComposer.java | 15 +- .../calendar/AdventCalendarDataComposer.java | 39 +- .../AdventCalendarProductComposer.java | 9 +- .../mysticbox/MysticBoxCloseComposer.java | 6 +- .../mysticbox/MysticBoxPrizeComposer.java | 9 +- .../mysticbox/MysticBoxStartOpenComposer.java | 6 +- .../NewYearResolutionCompletedComposer.java | 9 +- .../resolution/NewYearResolutionComposer.java | 26 +- .../NewYearResolutionProgressComposer.java | 9 +- .../FloorPlanEditorBlockedTilesComposer.java | 12 +- .../FloorPlanEditorDoorSettingsComposer.java | 9 +- .../friends/FriendChatMessageComposer.java | 21 +- .../friends/FriendFindingRoomComposer.java | 9 +- .../friends/FriendNotificationComposer.java | 9 +- .../friends/FriendRequestComposer.java | 9 +- .../friends/FriendRequestErrorComposer.java | 9 +- .../outgoing/friends/FriendsComposer.java | 16 +- .../friends/LoadFriendRequestsComposer.java | 15 +- .../friends/MessengerInitComposer.java | 16 +- .../friends/RemoveFriendComposer.java | 15 +- .../outgoing/friends/RoomInviteComposer.java | 9 +- .../friends/RoomInviteErrorComposer.java | 15 +- .../outgoing/friends/StalkErrorComposer.java | 9 +- .../friends/UpdateFriendComposer.java | 19 +- .../friends/UserSearchResultComposer.java | 29 +- .../GameCenterAccountInfoComposer.java | 9 +- ...nterAchievementsConfigurationComposer.java | 16 +- .../gamecenter/GameCenterGameComposer.java | 9 +- .../GameCenterGameListComposer.java | 6 +- .../basejump/BaseJumpJoinQueueComposer.java | 9 +- .../basejump/BaseJumpLeaveQueueComposer.java | 6 +- .../basejump/BaseJumpLoadGameComposer.java | 18 +- .../basejump/BaseJumpLoadGameURLComposer.java | 6 +- .../basejump/BaseJumpUnloadGameComposer.java | 6 +- .../generic/MinimailCountComposer.java | 6 +- ...ckMonthlyClubGiftNotificationComposer.java | 9 +- .../generic/alerts/BotErrorComposer.java | 9 +- .../generic/alerts/BubbleAlertComposer.java | 18 +- .../generic/alerts/BubbleAlertKeys.java | 6 +- .../alerts/CustomNotificationComposer.java | 9 +- .../generic/alerts/GenericAlertComposer.java | 12 +- .../alerts/GenericErrorMessagesComposer.java | 9 +- .../alerts/HotelClosedAndOpensComposer.java | 9 +- .../HotelClosesAndWillOpenAtComposer.java | 9 +- ...elWillCloseInMinutesAndBackInComposer.java | 9 +- .../HotelWillCloseInMinutesComposer.java | 9 +- .../alerts/MessagesForYouComposer.java | 18 +- .../generic/alerts/PetErrorComposer.java | 9 +- .../StaffAlertAndOpenHabboWayComposer.java | 9 +- ...fAlertWIthLinkAndOpenHabboWayComposer.java | 9 +- .../alerts/StaffAlertWithLinkComposer.java | 9 +- .../generic/alerts/UpdateFailedComposer.java | 9 +- .../outgoing/generic/testcomposer.java | 6 +- .../GuardianNewReportReceivedComposer.java | 7 +- .../GuardianVotingRequestedComposer.java | 15 +- .../GuardianVotingResultComposer.java | 14 +- .../guardians/GuardianVotingTimeEnded.java | 6 +- .../GuardianVotingVotesComposer.java | 12 +- .../guides/BullyReportClosedComposer.java | 9 +- .../guides/GuideSessionAttachedComposer.java | 9 +- .../guides/GuideSessionDetachedComposer.java | 6 +- .../guides/GuideSessionEndedComposer.java | 9 +- .../guides/GuideSessionErrorComposer.java | 15 +- ...uideSessionInvitedToGuideRoomComposer.java | 9 +- .../guides/GuideSessionMessageComposer.java | 9 +- .../GuideSessionPartnerIsPlayingComposer.java | 9 +- .../GuideSessionPartnerIsTypingComposer.java | 9 +- .../GuideSessionRequesterRoomComposer.java | 9 +- .../guides/GuideSessionStartedComposer.java | 9 +- .../outgoing/guides/GuideToolsComposer.java | 9 +- .../GuildAcceptMemberErrorComposer.java | 9 +- .../outgoing/guilds/GuildBoughtComposer.java | 9 +- .../guilds/GuildBuyRoomsComposer.java | 12 +- .../GuildConfirmRemoveMemberComposer.java | 9 +- .../guilds/GuildEditFailComposer.java | 9 +- .../GuildFavoriteRoomUserUpdateComposer.java | 9 +- .../guilds/GuildFurniWidgetComposer.java | 9 +- .../outgoing/guilds/GuildInfoComposer.java | 9 +- .../guilds/GuildJoinErrorComposer.java | 9 +- .../outgoing/guilds/GuildListComposer.java | 12 +- .../outgoing/guilds/GuildManageComposer.java | 19 +- .../guilds/GuildMemberUpdateComposer.java | 11 +- .../outgoing/guilds/GuildMembersComposer.java | 12 +- .../outgoing/guilds/GuildPartsComposer.java | 21 +- .../GuildRefreshMembersListComposer.java | 9 +- .../guilds/RemoveGuildFromRoomComposer.java | 9 +- .../forums/GuildForumAddCommentComposer.java | 6 +- .../forums/GuildForumCommentsComposer.java | 13 +- .../guilds/forums/GuildForumDataComposer.java | 141 +- .../guilds/forums/GuildForumListComposer.java | 11 +- .../GuildForumThreadMessagesComposer.java | 9 +- .../forums/GuildForumThreadsComposer.java | 22 +- ...uildForumsUnreadMessagesCountComposer.java | 9 +- .../forums/PostUpdateMessageComposer.java | 9 +- .../forums/ThreadUpdatedMessageComposer.java | 2 +- .../habboway/HabboWayQuizComposer1.java | 12 +- .../habboway/HabboWayQuizComposer2.java | 12 +- .../habboway/nux/NewUserGiftComposer.java | 15 +- .../habboway/nux/NewUserIdentityComposer.java | 9 +- .../habboway/nux/NuxAlertComposer.java | 9 +- .../handshake/BannerTokenComposer.java | 10 +- .../handshake/ConnectionErrorComposer.java | 6 +- .../handshake/DebugConsoleComposer.java | 9 +- .../outgoing/handshake/MachineIDComposer.java | 9 +- .../outgoing/handshake/PongComposer.java | 9 +- .../handshake/SecureLoginOKComposer.java | 6 +- .../handshake/SessionRightsComposer.java | 6 +- .../handshake/SomeConnectionComposer.java | 6 +- .../outgoing/hotelview/BonusRareComposer.java | 9 +- .../hotelview/HallOfFameComposer.java | 13 +- .../HotelViewBadgeButtonConfigComposer.java | 9 +- .../HotelViewCatalogPageExpiringComposer.java | 9 +- .../HotelViewCommunityGoalComposer.java | 12 +- .../outgoing/hotelview/HotelViewComposer.java | 6 +- .../HotelViewConcurrentUsersComposer.java | 15 +- .../HotelViewCustomTimerComposer.java | 9 +- .../hotelview/HotelViewDataComposer.java | 9 +- ...HotelViewExpiringCatalogPageCommposer.java | 9 +- ...elViewHideCommunityVoteButtonComposer.java | 9 +- .../HotelViewNextLTDAvailableComposer.java | 9 +- .../outgoing/hotelview/NewsListComposer.java | 9 +- .../outgoing/inventory/AddBotComposer.java | 9 +- .../inventory/AddHabboItemComposer.java | 39 +- .../outgoing/inventory/AddPetComposer.java | 9 +- .../inventory/EffectsListAddComposer.java | 9 +- .../EffectsListEffectEnableComposer.java | 9 +- .../inventory/EffectsListRemoveComposer.java | 9 +- .../InventoryAchievementsComposer.java | 18 +- .../inventory/InventoryBadgesComposer.java | 19 +- .../inventory/InventoryBotsComposer.java | 12 +- .../inventory/InventoryItemsComposer.java | 49 +- .../inventory/InventoryPetsComposer.java | 19 +- .../inventory/InventoryRefreshComposer.java | 6 +- .../InventoryUpdateItemComposer.java | 35 +- .../outgoing/inventory/RemoveBotComposer.java | 9 +- .../inventory/RemoveHabboItemComposer.java | 9 +- .../outgoing/inventory/RemovePetComposer.java | 9 +- .../inventory/UserEffectsListComposer.java | 18 +- .../modtool/BullyReportRequestComposer.java | 18 +- .../modtool/BullyReportedMessageComposer.java | 9 +- .../modtool/CfhTopicsMessageComposer.java | 18 +- .../HelperRequestDisabledComposer.java | 6 +- .../outgoing/modtool/ModToolComposer.java | 58 +- .../modtool/ModToolIssueChatlogComposer.java | 37 +- .../modtool/ModToolIssueHandledComposer.java | 12 +- ...ModToolIssueHandlerDimensionsComposer.java | 9 +- .../modtool/ModToolIssueInfoComposer.java | 9 +- .../ModToolIssueResponseAlertComposer.java | 9 +- .../modtool/ModToolIssueUpdateComposer.java | 9 +- .../ModToolReportReceivedAlertComposer.java | 9 +- .../modtool/ModToolRoomChatlogComposer.java | 14 +- .../modtool/ModToolRoomInfoComposer.java | 15 +- .../modtool/ModToolSanctionInfoComposer.java | 6 +- .../modtool/ModToolUserChatlogComposer.java | 15 +- .../modtool/ModToolUserInfoComposer.java | 18 +- .../ModToolUserRoomVisitsComposer.java | 12 +- .../modtool/ReportRoomFormComposer.java | 13 +- .../navigator/CanCreateEventComposer.java | 6 +- .../navigator/CanCreateRoomComposer.java | 9 +- ...NewNavigatorCategoryUserCountComposer.java | 12 +- ...wNavigatorCollapsedCategoriesComposer.java | 6 +- .../NewNavigatorEventCategoriesComposer.java | 6 +- .../NewNavigatorLiftedRoomsComposer.java | 6 +- .../NewNavigatorMetaDataComposer.java | 6 +- .../NewNavigatorSavedSearchesComposer.java | 6 +- .../NewNavigatorSearchResultsComposer.java | 16 +- .../NewNavigatorSettingsComposer.java | 9 +- .../OpenRoomCreationWindowComposer.java | 6 +- .../navigator/PrivateRoomsComposer.java | 16 +- .../navigator/RoomCategoriesComposer.java | 19 +- .../navigator/RoomCreatedComposer.java | 9 +- .../outgoing/navigator/TagsComposer.java | 12 +- .../outgoing/polls/PollQuestionsComposer.java | 12 +- .../outgoing/polls/PollStartComposer.java | 9 +- .../infobus/SimplePollAnswerComposer.java | 9 +- .../infobus/SimplePollAnswersComposer.java | 9 +- .../infobus/SimplePollStartComposer.java | 9 +- .../quests/QuestCompletedComposer.java | 18 +- .../outgoing/quests/QuestComposer.java | 9 +- .../outgoing/quests/QuestExpiredComposer.java | 9 +- .../outgoing/quests/QuestionInfoComposer.java | 6 +- .../outgoing/quests/QuestsComposer.java | 21 +- .../BotForceOpenContextMenuComposer.java | 9 +- .../outgoing/rooms/BotSettingsComposer.java | 38 +- .../rooms/DoorbellAddUserComposer.java | 10 +- .../rooms/FavoriteRoomChangedComposer.java | 9 +- .../outgoing/rooms/FloodCounterComposer.java | 9 +- .../outgoing/rooms/ForwardToRoomComposer.java | 9 +- .../outgoing/rooms/FreezeLivesComposer.java | 9 +- .../outgoing/rooms/HideDoorbellComposer.java | 9 +- .../rooms/KnockKnockUnknownComposer.java | 9 +- .../rooms/RoomAccessDeniedComposer.java | 9 +- .../rooms/RoomAddRightsListComposer.java | 9 +- .../rooms/RoomBannedUsersComposer.java | 26 +- .../rooms/RoomChatSettingsComposer.java | 10 +- .../outgoing/rooms/RoomDataComposer.java | 50 +- .../rooms/RoomEditSettingsErrorComposer.java | 9 +- .../rooms/RoomEnterErrorComposer.java | 28 +- .../outgoing/rooms/RoomEntryInfoComposer.java | 9 +- .../rooms/RoomFilterWordsComposer.java | 18 +- .../RoomFloorThicknessUpdatedComposer.java | 9 +- .../outgoing/rooms/RoomHeightMapComposer.java | 9 +- .../outgoing/rooms/RoomModelComposer.java | 9 +- .../outgoing/rooms/RoomMutedComposer.java | 9 +- .../outgoing/rooms/RoomNoRightsComposer.java | 6 +- .../outgoing/rooms/RoomOpenComposer.java | 6 +- .../outgoing/rooms/RoomOwnerComposer.java | 6 +- .../outgoing/rooms/RoomPaintComposer.java | 9 +- .../outgoing/rooms/RoomPaneComposer.java | 10 +- .../rooms/RoomQueueStatusMessage.java | 6 +- .../rooms/RoomRelativeMapComposer.java | 17 +- .../rooms/RoomRemoveRightsListComposer.java | 9 +- .../outgoing/rooms/RoomRightsComposer.java | 9 +- .../rooms/RoomRightsListComposer.java | 12 +- .../outgoing/rooms/RoomScoreComposer.java | 9 +- .../outgoing/rooms/RoomSettingsComposer.java | 21 +- .../rooms/RoomSettingsSavedComposer.java | 9 +- .../rooms/RoomSettingsUpdatedComposer.java | 9 +- .../outgoing/rooms/RoomThicknessComposer.java | 9 +- .../rooms/UpdateStackHeightComposer.java | 22 +- .../rooms/items/AddFloorItemComposer.java | 9 +- .../rooms/items/AddWallItemComposer.java | 9 +- .../items/FloorItemOnRollerComposer.java | 9 +- .../rooms/items/FloorItemUpdateComposer.java | 9 +- .../rooms/items/ItemExtraDataComposer.java | 9 +- .../rooms/items/ItemIntStateComposer.java | 9 +- .../rooms/items/ItemStateComposer.java | 16 +- .../rooms/items/ItemsDataUpdateComposer.java | 12 +- .../rooms/items/MoodLightDataComposer.java | 24 +- .../rooms/items/PostItDataComposer.java | 12 +- .../items/PostItStickyPoleOpenComposer.java | 9 +- .../items/PresentItemOpenedComposer.java | 9 +- .../rooms/items/RemoveFloorItemComposer.java | 12 +- .../rooms/items/RemoveWallItemComposer.java | 9 +- .../rooms/items/RoomFloorItemsComposer.java | 22 +- .../rooms/items/RoomWallItemsComposer.java | 25 +- .../UpdateStackHeightTileHeightComposer.java | 9 +- .../rooms/items/WallItemUpdateComposer.java | 9 +- .../items/jukebox/JukeBoxMySongsComposer.java | 12 +- .../JukeBoxNowPlayingMessageComposer.java | 16 +- .../JukeBoxPlayListAddSongComposer.java | 9 +- .../jukebox/JukeBoxPlayListComposer.java | 12 +- .../JukeBoxPlayListUpdatedComposer.java | 15 +- .../jukebox/JukeBoxPlaylistFullComposer.java | 6 +- .../jukebox/JukeBoxTrackCodeComposer.java | 9 +- .../jukebox/JukeBoxTrackDataComposer.java | 12 +- .../LoveLockFurniFinishedComposer.java | 9 +- .../LoveLockFurniFriendConfirmedComposer.java | 9 +- .../lovelock/LoveLockFurniStartComposer.java | 9 +- .../RentableSpaceInfoComposer.java | 14 +- .../RentableSpaceUnknown2Composer.java | 9 +- .../RentableSpaceUnknownComposer.java | 9 +- .../youtube/YoutubeDisplayListComposer.java | 12 +- .../items/youtube/YoutubeVideoComposer.java | 9 +- .../CantScratchPetNotOldEnoughComposer.java | 9 +- .../rooms/pets/PetInformationComposer.java | 29 +- .../rooms/pets/PetLevelUpComposer.java | 9 +- .../rooms/pets/PetLevelUpdatedComposer.java | 9 +- .../rooms/pets/PetPackageComposer.java | 9 +- .../PetPackageNameValidationComposer.java | 9 +- .../rooms/pets/PetStatusUpdateComposer.java | 10 +- .../rooms/pets/PetTrainingPanelComposer.java | 21 +- .../outgoing/rooms/pets/RoomPetComposer.java | 24 +- .../rooms/pets/RoomPetExperienceComposer.java | 9 +- .../pets/RoomPetHorseFigureComposer.java | 16 +- .../rooms/pets/RoomPetRespectComposer.java | 12 +- .../pets/breeding/PetBreedingCompleted.java | 9 +- .../breeding/PetBreedingFailedComposer.java | 9 +- .../breeding/PetBreedingResultComposer.java | 50 +- .../breeding/PetBreedingStartComposer.java | 9 +- .../PetBreedingStartFailedComposer.java | 9 +- .../PromoteOwnRoomsListComposer.java | 17 +- .../RoomPromotionMessageComposer.java | 16 +- .../users/ChangeNameUpdatedComposer.java | 9 +- .../rooms/users/RoomUnitIdleComposer.java | 9 +- .../rooms/users/RoomUnitOnRollerComposer.java | 21 +- .../users/RoomUnitUpdateUsernameComposer.java | 9 +- .../rooms/users/RoomUserActionComposer.java | 9 +- .../rooms/users/RoomUserDanceComposer.java | 9 +- .../rooms/users/RoomUserDataComposer.java | 9 +- .../rooms/users/RoomUserEffectComposer.java | 13 +- .../rooms/users/RoomUserHandItemComposer.java | 9 +- .../rooms/users/RoomUserIgnoredComposer.java | 9 +- .../users/RoomUserNameChangedComposer.java | 12 +- .../RoomUserReceivedHandItemComposer.java | 9 +- .../rooms/users/RoomUserRemoveComposer.java | 9 +- .../users/RoomUserRemoveRightsComposer.java | 9 +- .../rooms/users/RoomUserRespectComposer.java | 9 +- .../rooms/users/RoomUserShoutComposer.java | 11 +- .../rooms/users/RoomUserStatusComposer.java | 48 +- .../rooms/users/RoomUserTagsComposer.java | 12 +- .../rooms/users/RoomUserTalkComposer.java | 11 +- .../rooms/users/RoomUserTypingComposer.java | 9 +- .../rooms/users/RoomUserUnbannedComposer.java | 9 +- .../rooms/users/RoomUserWhisperComposer.java | 12 +- .../users/RoomUsersAddGuildBadgeComposer.java | 9 +- .../rooms/users/RoomUsersComposer.java | 49 +- .../users/RoomUsersGuildBadgesComposer.java | 15 +- .../trading/OtherTradingDisabledComposer.java | 6 +- .../trading/TradeAcceptedComposer.java | 9 +- .../trading/TradeCloseWindowComposer.java | 6 +- .../outgoing/trading/TradeClosedComposer.java | 9 +- .../trading/TradeCompleteComposer.java | 6 +- .../outgoing/trading/TradeStartComposer.java | 16 +- .../trading/TradeStartFailComposer.java | 12 +- .../outgoing/trading/TradeUpdateComposer.java | 17 +- .../TradingWaitingConfirmComposer.java | 6 +- .../trading/YouTradingDisabledComposer.java | 6 +- .../unknown/BuildersClubExpiredComposer.java | 6 +- .../unknown/CloseWebPageComposer.java | 6 +- .../CompetitionEntrySubmitResultComposer.java | 21 +- .../ConvertedForwardToRoomComposer.java | 9 +- .../unknown/EpicPopupFrameComposer.java | 9 +- .../outgoing/unknown/ErrorLoginComposer.java | 9 +- .../unknown/ExtendClubMessageComposer.java | 29 +- .../outgoing/unknown/HabboMallComposer.java | 6 +- .../unknown/IgnoredUsersComposer.java | 6 +- .../unknown/MessengerErrorComposer.java | 12 +- .../unknown/MinimailNewMessageComposer.java | 6 +- .../outgoing/unknown/ModToolComposerOne.java | 6 +- .../unknown/ModToolSanctionDataComposer.java | 18 +- .../MostUselessErrorAlertComposer.java | 6 +- .../unknown/MysteryPrizeComposer.java | 6 +- .../unknown/RemoveRoomEventComposer.java | 6 +- .../RentableItemBuyOutPriceComposer.java | 9 +- .../outgoing/unknown/RoomAdErrorComposer.java | 9 +- .../RoomCategoryUpdateMessageComposer.java | 9 +- .../RoomMessagesPostedCountComposer.java | 9 +- .../unknown/RoomUnknown3Composer.java | 6 +- .../RoomUserQuestionAnsweredComposer.java | 12 +- .../unknown/SnowWarsAddUserComposer.java | 6 +- .../outgoing/unknown/SnowWarsCompose1.java | 10 +- .../SnowWarsFullGameStatusComposer.java | 34 +- .../SnowWarsGameStartedErrorComposer.java | 6 +- .../unknown/SnowWarsGenericErrorComposer.java | 6 +- .../unknown/SnowWarsInitGameArena.java | 6 +- .../unknown/SnowWarsJoinErrorComposer.java | 6 +- .../unknown/SnowWarsLevelDataComposer.java | 6 +- .../unknown/SnowWarsLoadingArenaComposer.java | 12 +- .../unknown/SnowWarsLongDataComposer.java | 6 +- .../unknown/SnowWarsOnGameEnding.java | 52 +- .../unknown/SnowWarsOnStageEnding.java | 6 +- .../SnowWarsOnStageRunningComposer.java | 6 +- .../unknown/SnowWarsOnStageStartComposer.java | 6 +- .../SnowWarsPlayNowWindowComposer.java | 6 +- .../unknown/SnowWarsPreviousRoomComposer.java | 6 +- .../unknown/SnowWarsQuePositionComposer.java | 6 +- .../unknown/SnowWarsQuickJoinComposer.java | 6 +- .../unknown/SnowWarsRemoveUserComposer.java | 6 +- .../unknown/SnowWarsResetTimerComposer.java | 6 +- .../unknown/SnowWarsStartLobbyCounter.java | 6 +- .../unknown/SnowWarsUnknownComposer.java | 6 +- .../unknown/SnowWarsUserChatComposer.java | 6 +- .../SnowWarsUserEnteredArenaComposer.java | 19 +- .../SnowWarsUserExitArenaComposer.java | 6 +- .../TalentTrackEmailFailedComposer.java | 9 +- .../TalentTrackEmailVerifiedComposer.java | 9 +- .../unknown/UnknownAdManagerComposer.java | 9 +- .../unknown/UnknownAvatarEditorComposer.java | 9 +- .../UnknownCatalogPageOfferComposer.java | 9 +- .../unknown/UnknownCompetitionComposer.java | 9 +- .../outgoing/unknown/UnknownComposer4.java | 6 +- .../outgoing/unknown/UnknownComposer5.java | 6 +- .../outgoing/unknown/UnknownComposer8.java | 9 +- .../unknown/UnknownFurniModelComposer.java | 9 +- .../unknown/UnknownGuild2Composer.java | 9 +- .../unknown/UnknownGuildComposer3.java | 9 +- .../unknown/UnknownHabboWayQuizComposer.java | 12 +- .../unknown/UnknownHelperComposer.java | 6 +- .../outgoing/unknown/UnknownHintComposer.java | 9 +- .../UnknownMessengerErrorComposer.java | 9 +- .../unknown/UnknownPollQuestionComposer.java | 12 +- .../unknown/UnknownRoomDesktopComposer.java | 12 +- .../unknown/UnknownRoomViewerComposer.java | 12 +- .../unknown/UnknownStatusComposer.java | 11 +- .../unknown/UnknownTradeComposer.java | 6 +- .../unknown/UnkownPetPackageComposer.java | 12 +- .../unknown/UserClassificationComposer.java | 12 +- .../unknown/VipTutorialsStartComposer.java | 6 +- .../unknown/WatchAndEarnRewardComposer.java | 9 +- .../outgoing/unknown/WelcomeGiftComposer.java | 9 +- .../unknown/WelcomeGiftErrorComposer.java | 15 +- .../outgoing/users/AddUserBadgeComposer.java | 9 +- .../users/ChangeNameCheckResultComposer.java | 12 +- .../users/ClubGiftReceivedComposer.java | 12 +- .../users/FavoriteRoomsCountComposer.java | 15 +- .../users/MeMenuSettingsComposer.java | 9 +- .../outgoing/users/MutedWhisperComposer.java | 9 +- .../users/ProfileFriendsComposer.java | 35 +- .../users/UpdateUserLookComposer.java | 9 +- .../users/UserAchievementScoreComposer.java | 9 +- .../outgoing/users/UserBCLimitsComposer.java | 6 +- .../outgoing/users/UserBadgesComposer.java | 15 +- .../users/UserCitizinShipComposer.java | 9 +- .../outgoing/users/UserClothesComposer.java | 21 +- .../outgoing/users/UserClubComposer.java | 26 +- .../outgoing/users/UserCreditsComposer.java | 6 +- .../outgoing/users/UserCurrencyComposer.java | 18 +- .../outgoing/users/UserDataComposer.java | 11 +- .../outgoing/users/UserHomeRoomComposer.java | 9 +- .../outgoing/users/UserPerksComposer.java | 9 +- .../users/UserPermissionsComposer.java | 9 +- .../outgoing/users/UserPointsComposer.java | 9 +- .../outgoing/users/UserProfileComposer.java | 57 +- .../outgoing/users/UserWardrobeComposer.java | 12 +- .../VerifyMobileNumberComposer.java | 6 +- .../VerifyMobilePhoneCodeWindowComposer.java | 9 +- .../VerifyMobilePhoneDoneComposer.java | 9 +- .../VerifyMobilePhoneWindowComposer.java | 9 +- .../wired/WiredConditionDataComposer.java | 9 +- .../wired/WiredEffectDataComposer.java | 9 +- .../outgoing/wired/WiredOpenComposer.java | 9 +- .../wired/WiredRewardAlertComposer.java | 9 +- .../outgoing/wired/WiredSavedComposer.java | 6 +- .../wired/WiredTriggerDataComposer.java | 9 +- .../com/eu/habbo/messages/rcon/AlertUser.java | 16 +- .../habbo/messages/rcon/ChangeRoomOwner.java | 15 +- .../messages/rcon/CreateModToolTicket.java | 12 +- .../habbo/messages/rcon/DisconnectUser.java | 26 +- .../habbo/messages/rcon/ExecuteCommand.java | 22 +- .../eu/habbo/messages/rcon/ForwardUser.java | 25 +- .../eu/habbo/messages/rcon/FriendRequest.java | 34 +- .../com/eu/habbo/messages/rcon/GiveBadge.java | 58 +- .../eu/habbo/messages/rcon/GiveCredits.java | 28 +- .../eu/habbo/messages/rcon/GivePixels.java | 28 +- .../eu/habbo/messages/rcon/GivePoints.java | 28 +- .../eu/habbo/messages/rcon/GiveRespect.java | 26 +- .../eu/habbo/messages/rcon/HotelAlert.java | 27 +- .../eu/habbo/messages/rcon/IgnoreUser.java | 26 +- .../habbo/messages/rcon/ImageAlertUser.java | 33 +- .../habbo/messages/rcon/ImageHotelAlert.java | 35 +- .../com/eu/habbo/messages/rcon/MuteUser.java | 36 +- .../messages/rcon/ProgressAchievement.java | 26 +- .../eu/habbo/messages/rcon/RCONMessage.java | 24 +- .../com/eu/habbo/messages/rcon/SendGift.java | 51 +- .../habbo/messages/rcon/SendRoomBundle.java | 28 +- .../com/eu/habbo/messages/rcon/SetMotto.java | 29 +- .../com/eu/habbo/messages/rcon/SetRank.java | 22 +- .../eu/habbo/messages/rcon/StaffAlert.java | 12 +- .../com/eu/habbo/messages/rcon/StalkUser.java | 30 +- .../com/eu/habbo/messages/rcon/TalkUser.java | 34 +- .../eu/habbo/messages/rcon/UpdateCatalog.java | 12 +- .../eu/habbo/messages/rcon/UpdateUser.java | 82 +- .../habbo/messages/rcon/UpdateWordfilter.java | 12 +- .../java/com/eu/habbo/networking/Server.java | 55 +- .../habbo/networking/camera/CameraClient.java | 54 +- .../networking/camera/CameraDecoder.java | 12 +- .../networking/camera/CameraHandler.java | 42 +- .../camera/CameraIncomingMessage.java | 48 +- .../networking/camera/CameraMessage.java | 9 +- .../camera/CameraOutgoingMessage.java | 131 +- .../camera/CameraPacketHandler.java | 39 +- .../messages/CameraOutgoingHeaders.java | 3 +- .../CameraAuthenticationTicketEvent.java | 12 +- .../incoming/CameraLoginStatusEvent.java | 39 +- .../incoming/CameraResultURLEvent.java | 28 +- .../CameraRoomThumbnailGeneratedEvent.java | 12 +- .../incoming/CameraUpdateNotification.java | 23 +- .../outgoing/CameraLoginComposer.java | 9 +- .../outgoing/CameraRenderImageComposer.java | 11 +- .../gameserver/GameByteDecoder.java | 15 +- .../gameserver/GameMessageHandler.java | 40 +- .../networking/gameserver/GameServer.java | 21 +- .../networking/rconserver/RCONServer.java | 103 +- .../rconserver/RCONServerHandler.java | 26 +- src/main/java/com/eu/habbo/plugin/Event.java | 15 +- .../com/eu/habbo/plugin/EventListener.java | 3 +- .../com/eu/habbo/plugin/EventPriority.java | 9 +- .../java/com/eu/habbo/plugin/HabboPlugin.java | 13 +- .../plugin/HabboPluginConfiguration.java | 3 +- .../com/eu/habbo/plugin/PluginManager.java | 490 +-- .../plugin/events/bots/BotChatEvent.java | 6 +- .../eu/habbo/plugin/events/bots/BotEvent.java | 6 +- .../plugin/events/bots/BotPickUpEvent.java | 6 +- .../plugin/events/bots/BotPlacedEvent.java | 6 +- .../plugin/events/bots/BotSavedChatEvent.java | 6 +- .../plugin/events/bots/BotSavedLookEvent.java | 10 +- .../plugin/events/bots/BotSavedNameEvent.java | 6 +- .../events/bots/BotServerItemEvent.java | 6 +- .../plugin/events/bots/BotShoutEvent.java | 6 +- .../plugin/events/bots/BotTalkEvent.java | 6 +- .../plugin/events/bots/BotWhisperEvent.java | 6 +- .../emulator/EmulatorConfigUpdatedEvent.java | 3 +- .../plugin/events/emulator/EmulatorEvent.java | 3 +- .../EmulatorLoadCatalogManagerEvent.java | 6 +- .../EmulatorLoadItemsManagerEvent.java | 6 +- .../events/emulator/EmulatorLoadedEvent.java | 6 +- .../emulator/EmulatorStartShutdownEvent.java | 6 +- .../events/emulator/EmulatorStoppedEvent.java | 6 +- .../emulator/SSOAuthenticationEvent.java | 6 +- .../furniture/FurnitureDiceRolledEvent.java | 6 +- .../events/furniture/FurnitureEvent.java | 6 +- .../events/furniture/FurnitureMovedEvent.java | 6 +- .../furniture/FurniturePickedUpEvent.java | 6 +- .../furniture/FurniturePlacedEvent.java | 6 +- .../furniture/FurnitureRedeemedEvent.java | 6 +- .../furniture/FurnitureRolledEvent.java | 6 +- .../furniture/FurnitureRoomTonerEvent.java | 6 +- .../furniture/FurnitureRotatedEvent.java | 6 +- .../events/furniture/FurnitureUserEvent.java | 6 +- .../wired/WiredConditionFailedEvent.java | 6 +- .../wired/WiredStackExecutedEvent.java | 6 +- .../wired/WiredStackTriggeredEvent.java | 6 +- .../habbo/plugin/events/games/GameEvent.java | 6 +- .../events/games/GameHabboJoinEvent.java | 6 +- .../events/games/GameHabboLeaveEvent.java | 6 +- .../plugin/events/games/GameStartedEvent.java | 6 +- .../plugin/events/games/GameStoppedEvent.java | 6 +- .../plugin/events/games/GameUserEvent.java | 6 +- .../guilds/GuildAcceptedMembershipEvent.java | 6 +- .../events/guilds/GuildChangedBadgeEvent.java | 6 +- .../guilds/GuildChangedColorsEvent.java | 6 +- .../events/guilds/GuildChangedNameEvent.java | 6 +- .../guilds/GuildChangedSettingsEvent.java | 6 +- .../guilds/GuildDeclinedMembershipEvent.java | 6 +- .../events/guilds/GuildDeletedEvent.java | 6 +- .../plugin/events/guilds/GuildEvent.java | 6 +- .../events/guilds/GuildFavoriteSetEvent.java | 6 +- .../events/guilds/GuildGivenAdminEvent.java | 6 +- .../events/guilds/GuildPurchasedEvent.java | 6 +- .../events/guilds/GuildRemovedAdminEvent.java | 6 +- .../guilds/GuildRemovedFavoriteEvent.java | 6 +- .../guilds/GuildRemovedMemberEvent.java | 6 +- .../events/inventory/InventoryEvent.java | 6 +- .../inventory/InventoryItemAddedEvent.java | 6 +- .../events/inventory/InventoryItemEvent.java | 6 +- .../inventory/InventoryItemRemovedEvent.java | 6 +- .../inventory/InventoryItemsAddedEvent.java | 6 +- .../events/marketplace/MarketPlaceEvent.java | 3 +- .../MarketPlaceItemCancelledEvent.java | 6 +- .../MarketPlaceItemOfferedEvent.java | 6 +- .../marketplace/MarketPlaceItemSoldEvent.java | 6 +- .../navigator/NavigatorPopularRoomsEvent.java | 6 +- .../navigator/NavigatorRoomCreatedEvent.java | 6 +- .../navigator/NavigatorRoomDeletedEvent.java | 6 +- .../events/navigator/NavigatorRoomsEvent.java | 6 +- .../navigator/NavigatorSearchResultEvent.java | 6 +- .../eu/habbo/plugin/events/pets/PetEvent.java | 6 +- .../plugin/events/pets/PetTalkEvent.java | 8 +- .../habbo/plugin/events/rooms/RoomEvent.java | 6 +- .../plugin/events/rooms/RoomLoadedEvent.java | 6 +- .../events/rooms/RoomUncachedEvent.java | 6 +- .../events/rooms/RoomUnloadedEvent.java | 6 +- .../events/rooms/RoomUnloadingEvent.java | 6 +- .../plugin/events/roomunit/RoomUnitEvent.java | 6 +- .../roomunit/RoomUnitLookAtPointEvent.java | 6 +- .../events/roomunit/RoomUnitSetGoalEvent.java | 9 +- .../plugin/events/support/SupportEvent.java | 6 +- .../support/SupportRoomActionEvent.java | 12 +- .../events/support/SupportTicketEvent.java | 6 +- .../SupportTicketStatusChangedEvent.java | 6 +- .../support/SupportUserAlertedEvent.java | 8 +- .../support/SupportUserAlertedReason.java | 6 +- .../support/SupportUserBannedEvent.java | 8 +- .../events/support/SupportUserKickEvent.java | 6 +- .../events/users/HabboAddedToRoomEvent.java | 6 +- .../plugin/events/users/UserCommandEvent.java | 6 +- .../plugin/events/users/UserCreditsEvent.java | 6 +- .../events/users/UserDisconnectEvent.java | 6 +- .../events/users/UserEnterRoomEvent.java | 6 +- .../habbo/plugin/events/users/UserEvent.java | 6 +- .../events/users/UserExecuteCommandEvent.java | 6 +- .../events/users/UserExitRoomEvent.java | 26 +- .../plugin/events/users/UserIdleEvent.java | 28 +- .../plugin/events/users/UserKickEvent.java | 6 +- .../plugin/events/users/UserLoginEvent.java | 6 +- .../events/users/UserNameChangedEvent.java | 6 +- .../events/users/UserPickGiftEvent.java | 6 +- .../plugin/events/users/UserPointsEvent.java | 8 +- .../events/users/UserPublishPictureEvent.java | 6 +- .../users/UserPurchasePictureEvent.java | 6 +- .../events/users/UserRankChangedEvent.java | 6 +- .../events/users/UserRegisteredEvent.java | 6 +- .../events/users/UserRespectedEvent.java | 6 +- .../events/users/UserRightsGivenEvent.java | 6 +- .../events/users/UserRightsTakenEvent.java | 6 +- .../plugin/events/users/UserRolledEvent.java | 6 +- .../events/users/UserSavedLookEvent.java | 6 +- .../events/users/UserSavedMottoEvent.java | 6 +- .../events/users/UserSavedSettingsEvent.java | 6 +- .../events/users/UserSavedWardrobeEvent.java | 6 +- .../plugin/events/users/UserSignEvent.java | 6 +- .../events/users/UserTakeStepEvent.java | 6 +- .../plugin/events/users/UserTalkEvent.java | 6 +- .../users/UserTriggerWordFilterEvent.java | 6 +- .../events/users/UserWiredRewardReceived.java | 6 +- .../achievements/UserAchievementEvent.java | 6 +- .../UserAchievementLeveledEvent.java | 6 +- .../UserAchievementProgressEvent.java | 6 +- .../users/catalog/UserCatalogEvent.java | 6 +- .../UserCatalogFurnitureBoughtEvent.java | 6 +- .../UserCatalogItemPurchasedEvent.java | 12 +- .../friends/UserAcceptFriendRequestEvent.java | 6 +- .../users/friends/UserFriendChatEvent.java | 6 +- .../events/users/friends/UserFriendEvent.java | 6 +- .../users/friends/UserRelationShipEvent.java | 6 +- .../friends/UserRequestFriendshipEvent.java | 6 +- .../habbo/threading/HabboExecutorService.java | 18 +- .../RejectedExecutionHandlerImpl.java | 6 +- .../com/eu/habbo/threading/ThreadPooling.java | 61 +- .../runnables/AchievementUpdater.java | 19 +- .../runnables/BackgroundAnimation.java | 19 +- .../runnables/BanzaiRandomTeleport.java | 10 +- .../runnables/BattleBanzaiTilesFlicker.java | 27 +- .../threading/runnables/BotFollowHabbo.java | 30 +- .../runnables/CameraClientAutoReconnect.java | 30 +- .../threading/runnables/CannonKickAction.java | 21 +- .../runnables/CannonResetCooldownAction.java | 12 +- .../runnables/ChannelReadHandler.java | 21 +- .../threading/runnables/ClearRentedSpace.java | 28 +- .../habbo/threading/runnables/CloseGate.java | 18 +- .../threading/runnables/CrackableExplode.java | 32 +- .../runnables/GuardianNotAccepted.java | 15 +- .../GuardianTicketFindMoreSlaves.java | 9 +- .../runnables/GuardianVotingFinish.java | 15 +- .../runnables/GuideFindNewHelper.java | 15 +- .../runnables/HabboGiveHandItemToHabbo.java | 16 +- .../runnables/HabboItemNewState.java | 12 +- .../runnables/InsertModToolIssue.java | 22 +- .../threading/runnables/KickBallAction.java | 42 +- .../runnables/LoadCustomHeightMap.java | 9 +- .../runnables/OneWayGateActionOne.java | 29 +- .../habbo/threading/runnables/OpenGift.java | 42 +- .../threading/runnables/PetClearPosture.java | 25 +- .../threading/runnables/PetEatAction.java | 38 +- .../threading/runnables/PetFollowHabbo.java | 30 +- .../runnables/QueryDeleteHabboBadge.java | 17 +- .../runnables/QueryDeleteHabboItem.java | 19 +- .../runnables/QueryDeleteHabboItems.java | 19 +- .../threading/runnables/RandomDiceNumber.java | 19 +- .../runnables/RemoveFloorItemTask.java | 11 +- .../threading/runnables/RoomTrashing.java | 96 +- .../runnables/RoomUnitGiveHanditem.java | 12 +- .../threading/runnables/RoomUnitKick.java | 12 +- .../threading/runnables/RoomUnitRidePet.java | 18 +- .../threading/runnables/RoomUnitTeleport.java | 23 +- .../RoomUnitTeleportWalkToAction.java | 38 +- .../RoomUnitVendingMachineAction.java | 38 +- .../runnables/RoomUnitWalkToLocation.java | 21 +- .../runnables/RoomUnitWalkToRoomUnit.java | 53 +- .../threading/runnables/SaveScoreForTeam.java | 19 +- .../runnables/SendRoomUnitEffectComposer.java | 8 +- .../threading/runnables/ShutdownEmulator.java | 16 +- .../runnables/TeleportInteraction.java | 66 +- .../runnables/UpdateModToolIssue.java | 16 +- .../threading/runnables/WiredExecuteTask.java | 25 +- .../runnables/WiredRepeatEffectTask.java | 15 +- .../threading/runnables/WiredResetTimers.java | 12 +- .../threading/runnables/YouAreAPirate.java | 141 +- .../runnables/freeze/FreezeClearEffects.java | 12 +- .../freeze/FreezeHandleSnowballExplosion.java | 69 +- .../freeze/FreezeResetExplosionTiles.java | 13 +- .../runnables/freeze/FreezeThrowSnowball.java | 11 +- .../runnables/hopper/HopperActionFive.java | 12 +- .../runnables/hopper/HopperActionFour.java | 9 +- .../runnables/hopper/HopperActionOne.java | 15 +- .../runnables/hopper/HopperActionThree.java | 18 +- .../runnables/hopper/HopperActionTwo.java | 29 +- .../teleport/TeleportActionFive.java | 18 +- .../teleport/TeleportActionFour.java | 12 +- .../runnables/teleport/TeleportActionOne.java | 15 +- .../teleport/TeleportActionThree.java | 25 +- .../runnables/teleport/TeleportActionTwo.java | 52 +- .../eu/habbo/util/callback/HTTPPostError.java | 8 - .../habbo/util/callback/HTTPVersionCheck.java | 10 - .../java/com/eu/habbo/util/crypto/ZIP.java | 16 +- .../com/eu/habbo/util/figure/FigureUtil.java | 34 +- .../habbo/util/imager/badges/BadgeImager.java | 354 +- .../eu/habbo/util/pathfinding/Rotation.java | 6 +- 1710 files changed, 20303 insertions(+), 37560 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 4c364d06..af521b00 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -7,7 +7,6 @@ import com.eu.habbo.core.TextsManager; import com.eu.habbo.core.consolecommands.ConsoleCommand; import com.eu.habbo.database.Database; import com.eu.habbo.habbohotel.GameEnvironment; -import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.gameserver.GameServer; import com.eu.habbo.networking.rconserver.RCONServer; @@ -17,7 +16,6 @@ import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent; import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent; import com.eu.habbo.threading.ThreadPooling; -import com.eu.habbo.threading.runnables.CameraClientAutoReconnect; import com.eu.habbo.util.imager.badges.BadgeImager; import java.io.BufferedReader; @@ -30,10 +28,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Random; -import java.util.zip.Checksum; -public final class Emulator -{ +public final class Emulator { public final static int MAJOR = 2; @@ -46,39 +42,39 @@ public final class Emulator public final static String PREVIEW = "RC-1"; - public static final String version = "Arcturus Morningstar"+ " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; + public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; + private static final String logo = + " \n" + + " __ ___ _ A R C T U R U S __ \n" + + " / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" + + " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" + + " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + + " /____/ \n"; public static String build = ""; - public static boolean isReady = false; - public static boolean isShuttingDown = false; - public static boolean stopped = false; - public static boolean debugging = false; + private static int timeStarted = 0; + private static Runtime runtime; + private static ConfigurationManager config; + private static TextsManager texts; + private static GameServer gameServer; + private static RCONServer rconServer; + private static CameraClient cameraClient; + private static Database database; + private static Logging logging; + private static ThreadPooling threading; + private static GameEnvironment gameEnvironment; + private static PluginManager pluginManager; + private static Random random; + private static BadgeImager badgeImager; - private static int timeStarted = 0; - private static Runtime runtime; - private static ConfigurationManager config; - private static TextsManager texts; - private static GameServer gameServer; - private static RCONServer rconServer; - private static CameraClient cameraClient; - private static Database database; - private static Logging logging; - private static ThreadPooling threading; - private static GameEnvironment gameEnvironment; - private static PluginManager pluginManager; - private static Random random; - private static BadgeImager badgeImager; - - static - { - Thread hook = new Thread(new Runnable() - { - public synchronized void run() - { + static { + Thread hook = new Thread(new Runnable() { + public synchronized void run() { Emulator.dispose(); } }); @@ -86,11 +82,8 @@ public final class Emulator Runtime.getRuntime().addShutdownHook(hook); } - - public static void main(String[] args) throws Exception - { - try - { + public static void main(String[] args) throws Exception { + try { Locale.setDefault(new Locale("en")); setBuild(); @@ -98,15 +91,14 @@ public final class Emulator ConsoleCommand.load(); Emulator.logging = new Logging(); Emulator.getLogging().logStart("\r" + Emulator.logo + - " Build: " + build + "\n"); + " Build: " + build + "\n"); random = new Random(); long startTime = System.nanoTime(); Emulator.runtime = Runtime.getRuntime(); Emulator.config = new ConfigurationManager("config.ini"); - if (Emulator.getConfig().getValue("username").isEmpty()) - { + if (Emulator.getConfig().getValue("username").isEmpty()) { Emulator.getLogging().logErrorLine("Please make sure you enter your forum login details!"); Thread.sleep(2000); } @@ -131,7 +123,7 @@ public final class Emulator Emulator.rconServer.initializePipeline(); Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - // Removed Wesleys Camera Server lol. + // Removed Wesleys Camera Server lol. /* if (Emulator.getConfig().getBoolean("camera.enabled")) { Emulator.getThreading().run(new CameraClientAutoReconnect()); @@ -144,8 +136,7 @@ public final class Emulator Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode"); - if (debugging) - { + if (debugging) { Emulator.getLogging().logDebugLine("Debugging Enabled!"); } @@ -153,17 +144,14 @@ public final class Emulator Emulator.isReady = true; Emulator.timeStarted = getIntUnixTimestamp(); - if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) - { + if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) { Emulator.getLogging().logStart("Emulator settings runtime.threads (" + Emulator.getConfig().getInt("runtime.threads") + ") can be increased to " + (Runtime.getRuntime().availableProcessors() * 2) + " to possibly increase performance."); } - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a Release Candidate for 2.1.0, if you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); @@ -173,56 +161,46 @@ public final class Emulator BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - while (!isShuttingDown && isReady) - { - try - { + while (!isShuttingDown && isReady) { + try { String line = reader.readLine(); - if (line != null) - { + if (line != null) { ConsoleCommand.handle(line); } System.out.println("Waiting for command: "); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } private static void setBuild() { - if(Emulator.class.getProtectionDomain().getCodeSource() == null) { + if (Emulator.class.getProtectionDomain().getCodeSource() == null) { build = "UNKNOWN"; return; } StringBuilder sb = new StringBuilder(); - try - { + try { String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath(); MessageDigest md = MessageDigest.getInstance("MD5");// MD5 FileInputStream fis = new FileInputStream(filepath); byte[] dataBytes = new byte[1024]; int nread = 0; - while((nread = fis.read(dataBytes)) != -1) + while ((nread = fis.read(dataBytes)) != -1) md.update(dataBytes, 0, nread); byte[] mdbytes = md.digest(); - for(int i=0; i RELOAD_HALL_OF_FAME) - { + if (time - LAST_HOF_RELOAD > RELOAD_HALL_OF_FAME) { Emulator.getGameEnvironment().getHotelViewManager().getHallOfFame().reload(); LAST_HOF_RELOAD = time; } - if (time - LAST_NL_RELOAD > RELOAD_NEWS_LIST) - { + if (time - LAST_NL_RELOAD > RELOAD_NEWS_LIST) { Emulator.getGameEnvironment().getHotelViewManager().getNewsList().reload(); LAST_NL_RELOAD = time; } - if (time - LAST_INACTIVE_ROOMS_CLEARED > REMOVE_INACTIVE_ROOMS) - { + if (time - LAST_INACTIVE_ROOMS_CLEARED > REMOVE_INACTIVE_ROOMS) { Emulator.getGameEnvironment().getRoomManager().clearInactiveRooms(); LAST_INACTIVE_ROOMS_CLEARED = time; } - if (time - LAST_INACTIVE_GUILDS_CLEARED > REMOVE_INACTIVE_GUILDS) - { + if (time - LAST_INACTIVE_GUILDS_CLEARED > REMOVE_INACTIVE_GUILDS) { Emulator.getGameEnvironment().getGuildManager().clearInactiveGuilds(); ForumThread.clearCache(); LAST_INACTIVE_GUILDS_CLEARED = time; } - if (time - LAST_INACTIVE_TOURS_CLEARED > REMOVE_INACTIVE_TOURS) - { + if (time - LAST_INACTIVE_TOURS_CLEARED > REMOVE_INACTIVE_TOURS) { Emulator.getGameEnvironment().getGuideManager().cleanup(); LAST_INACTIVE_TOURS_CLEARED = time; } - if (time - LAST_ERROR_LOGS_SAVED > SAVE_ERROR_LOGS) - { + if (time - LAST_ERROR_LOGS_SAVED > SAVE_ERROR_LOGS) { Emulator.getLogging().saveLogs(); LAST_ERROR_LOGS_SAVED = time; } - if (time - LAST_CALLBACK > CALLBACK_TIME) - { - // Emulator.getThreading().run(new HTTPPostStatus()); + if (time - LAST_CALLBACK > CALLBACK_TIME) { + // Emulator.getThreading().run(new HTTPPostStatus()); LAST_CALLBACK = time; } - if (time - LAST_DAILY_REFILL > Emulator.getConfig().getInt("hotel.refill.daily")) - { + if (time - LAST_DAILY_REFILL > Emulator.getConfig().getInt("hotel.refill.daily")) { this.refillDailyRespects(); LAST_DAILY_REFILL = time; } - if (time - LAST_HABBO_CACHE_CLEARED > CLEAR_CACHED_VALUES) - { + if (time - LAST_HABBO_CACHE_CLEARED > CLEAR_CACHED_VALUES) { this.clearCachedValues(); LAST_HABBO_CACHE_CLEARED = time; } @@ -147,15 +134,12 @@ public class CleanerThread implements Runnable { } - void databaseCleanup() - { + void databaseCleanup() { this.refillDailyRespects(); int time = Emulator.getIntUnixTimestamp(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (Statement statement = connection.createStatement()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (Statement statement = connection.createStatement()) { statement.execute("UPDATE users SET online = '0' WHERE online = '1'"); statement.execute("UPDATE rooms SET users = '0' WHERE users > 0"); statement.execute("DELETE FROM room_mutes WHERE ends < " + time); @@ -163,63 +147,47 @@ public class CleanerThread implements Runnable { statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL"); } - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) - { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) { statement.setInt(1, Emulator.getIntUnixTimestamp() - 86400); statement.execute(); } - try (Statement statement = connection.createStatement()) - { + try (Statement statement = connection.createStatement()) { statement.execute("DELETE FROM users_effects WHERE total <= 0"); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } Emulator.getLogging().logStart("Database -> Cleaned!"); } - public void refillDailyRespects() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET daily_respect_points = ?, daily_pet_respect_points = ?")) - { + public void refillDailyRespects() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET daily_respect_points = ?, daily_pet_respect_points = ?")) { statement.setInt(1, Emulator.getConfig().getInt("hotel.daily.respect")); statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets")); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if (Emulator.isReady) - { - for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) - { + if (Emulator.isReady) { + for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) { habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect"); habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets"); } } } - private void clearCachedValues() - { + private void clearCachedValues() { Habbo habbo; - for(Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { habbo = map.getValue(); - try - { - if (habbo != null) - { + try { + if (habbo != null) { habbo.clearCaches(); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/core/CommandLog.java b/src/main/java/com/eu/habbo/core/CommandLog.java index d6af2420..1f4cefbc 100644 --- a/src/main/java/com/eu/habbo/core/CommandLog.java +++ b/src/main/java/com/eu/habbo/core/CommandLog.java @@ -6,8 +6,7 @@ import com.eu.habbo.habbohotel.commands.Command; import java.sql.PreparedStatement; import java.sql.SQLException; -public class CommandLog implements Loggable -{ +public class CommandLog implements Loggable { public static final String insertQuery = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)"; private final int userId; @@ -17,8 +16,7 @@ public class CommandLog implements Loggable private final boolean succes; - public CommandLog(int userId, Command command, String params, boolean succes) - { + public CommandLog(int userId, Command command, String params, boolean succes) { this.userId = userId; this.command = command; this.params = params; @@ -26,8 +24,7 @@ public class CommandLog implements Loggable } @Override - public void log(PreparedStatement statement) throws SQLException - { + public void log(PreparedStatement statement) throws SQLException { statement.setInt(1, this.userId); statement.setInt(2, this.timestamp); statement.setString(3, this.command.getClass().getSimpleName()); diff --git a/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/src/main/java/com/eu/habbo/core/ConfigurationManager.java index c6fe2e22..446c028f 100644 --- a/src/main/java/com/eu/habbo/core/ConfigurationManager.java +++ b/src/main/java/com/eu/habbo/core/ConfigurationManager.java @@ -11,128 +11,95 @@ import java.sql.*; import java.util.Map; import java.util.Properties; -public class ConfigurationManager -{ - - public boolean loaded = false; - - - public boolean isLoading = false; - +public class ConfigurationManager { private final Properties properties; - private final String configurationPath; - - public ConfigurationManager(String configurationPath) throws Exception - { + public boolean loaded = false; + public boolean isLoading = false; + + public ConfigurationManager(String configurationPath) throws Exception { this.properties = new Properties(); this.configurationPath = configurationPath; this.reload(); } - public void reload() - { + public void reload() { this.isLoading = true; this.properties.clear(); InputStream input = null; - try - { + try { File f = new File(this.configurationPath); input = new FileInputStream(f); this.properties.load(input); - } - catch (IOException ex) - { + } catch (IOException ex) { Emulator.getLogging().logErrorLine("[CRITICAL] FAILED TO LOAD CONFIG FILE! (" + this.configurationPath + ")"); ex.printStackTrace(); - } - finally - { - if (input != null) - { - try - { + } finally { + if (input != null) { + try { input.close(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } } - if(this.loaded) - { + if (this.loaded) { this.loadFromDatabase(); } this.isLoading = false; Emulator.getLogging().logStart("Configuration Manager -> Loaded!"); - if (Emulator.getPluginManager() != null) - { + if (Emulator.getPluginManager() != null) { Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent()); } } - public void loadFromDatabase() - { + public void loadFromDatabase() { Emulator.getLogging().logStart("Loading configuration from database..."); long millis = System.currentTimeMillis(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) - { - if (statement.execute("SELECT * FROM emulator_settings")) - { - try (ResultSet set = statement.getResultSet()) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) { + if (statement.execute("SELECT * FROM emulator_settings")) { + try (ResultSet set = statement.getResultSet()) { + while (set.next()) { this.properties.put(set.getString("key"), set.getString("value")); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } Emulator.getLogging().logStart("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void saveToDatabase() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE emulator_settings SET `value` = ? WHERE `key` = ? LIMIT 1")) - { - for (Map.Entry entry : this.properties.entrySet()) - { + public void saveToDatabase() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE emulator_settings SET `value` = ? WHERE `key` = ? LIMIT 1")) { + for (Map.Entry entry : this.properties.entrySet()) { statement.setString(1, entry.getValue().toString()); statement.setString(2, entry.getKey().toString()); statement.executeUpdate(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public String getValue(String key) - { + public String getValue(String key) { return this.getValue(key, ""); } - public String getValue(String key, String defaultValue) - { + public String getValue(String key, String defaultValue) { if (this.isLoading) return defaultValue; @@ -143,68 +110,54 @@ public class ConfigurationManager } - public boolean getBoolean(String key) - { + public boolean getBoolean(String key) { return this.getBoolean(key, false); } - public boolean getBoolean(String key, boolean defaultValue) - { + public boolean getBoolean(String key, boolean defaultValue) { if (this.isLoading) return defaultValue; - try - { + try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type boolean."); } return defaultValue; } - public int getInt(String key) - { + public int getInt(String key) { return this.getInt(key, 0); } - public int getInt(String key, Integer defaultValue) - { + public int getInt(String key, Integer defaultValue) { if (this.isLoading) return defaultValue; - try - { + try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type integer."); } return defaultValue; } - public double getDouble(String key) - { + public double getDouble(String key) { return this.getDouble(key, 0.0); } - public double getDouble(String key, Double defaultValue) - { + public double getDouble(String key, Double defaultValue) { if (this.isLoading) return defaultValue; - try - { + try { return Double.parseDouble(this.getValue(key, defaultValue.toString())); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type double."); } @@ -212,24 +165,19 @@ public class ConfigurationManager } - public void update(String key, String value) - { + public void update(String key, String value) { this.properties.setProperty(key, value); } - public void register(String key, String value) - { + public void register(String key, String value) { if (this.properties.getProperty(key, null) != null) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO emulator_settings VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO emulator_settings VALUES (?, ?)")) { statement.setString(1, key); statement.setString(2, value); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java index fed09c67..4c2a44a1 100644 --- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.Map; -public class CreditsScheduler extends Scheduler -{ +public class CreditsScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; @@ -22,36 +21,29 @@ public class CreditsScheduler extends Scheduler } public void reloadConfig() { - if(Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) - { - IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview"); - IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled"); - CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount"); + if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) { + IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview"); + IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled"); + CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount"); if (this.disposed) { this.disposed = false; this.run(); } - } - else - { + } else { this.disposed = true; } } @Override - public void run() - { + public void run() { super.run(); Habbo habbo; - for(Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { habbo = map.getValue(); - try - { - if (habbo != null) - { + try { + if (habbo != null) { if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) continue; @@ -60,21 +52,17 @@ public class CreditsScheduler extends Scheduler habbo.giveCredits(CREDITS); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } } - public boolean isDisposed() - { + public boolean isDisposed() { return this.disposed; } - public void setDisposed(boolean disposed) - { + public void setDisposed(boolean disposed) { this.disposed = disposed; } } diff --git a/src/main/java/com/eu/habbo/core/Disposable.java b/src/main/java/com/eu/habbo/core/Disposable.java index d0bdb49e..554ec32a 100644 --- a/src/main/java/com/eu/habbo/core/Disposable.java +++ b/src/main/java/com/eu/habbo/core/Disposable.java @@ -1,7 +1,7 @@ package com.eu.habbo.core; -public interface Disposable -{ +public interface Disposable { void dispose(); + boolean disposed(); } diff --git a/src/main/java/com/eu/habbo/core/Easter.java b/src/main/java/com/eu/habbo/core/Easter.java index 3692d672..ea643841 100644 --- a/src/main/java/com/eu/habbo/core/Easter.java +++ b/src/main/java/com/eu/habbo/core/Easter.java @@ -8,13 +8,10 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.users.UserSavedMottoEvent; -public class Easter -{ +public class Easter { @EventHandler - public static void onUserChangeMotto(UserSavedMottoEvent event) - { - if(event.newMotto.equalsIgnoreCase("crickey!")) - { + public static void onUserChangeMotto(UserSavedMottoEvent event) { + if (event.newMotto.equalsIgnoreCase("crickey!")) { event.habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.newMotto, event.habbo, event.habbo, RoomChatMessageBubbles.ALERT))); Room room = event.habbo.getHabboInfo().getCurrentRoom(); diff --git a/src/main/java/com/eu/habbo/core/ErrorLog.java b/src/main/java/com/eu/habbo/core/ErrorLog.java index 4afcf4b7..44d0176f 100644 --- a/src/main/java/com/eu/habbo/core/ErrorLog.java +++ b/src/main/java/com/eu/habbo/core/ErrorLog.java @@ -9,8 +9,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; -public class ErrorLog implements Loggable -{ +public class ErrorLog implements Loggable { public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)"; public final String version; public final String buildHash; @@ -19,8 +18,7 @@ public class ErrorLog implements Loggable public final String type; public final String stackTrace; - public ErrorLog(String type, Throwable e) - { + public ErrorLog(String type, Throwable e) { this.version = Emulator.version; this.buildHash = Emulator.version; @@ -33,18 +31,15 @@ public class ErrorLog implements Loggable e.printStackTrace(pw); this.stackTrace = sw.toString(); - try - { + try { pw.close(); sw.close(); - } catch (IOException e1) - { + } catch (IOException e1) { Emulator.getLogging().logErrorLine(e1); } } - public ErrorLog(String type, String message) - { + public ErrorLog(String type, String message) { this.version = Emulator.version; this.buildHash = Emulator.build; @@ -54,8 +49,7 @@ public class ErrorLog implements Loggable } @Override - public void log(PreparedStatement statement) throws SQLException - { + public void log(PreparedStatement statement) throws SQLException { statement.setInt(1, this.timeStamp); statement.setString(2, this.version); statement.setString(3, this.buildHash); diff --git a/src/main/java/com/eu/habbo/core/Loggable.java b/src/main/java/com/eu/habbo/core/Loggable.java index c974aac0..90826717 100644 --- a/src/main/java/com/eu/habbo/core/Loggable.java +++ b/src/main/java/com/eu/habbo/core/Loggable.java @@ -3,7 +3,6 @@ package com.eu.habbo.core; import java.sql.PreparedStatement; import java.sql.SQLException; -public interface Loggable -{ +public interface Loggable { void log(PreparedStatement statement) throws SQLException; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java index 13427b1e..1f3b1b51 100644 --- a/src/main/java/com/eu/habbo/core/Logging.java +++ b/src/main/java/com/eu/habbo/core/Logging.java @@ -13,28 +13,12 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class Logging -{ - - private static PrintWriter packetsWriter; - private static PrintWriter packetsUndefinedWriter; - private static PrintWriter errorsPacketsWriter; - private static PrintWriter errorsSQLWriter; - private static PrintWriter errorsRuntimeWriter; - private static PrintWriter debugFileWriter; - +public class Logging { public static final String ANSI_BRIGHT = "\u001B[1m"; - - public static final String ANSI_ITALICS = "\u001B[3m"; - - public static final String ANSI_UNDERLINE = "\u001B[4m"; - - public static final String ANSI_RESET = "\u001B[0m"; - public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; @@ -43,8 +27,12 @@ public class Logging public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; - - + private static PrintWriter packetsWriter; + private static PrintWriter packetsUndefinedWriter; + private static PrintWriter errorsPacketsWriter; + private static PrintWriter errorsSQLWriter; + private static PrintWriter errorsRuntimeWriter; + private static PrintWriter debugFileWriter; private final THashSet errorLogs = new THashSet<>(100); @@ -52,8 +40,7 @@ public class Logging private ConcurrentSet chatLogs = new ConcurrentSet<>(); - public Logging() - { + public Logging() { File packets = new File("logging//packets//defined.txt"); @@ -67,121 +54,101 @@ public class Logging File debugFile = new File("logging//debug.txt"); - try - { - if (!packets.exists()) - { - if (!packets.getParentFile().exists()) - { + try { + if (!packets.exists()) { + if (!packets.getParentFile().exists()) { packets.getParentFile().mkdirs(); } packets.createNewFile(); } - if (!packetsUndefined.exists()) - { - if (!packetsUndefined.getParentFile().exists()) - { + if (!packetsUndefined.exists()) { + if (!packetsUndefined.getParentFile().exists()) { packetsUndefined.getParentFile().mkdirs(); } packetsUndefined.createNewFile(); } - if (!errorsPackets.exists()) - { - if (!errorsPackets.getParentFile().exists()) - { + if (!errorsPackets.exists()) { + if (!errorsPackets.getParentFile().exists()) { errorsPackets.getParentFile().mkdirs(); } errorsPackets.createNewFile(); } - if (!errorsSQL.exists()) - { - if (!errorsSQL.getParentFile().exists()) - { + if (!errorsSQL.exists()) { + if (!errorsSQL.getParentFile().exists()) { errorsSQL.getParentFile().mkdirs(); } errorsSQL.createNewFile(); } - if (!errorsRuntime.exists()) - { - if (!errorsRuntime.getParentFile().exists()) - { + if (!errorsRuntime.exists()) { + if (!errorsRuntime.getParentFile().exists()) { errorsRuntime.getParentFile().mkdirs(); } errorsRuntime.createNewFile(); } - if (!debugFile.exists()) - { - if (!debugFile.getParentFile().exists()) - { + if (!debugFile.exists()) { + if (!debugFile.getParentFile().exists()) { debugFile.getParentFile().mkdirs(); } debugFile.createNewFile(); } - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); } - try - { - packetsWriter = new PrintWriter(new FileWriter(packets, true)); + try { + packetsWriter = new PrintWriter(new FileWriter(packets, true)); packetsUndefinedWriter = new PrintWriter(new FileWriter(packetsUndefined, true)); - errorsPacketsWriter = new PrintWriter(new FileWriter(errorsPackets, true)); - errorsSQLWriter = new PrintWriter(new FileWriter(errorsSQL, true)); - errorsRuntimeWriter = new PrintWriter(new FileWriter(errorsRuntime, true)); - debugFileWriter = new PrintWriter(new FileWriter(debugFile, true)); - } - catch (IOException e) - { - System.out.println("[CRITICAL] FAILED TO LOAD LOGGING COMPONENT!"); + errorsPacketsWriter = new PrintWriter(new FileWriter(errorsPackets, true)); + errorsSQLWriter = new PrintWriter(new FileWriter(errorsSQL, true)); + errorsRuntimeWriter = new PrintWriter(new FileWriter(errorsRuntime, true)); + debugFileWriter = new PrintWriter(new FileWriter(debugFile, true)); + } catch (IOException e) { + System.out.println("[CRITICAL] FAILED TO LOAD LOGGING COMPONENT!"); } } + public static PrintWriter getPacketsWriter() { + return packetsWriter; + } - public void logStart(Object line) - { + public static PrintWriter getPacketsUndefinedWriter() { + return packetsUndefinedWriter; + } + + public void logStart(Object line) { System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "LOADING" + Logging.ANSI_RESET + "] " + line.toString()); } - - public void logShutdownLine(Object line) - { - if(Emulator.getConfig().getBoolean("logging.debug")) - { + public void logShutdownLine(Object line) { + if (Emulator.getConfig().getBoolean("logging.debug")) { this.write(debugFileWriter, line.toString()); } System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString()); } - public void logUserLine(Object line) - { - if(Emulator.getConfig().getBoolean("logging.debug")) - { + public void logUserLine(Object line) { + if (Emulator.getConfig().getBoolean("logging.debug")) { this.write(debugFileWriter, line.toString()); } - if (Emulator.getConfig().getBoolean("debug.show.users")) - { + if (Emulator.getConfig().getBoolean("debug.show.users")) { System.out.println("[USER] " + line.toString()); } } - - public synchronized void logDebugLine(Object line) - { - if (line instanceof Throwable) - { + + public synchronized void logDebugLine(Object line) { + if (line instanceof Throwable) { this.logErrorLine(line); return; } @@ -189,58 +156,47 @@ public class Logging System.out.println("[DEBUG] " + line.toString()); } - if(Emulator.getConfig().getBoolean("logging.debug")) - { + if (Emulator.getConfig().getBoolean("logging.debug")) { this.write(debugFileWriter, line.toString()); } } - - public synchronized void logPacketLine(Object line) - { + + public synchronized void logPacketLine(Object line) { if (Emulator.getConfig().getBoolean("debug.show.packets")) { System.out.println("[" + Logging.ANSI_BLUE + "PACKET" + Logging.ANSI_RESET + "]" + line.toString()); } - if(Emulator.getConfig().getBoolean("logging.packets")) - { + if (Emulator.getConfig().getBoolean("logging.packets")) { this.write(packetsWriter, line.toString()); } } - - public synchronized void logUndefinedPacketLine(Object line) - { - if (Emulator.getConfig().getBoolean("debug.show.packets.undefined")) - { + + public synchronized void logUndefinedPacketLine(Object line) { + if (Emulator.getConfig().getBoolean("debug.show.packets.undefined")) { System.out.println("[PACKET] [UNDEFINED] " + line.toString()); } - if (Emulator.getConfig().getBoolean("logging.packets.undefined")) - { + if (Emulator.getConfig().getBoolean("logging.packets.undefined")) { this.write(packetsUndefinedWriter, line.toString()); } } - - public synchronized void logErrorLine(Object line) - { - if (Emulator.isReady && Emulator.getConfig().getBoolean("debug.show.errors")) - { + + public synchronized void logErrorLine(Object line) { + if (Emulator.isReady && Emulator.getConfig().getBoolean("debug.show.errors")) { System.err.println("[ERROR] " + line.toString()); } - if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime")) - { + if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime")) { this.write(errorsRuntimeWriter, line); } - if(line instanceof Throwable) - { + if (line instanceof Throwable) { ((Throwable) line).printStackTrace(); - if (line instanceof SQLException) - { + if (line instanceof SQLException) { this.logSQLException((SQLException) line); return; } - // Emulator.getThreading().run(new HTTPPostError((Throwable) line)); + // Emulator.getThreading().run(new HTTPPostError((Throwable) line)); this.errorLogs.add(new ErrorLog("Exception", (Throwable) line)); @@ -250,10 +206,8 @@ public class Logging this.errorLogs.add(new ErrorLog("Emulator", line.toString())); } - public void logSQLException(SQLException e) - { - if(Emulator.getConfig().getBoolean("logging.errors.sql")) - { + public void logSQLException(SQLException e) { + if (Emulator.getConfig().getBoolean("logging.errors.sql")) { e.printStackTrace(); this.write(errorsSQLWriter, e); @@ -261,44 +215,34 @@ public class Logging } } - public void logPacketError(Object e) - { - if(Emulator.getConfig().getBoolean("logging.errors.packets")) - { - if(e instanceof Throwable) + public void logPacketError(Object e) { + if (Emulator.getConfig().getBoolean("logging.errors.packets")) { + if (e instanceof Throwable) ((Exception) e).printStackTrace(); this.write(errorsPacketsWriter, e); } - if(e instanceof Throwable) - { + if (e instanceof Throwable) { ((Throwable) e).printStackTrace(); - if (e instanceof SQLException) - { + if (e instanceof SQLException) { this.logSQLException((SQLException) e); return; } - // Emulator.getThreading().run(new HTTPPostError((Throwable) e)); + // Emulator.getThreading().run(new HTTPPostError((Throwable) e)); } } - - public void handleException(Exception e) - { + + public void handleException(Exception e) { e.printStackTrace(); } - private synchronized void write(PrintWriter printWriter, Object message) - { - if(printWriter != null && message != null) - { - if(message instanceof Throwable) - { + private synchronized void write(PrintWriter printWriter, Object message) { + if (printWriter != null && message != null) { + if (message instanceof Throwable) { ((Exception) message).printStackTrace(printWriter); - } - else - { + } else { printWriter.write("MSG: " + message.toString() + "\r\n"); } @@ -306,45 +250,30 @@ public class Logging } } - public void addLog(Loggable log) - { - if (log instanceof ErrorLog) - { - synchronized (this.errorLogs) - { + public void addLog(Loggable log) { + if (log instanceof ErrorLog) { + synchronized (this.errorLogs) { this.errorLogs.add(log); } - } - else if (log instanceof CommandLog) - { - synchronized (this.commandLogs) - { + } else if (log instanceof CommandLog) { + synchronized (this.commandLogs) { this.commandLogs.add(log); } } } - public void addChatLog(Loggable chatLog) - { + public void addChatLog(Loggable chatLog) { this.chatLogs.add(chatLog); } - public void saveLogs() - { - if (Emulator.getDatabase() != null && Emulator.getDatabase().getDataSource() != null) - { - if (!this.errorLogs.isEmpty() || !this.commandLogs.isEmpty() || !this.chatLogs.isEmpty()) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - if (!this.errorLogs.isEmpty()) - { - synchronized (this.errorLogs) - { - try (PreparedStatement statement = connection.prepareStatement(ErrorLog.insertQuery)) - { - for (Loggable log : this.errorLogs) - { + public void saveLogs() { + if (Emulator.getDatabase() != null && Emulator.getDatabase().getDataSource() != null) { + if (!this.errorLogs.isEmpty() || !this.commandLogs.isEmpty() || !this.chatLogs.isEmpty()) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + if (!this.errorLogs.isEmpty()) { + synchronized (this.errorLogs) { + try (PreparedStatement statement = connection.prepareStatement(ErrorLog.insertQuery)) { + for (Loggable log : this.errorLogs) { log.log(statement); } statement.executeBatch(); @@ -353,14 +282,10 @@ public class Logging } } - if (!this.commandLogs.isEmpty()) - { - synchronized (this.commandLogs) - { - try (PreparedStatement statement = connection.prepareStatement(CommandLog.insertQuery)) - { - for (Loggable log : this.commandLogs) - { + if (!this.commandLogs.isEmpty()) { + synchronized (this.commandLogs) { + try (PreparedStatement statement = connection.prepareStatement(CommandLog.insertQuery)) { + for (Loggable log : this.commandLogs) { log.log(statement); } @@ -370,15 +295,12 @@ public class Logging } } - if (!this.chatLogs.isEmpty()) - { + if (!this.chatLogs.isEmpty()) { ConcurrentSet chatLogs = this.chatLogs; this.chatLogs = new ConcurrentSet<>(); - try (PreparedStatement statement = connection.prepareStatement(RoomChatMessage.insertQuery)) - { - for (Loggable log : chatLogs) - { + try (PreparedStatement statement = connection.prepareStatement(RoomChatMessage.insertQuery)) { + for (Loggable log : chatLogs) { log.log(statement); } @@ -386,24 +308,12 @@ public class Logging } chatLogs.clear(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } } - - public static PrintWriter getPacketsWriter() - { - return packetsWriter; - } - - public static PrintWriter getPacketsUndefinedWriter() - { - return packetsUndefinedWriter; - } /* public static PrintWriter getErrorsPacketsWriter() { diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java index 705db579..285df17c 100644 --- a/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.Map; -public class PixelScheduler extends Scheduler -{ +public class PixelScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; @@ -16,43 +15,59 @@ public class PixelScheduler extends Scheduler private static int PIXELS; - public PixelScheduler() - { + public PixelScheduler() { super(Emulator.getConfig().getInt("hotel.auto.pixels.interval")); this.reloadConfig(); } + public static boolean isIgnoreHotelView() { + return IGNORE_HOTEL_VIEW; + } + + public static void setIgnoreHotelView(boolean ignoreHotelView) { + IGNORE_HOTEL_VIEW = ignoreHotelView; + } + + public static boolean isIgnoreIdled() { + return IGNORE_IDLED; + } + + public static void setIgnoreIdled(boolean ignoreIdled) { + IGNORE_IDLED = ignoreIdled; + } + + public static int getPIXELS() { + return PIXELS; + } + + public static void setPIXELS(int PIXELS) { + PixelScheduler.PIXELS = PIXELS; + } + public void reloadConfig() { - if(Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) - { - IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview"); - IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled"); - PIXELS = Emulator.getConfig().getInt("hotel.auto.pixels.amount"); + if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) { + IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview"); + IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled"); + PIXELS = Emulator.getConfig().getInt("hotel.auto.pixels.amount"); if (this.disposed) { this.disposed = false; this.run(); } - } - else - { + } else { this.disposed = true; } } @Override - public void run() - { + public void run() { super.run(); Habbo habbo; - for(Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { habbo = map.getValue(); - try - { - if (habbo != null) - { + try { + if (habbo != null) { if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) continue; @@ -61,51 +76,17 @@ public class PixelScheduler extends Scheduler habbo.givePixels(PIXELS); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } } - public static boolean isIgnoreHotelView() - { - return IGNORE_HOTEL_VIEW; - } - - public static void setIgnoreHotelView(boolean ignoreHotelView) - { - IGNORE_HOTEL_VIEW = ignoreHotelView; - } - - public static boolean isIgnoreIdled() - { - return IGNORE_IDLED; - } - - public static void setIgnoreIdled(boolean ignoreIdled) - { - IGNORE_IDLED = ignoreIdled; - } - - public static int getPIXELS() - { - return PIXELS; - } - - public static void setPIXELS(int PIXELS) - { - PixelScheduler.PIXELS = PIXELS; - } - - public boolean isDisposed() - { + public boolean isDisposed() { return this.disposed; } - public void setDisposed(boolean disposed) - { + public void setDisposed(boolean disposed) { this.disposed = disposed; } } diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java index 86037820..529d004d 100644 --- a/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.Map; -public class PointsScheduler extends Scheduler -{ +public class PointsScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; @@ -16,43 +15,59 @@ public class PointsScheduler extends Scheduler private static int POINTS; - public PointsScheduler() - { + public PointsScheduler() { super(Emulator.getConfig().getInt("hotel.auto.points.interval")); this.reloadConfig(); } + public static boolean isIgnoreHotelView() { + return IGNORE_HOTEL_VIEW; + } + + public static void setIgnoreHotelView(boolean ignoreHotelView) { + IGNORE_HOTEL_VIEW = ignoreHotelView; + } + + public static boolean isIgnoreIdled() { + return IGNORE_IDLED; + } + + public static void setIgnoreIdled(boolean ignoreIdled) { + IGNORE_IDLED = ignoreIdled; + } + + public static int getPOINTS() { + return POINTS; + } + + public static void setPOINTS(int POINTS) { + PointsScheduler.POINTS = POINTS; + } + public void reloadConfig() { - if(Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) - { - IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview"); - IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled"); - POINTS = Emulator.getConfig().getInt("hotel.auto.points.amount"); + if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) { + IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview"); + IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled"); + POINTS = Emulator.getConfig().getInt("hotel.auto.points.amount"); if (this.disposed) { this.disposed = false; this.run(); } - } - else - { + } else { this.disposed = true; } } @Override - public void run() - { + public void run() { super.run(); Habbo habbo; - for(Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { habbo = map.getValue(); - try - { - if (habbo != null) - { + try { + if (habbo != null) { if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) continue; @@ -61,51 +76,17 @@ public class PointsScheduler extends Scheduler habbo.givePoints(POINTS); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } } - public static boolean isIgnoreHotelView() - { - return IGNORE_HOTEL_VIEW; - } - - public static void setIgnoreHotelView(boolean ignoreHotelView) - { - IGNORE_HOTEL_VIEW = ignoreHotelView; - } - - public static boolean isIgnoreIdled() - { - return IGNORE_IDLED; - } - - public static void setIgnoreIdled(boolean ignoreIdled) - { - IGNORE_IDLED = ignoreIdled; - } - - public static int getPOINTS() - { - return POINTS; - } - - public static void setPOINTS(int POINTS) - { - PointsScheduler.POINTS = POINTS; - } - - public boolean isDisposed() - { + public boolean isDisposed() { return this.disposed; } - public void setDisposed(boolean disposed) - { + public void setDisposed(boolean disposed) { this.disposed = disposed; } } diff --git a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java index 299a8ac8..9799350d 100644 --- a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java +++ b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.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; -public class RoomUserPetComposer extends MessageComposer -{ +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) - { + public RoomUserPetComposer(int petType, int race, String color, Habbo habbo) { this.petType = petType; this.race = race; this.color = color; @@ -21,8 +19,7 @@ public class RoomUserPetComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUsersComposer); this.response.appendInt(1); this.response.appendInt(this.habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/core/Scheduler.java b/src/main/java/com/eu/habbo/core/Scheduler.java index 431710a1..17fae179 100644 --- a/src/main/java/com/eu/habbo/core/Scheduler.java +++ b/src/main/java/com/eu/habbo/core/Scheduler.java @@ -2,39 +2,32 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -public class Scheduler implements Runnable -{ +public class Scheduler implements Runnable { protected boolean disposed; protected int interval; - public Scheduler(int interval) - { + public Scheduler(int interval) { this.interval = interval; } - public boolean isDisposed() - { + public boolean isDisposed() { return this.disposed; } - public void setDisposed(boolean disposed) - { + public void setDisposed(boolean disposed) { this.disposed = disposed; } - public int getInterval() - { + public int getInterval() { return this.interval; } - public void setInterval(int interval) - { + public void setInterval(int interval) { this.interval = interval; } @Override - public void run() - { + public void run() { if (this.disposed) return; diff --git a/src/main/java/com/eu/habbo/core/TextsManager.java b/src/main/java/com/eu/habbo/core/TextsManager.java index 8da68f36..7b28651c 100644 --- a/src/main/java/com/eu/habbo/core/TextsManager.java +++ b/src/main/java/com/eu/habbo/core/TextsManager.java @@ -5,62 +5,47 @@ import com.eu.habbo.Emulator; import java.sql.*; import java.util.Properties; -public class TextsManager -{ +public class TextsManager { private final Properties texts; - public TextsManager() - { + public TextsManager() { long millis = System.currentTimeMillis(); this.texts = new Properties(); - try - { + try { this.reload(); Emulator.getLogging().logStart("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } - public void reload() throws Exception - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM emulator_texts")) - { - while(set.next()) - { - if(this.texts.containsKey(set.getString("key"))) - { + public void reload() throws Exception { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM emulator_texts")) { + while (set.next()) { + if (this.texts.containsKey(set.getString("key"))) { this.texts.setProperty(set.getString("key"), set.getString("value")); - } - else - { + } else { this.texts.put(set.getString("key"), set.getString("value")); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public String getValue(String key) - { + public String getValue(String key) { return this.getValue(key, ""); } - public String getValue(String key, String defaultValue) - { + public String getValue(String key, String defaultValue) { if (!this.texts.containsKey(key)) { Emulator.getLogging().logErrorLine("[TEXTS] Text key not found: " + key); } @@ -68,64 +53,49 @@ public class TextsManager } - public boolean getBoolean(String key) - { + public boolean getBoolean(String key) { return this.getBoolean(key, false); } - public boolean getBoolean(String key, Boolean defaultValue) - { - try - { + public boolean getBoolean(String key, Boolean defaultValue) { + try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return defaultValue; } - public int getInt(String key) - { + public int getInt(String key) { return this.getInt(key, 0); } - public int getInt(String key, Integer defaultValue) - { - try - { + public int getInt(String key, Integer defaultValue) { + try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return defaultValue; } - public void update(String key, String value) - { + public void update(String key, String value) { this.texts.setProperty(key, value); } - public void register(String key, String value) - { + public void register(String key, String value) { if (this.texts.getProperty(key, null) != null) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO emulator_texts VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO emulator_texts VALUES (?, ?)")) { statement.setString(1, key); statement.setString(2, value); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } 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 dc4a8955..25e523a9 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java @@ -3,8 +3,7 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; -public abstract class ConsoleCommand -{ +public abstract class ConsoleCommand { private static final THashMap commands = new THashMap<>(); @@ -15,15 +14,13 @@ public abstract class ConsoleCommand public final String usage; - public ConsoleCommand(String key, String usage) - { - this.key = key; - this.usage = usage; + public ConsoleCommand(String key, String usage) { + this.key = key; + this.usage = usage; } - public static void load() - { + public static void load() { addCommand(new ConsoleShutdownCommand()); addCommand(new ConsoleInfoCommand()); addCommand(new ConsoleTestCommand()); @@ -32,49 +29,32 @@ public abstract class ConsoleCommand addCommand(new ShowRCONCommands()); } - - public abstract void handle(String[] args) throws Exception; - - - public static void addCommand(ConsoleCommand command) - { + public static void addCommand(ConsoleCommand command) { commands.put(command.key, command); } - - public static ConsoleCommand findCommand(String key) - { + public static ConsoleCommand findCommand(String key) { return commands.get(key); } - - public static boolean handle(String line) - { + public static boolean handle(String line) { String[] message = line.split(" "); - if (message.length > 0) - { + if (message.length > 0) { ConsoleCommand command = ConsoleCommand.findCommand(message[0]); - if (command != null) - { - try - { + if (command != null) { + try { command.handle(message); return true; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - } - else - { + } else { System.out.println("Unknown Console Command " + message[0]); System.out.println("Commands Available (" + commands.size() + "): "); - for (ConsoleCommand c : commands.values()) - { + for (ConsoleCommand c : commands.values()) { System.out.println(c.key + " - " + c.usage); } } @@ -82,4 +62,6 @@ public abstract class ConsoleCommand return false; } + + public abstract void handle(String[] args) throws Exception; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java index 7c08d398..c36f82bf 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java @@ -5,21 +5,18 @@ import com.eu.habbo.habbohotel.catalog.CatalogManager; import java.util.concurrent.TimeUnit; -public class ConsoleInfoCommand extends ConsoleCommand -{ - public ConsoleInfoCommand() - { +public class ConsoleInfoCommand extends ConsoleCommand { + public ConsoleInfoCommand() { super("info", "Show current statistics."); } @Override - public void handle(String[] args) throws Exception - { + public void handle(String[] args) throws Exception { int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted(); int day = (int) TimeUnit.SECONDS.toDays(seconds); - long hours = TimeUnit.SECONDS.toHours(seconds) - (day *24); - long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds)* 60); - long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24); + long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60); System.out.println("Emulator version: " + Emulator.version); System.out.println("Emulator build: " + Emulator.build); 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 f7247a3c..0520a5e3 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java @@ -2,16 +2,13 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.networking.camera.CameraClient; -public class ConsoleReconnectCameraCommand extends ConsoleCommand -{ - public ConsoleReconnectCameraCommand() - { +public class ConsoleReconnectCameraCommand extends ConsoleCommand { + public ConsoleReconnectCameraCommand() { super("camera", "Attempt to reconnect to the camera server."); } @Override - public void handle(String[] args) throws Exception - { + public void handle(String[] args) throws Exception { System.out.println("Connecting to the camera..."); CameraClient.attemptReconnect = true; } diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java index 345f3687..1b033e70 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java @@ -2,16 +2,13 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.habbohotel.commands.ShutdownCommand; -public class ConsoleShutdownCommand extends ConsoleCommand -{ - public ConsoleShutdownCommand() - { +public class ConsoleShutdownCommand extends ConsoleCommand { + public ConsoleShutdownCommand() { super("stop", "Stop the emulator."); } @Override - public void handle(String[] args) throws Exception - { + public void handle(String[] args) throws Exception { new ShutdownCommand().handle(null, args); } } \ 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 213f81de..d40fb13e 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java @@ -4,23 +4,17 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -public class ConsoleTestCommand extends ConsoleCommand -{ - public ConsoleTestCommand() - { +public class ConsoleTestCommand extends ConsoleCommand { + public ConsoleTestCommand() { super("test", "This is just a test."); } @Override - public void handle(String[] args) throws Exception - { - if (Emulator.debugging) - { + public void handle(String[] args) throws Exception { + if (Emulator.debugging) { System.out.println("This is a test command for live debugging."); - - //AchievementManager.progressAchievement(4, Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"), 30); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(1); habbo.getHabboInfo().getMachineID(); diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java index bd621909..9aa6eee9 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java @@ -2,18 +2,14 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -public class ShowInteractionsCommand extends ConsoleCommand -{ - public ShowInteractionsCommand() - { +public class ShowInteractionsCommand extends ConsoleCommand { + public ShowInteractionsCommand() { super("interactions", "Show a list of available furniture interactions."); } @Override - public void handle(String[] args) throws Exception - { - for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) - { + public void handle(String[] args) throws Exception { + for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) { System.out.println(interaction); } } 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 a0350cfb..a7df7bf3 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java @@ -2,18 +2,14 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -public class ShowRCONCommands extends ConsoleCommand -{ - public ShowRCONCommands() - { +public class ShowRCONCommands extends ConsoleCommand { + public ShowRCONCommands() { super("rconcommands", "Show a list of all RCON commands"); } @Override - public void handle(String[] args) throws Exception - { - for (String command : Emulator.getRconServer().getCommands()) - { + public void handle(String[] args) throws Exception { + for (String command : Emulator.getRconServer().getCommands()) { System.out.println(command); } } diff --git a/src/main/java/com/eu/habbo/database/Database.java b/src/main/java/com/eu/habbo/database/Database.java index 2c7e8593..81f7c508 100644 --- a/src/main/java/com/eu/habbo/database/Database.java +++ b/src/main/java/com/eu/habbo/database/Database.java @@ -4,41 +4,33 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariDataSource; -public class Database -{ +public class Database { private HikariDataSource dataSource; private DatabasePool databasePool; - - public Database(ConfigurationManager config) - { + + public Database(ConfigurationManager config) { long millis = System.currentTimeMillis(); boolean SQLException = false; - try - { + try { this.databasePool = new DatabasePool(); - if (!this.databasePool.getStoragePooling(config)) - { + if (!this.databasePool.getStoragePooling(config)) { Emulator.getLogging().logStart("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down..."); SQLException = true; return; } this.dataSource = this.databasePool.getDatabase(); - } - catch (Exception e) - { + } catch (Exception e) { SQLException = true; e.printStackTrace(); Emulator.getLogging().logStart("Failed to connect to your database."); Emulator.getLogging().logStart(e.getMessage()); - } - finally - { + } finally { if (SQLException) Emulator.prepareShutdown(); } @@ -47,23 +39,19 @@ public class Database } - public void dispose() - { - if (this.databasePool != null) - { + public void dispose() { + if (this.databasePool != null) { this.databasePool.getDatabase().close(); } this.dataSource.close(); } - public HikariDataSource getDataSource() - { + public HikariDataSource getDataSource() { return this.dataSource; } - public DatabasePool getDatabasePool() - { + public DatabasePool getDatabasePool() { return this.databasePool; } } diff --git a/src/main/java/com/eu/habbo/database/DatabasePool.java b/src/main/java/com/eu/habbo/database/DatabasePool.java index f87190c0..9a33ba29 100644 --- a/src/main/java/com/eu/habbo/database/DatabasePool.java +++ b/src/main/java/com/eu/habbo/database/DatabasePool.java @@ -1,21 +1,17 @@ package com.eu.habbo.database; import com.eu.habbo.core.ConfigurationManager; -import com.eu.habbo.core.Logging; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class DatabasePool -{ +class DatabasePool { private final Logger log = LoggerFactory.getLogger(DatabasePool.class); private HikariDataSource database; - public boolean getStoragePooling(ConfigurationManager config) - { - try - { + public boolean getStoragePooling(ConfigurationManager config) { + try { HikariConfig databaseConfiguration = new HikariConfig(); databaseConfiguration.setMaximumPoolSize(config.getInt("db.pool.maxsize", 50)); databaseConfiguration.setMinimumIdle(config.getInt("db.pool.minsize", 10)); @@ -30,11 +26,11 @@ class DatabasePool databaseConfiguration.addDataSourceProperty("dataSource.dumpQueriesOnException", "true"); databaseConfiguration.addDataSourceProperty("prepStmtCacheSize", "500"); databaseConfiguration.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); - // databaseConfiguration.addDataSourceProperty("dataSource.logWriter", Logging.getErrorsSQLWriter()); + // databaseConfiguration.addDataSourceProperty("dataSource.logWriter", Logging.getErrorsSQLWriter()); databaseConfiguration.addDataSourceProperty("cachePrepStmts", "true"); databaseConfiguration.addDataSourceProperty("useServerPrepStmts", "true"); databaseConfiguration.addDataSourceProperty("rewriteBatchedStatements", "true"); - databaseConfiguration.addDataSourceProperty("useUnicode","true"); + databaseConfiguration.addDataSourceProperty("useUnicode", "true"); databaseConfiguration.setAutoCommit(true); databaseConfiguration.setConnectionTimeout(300000L); databaseConfiguration.setValidationTimeout(5000L); @@ -43,16 +39,13 @@ class DatabasePool databaseConfiguration.setIdleTimeout(600000L); //databaseConfiguration.setDriverClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); this.database = new HikariDataSource(databaseConfiguration); - } - catch (Exception e) - { + } catch (Exception e) { return false; } return true; } - - public HikariDataSource getDatabase() - { + + public HikariDataSource getDatabase() { return this.database; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index 09d5aec1..99302c6a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -22,8 +22,10 @@ import com.eu.habbo.habbohotel.polls.PollManager; import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.HabboManager; -public class GameEnvironment -{ +public class GameEnvironment { + public CreditsScheduler creditsScheduler; + public PixelScheduler pixelScheduler; + public PointsScheduler pointsScheduler; private HabboManager habboManager; private NavigatorManager navigatorManager; private GuildManager guildManager; @@ -42,49 +44,43 @@ public class GameEnvironment private CraftingManager craftingManager; private PollManager pollManager; - public CreditsScheduler creditsScheduler; - public PixelScheduler pixelScheduler; - public PointsScheduler pointsScheduler; - - public void load() throws Exception - { + public void load() throws Exception { Emulator.getLogging().logStart("GameEnvironment -> Loading..."); this.permissionsManager = new PermissionsManager(); - this.habboManager = new HabboManager(); - this.hotelViewManager = new HotelViewManager(); - this.itemManager = new ItemManager(); + this.habboManager = new HabboManager(); + this.hotelViewManager = new HotelViewManager(); + this.itemManager = new ItemManager(); this.itemManager.load(); - this.botManager = new BotManager(); - this.petManager = new PetManager(); - this.guildManager = new GuildManager(); - this.catalogManager = new CatalogManager(); - this.roomManager = new RoomManager(); - this.navigatorManager = new NavigatorManager(); - this.commandHandler = new CommandHandler(); - this.modToolManager = new ModToolManager(); + this.botManager = new BotManager(); + this.petManager = new PetManager(); + this.guildManager = new GuildManager(); + this.catalogManager = new CatalogManager(); + this.roomManager = new RoomManager(); + this.navigatorManager = new NavigatorManager(); + this.commandHandler = new CommandHandler(); + this.modToolManager = new ModToolManager(); this.achievementManager = new AchievementManager(); this.achievementManager.reload(); - this.guideManager = new GuideManager(); - this.wordFilter = new WordFilter(); - this.craftingManager = new CraftingManager(); - this.pollManager = new PollManager(); + this.guideManager = new GuideManager(); + this.wordFilter = new WordFilter(); + this.craftingManager = new CraftingManager(); + this.pollManager = new PollManager(); this.roomManager.loadPublicRooms(); this.navigatorManager.loadNavigator(); - this.creditsScheduler = new CreditsScheduler(); + this.creditsScheduler = new CreditsScheduler(); Emulator.getThreading().run(this.creditsScheduler); - this.pixelScheduler = new PixelScheduler(); + this.pixelScheduler = new PixelScheduler(); Emulator.getThreading().run(this.pixelScheduler); - this.pointsScheduler = new PointsScheduler(); + this.pointsScheduler = new PointsScheduler(); Emulator.getThreading().run(this.pointsScheduler); Emulator.getLogging().logStart("GameEnvironment -> Loaded!"); } - public void dispose() - { + public void dispose() { this.pointsScheduler.setDisposed(true); this.pixelScheduler.setDisposed(true); this.creditsScheduler.setDisposed(true); @@ -99,88 +95,71 @@ public class GameEnvironment Emulator.getLogging().logShutdownLine("GameEnvironment -> Disposed!"); } - public HabboManager getHabboManager() - { + public HabboManager getHabboManager() { return this.habboManager; } - public NavigatorManager getNavigatorManager() - { + public NavigatorManager getNavigatorManager() { return this.navigatorManager; } - public GuildManager getGuildManager() - { + public GuildManager getGuildManager() { return this.guildManager; } - public ItemManager getItemManager() - { + public ItemManager getItemManager() { return this.itemManager; } - public CatalogManager getCatalogManager() - { + public CatalogManager getCatalogManager() { return this.catalogManager; } - public HotelViewManager getHotelViewManager() - { + public HotelViewManager getHotelViewManager() { return this.hotelViewManager; } - public RoomManager getRoomManager() - { + public RoomManager getRoomManager() { return this.roomManager; } - public CommandHandler getCommandHandler() - { + public CommandHandler getCommandHandler() { return this.commandHandler; } - public PermissionsManager getPermissionsManager() - { + public PermissionsManager getPermissionsManager() { return this.permissionsManager; } - public BotManager getBotManager() - { + public BotManager getBotManager() { return this.botManager; } - public ModToolManager getModToolManager() - { + public ModToolManager getModToolManager() { return this.modToolManager; } - public PetManager getPetManager() - { + public PetManager getPetManager() { return this.petManager; } - public AchievementManager getAchievementManager() - { + public AchievementManager getAchievementManager() { return this.achievementManager; } - public GuideManager getGuideManager() - { + public GuideManager getGuideManager() { return this.guideManager; } - public WordFilter getWordFilter() - { + public WordFilter getWordFilter() { return this.wordFilter; } - public CraftingManager getCraftingManager() - { + public CraftingManager getCraftingManager() { return this.craftingManager; } - public PollManager getPollManager() - { + public PollManager getPollManager() { return this.pollManager; } 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 b7d9aed3..dcf34c16 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/Achievement.java @@ -5,8 +5,7 @@ import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class Achievement -{ +public class Achievement { public final int id; @@ -20,8 +19,7 @@ public class Achievement public final THashMap levels; - public Achievement(ResultSet set) throws SQLException - { + public Achievement(ResultSet set) throws SQLException { this.levels = new THashMap<>(); this.id = set.getInt("id"); @@ -32,28 +30,20 @@ public class Achievement } - public void addLevel(AchievementLevel level) - { - synchronized (this.levels) - { + public void addLevel(AchievementLevel level) { + synchronized (this.levels) { this.levels.put(level.level, level); } } - public AchievementLevel getLevelForProgress(int progress) - { + public AchievementLevel getLevelForProgress(int progress) { AchievementLevel l = null; - if (progress > 0) - { - for (AchievementLevel level : this.levels.values()) - { - if (progress >= level.progress) - { - if (l != null) - { - if (l.level > level.level) - { + if (progress > 0) { + for (AchievementLevel level : this.levels.values()) { + if (progress >= level.progress) { + if (l != null) { + if (l.level > level.level) { continue; } } @@ -66,26 +56,22 @@ public class Achievement } - public AchievementLevel getNextLevel(int currentLevel) - { + public AchievementLevel getNextLevel(int currentLevel) { AchievementLevel l = null; - for(AchievementLevel level : this.levels.values()) - { - if(level.level == (currentLevel + 1)) + for (AchievementLevel level : this.levels.values()) { + if (level.level == (currentLevel + 1)) return level; } return null; } - public AchievementLevel firstLevel() - { + public AchievementLevel firstLevel() { return this.levels.get(1); } - public void clearLevels() - { + public void clearLevels() { this.levels.clear(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementCategories.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementCategories.java index 66370ee0..f5e8ba62 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementCategories.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementCategories.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.achievements; -public enum AchievementCategories -{ +public enum AchievementCategories { IDENTITY, 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 bb347be3..28868aa7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementLevel.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.achievements; import java.sql.ResultSet; import java.sql.SQLException; -public class AchievementLevel -{ +public class AchievementLevel { public final int level; @@ -20,12 +19,11 @@ public class AchievementLevel public final int progress; - public AchievementLevel(ResultSet set) throws SQLException - { - this.level = set.getInt("level"); + public AchievementLevel(ResultSet set) throws SQLException { + this.level = set.getInt("level"); this.rewardAmount = set.getInt("reward_amount"); this.rewardType = set.getInt("reward_type"); - this.points = set.getInt("points"); - this.progress = set.getInt("progress_needed"); + this.points = set.getInt("points"); + this.progress = set.getInt("progress_needed"); } } 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 4b9e8868..c6a865e5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -23,8 +23,7 @@ import java.sql.*; import java.util.LinkedHashMap; import java.util.Map; -public class AchievementManager -{ +public class AchievementManager { public static boolean TALENTTRACK_ENABLED = false; @@ -33,154 +32,43 @@ public class AchievementManager private final THashMap> talentTrackLevels; - public AchievementManager() - { + public AchievementManager() { this.achievements = new THashMap<>(); this.talentTrackLevels = new THashMap<>(); } - - public void reload() - { - long millis = System.currentTimeMillis(); - synchronized (this.achievements) - { - for (Achievement achievement : this.achievements.values()) - { - achievement.clearLevels(); - } - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM achievements")) - { - while (set.next()) - { - if (!this.achievements.containsKey(set.getString("name"))) - { - this.achievements.put(set.getString("name"), new Achievement(set)); - } - else - { - this.achievements.get(set.getString("name")).addLevel(new AchievementLevel(set)); - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - - - synchronized (this.talentTrackLevels) - { - this.talentTrackLevels.clear(); - - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM achievements_talents ORDER BY level ASC")) - { - while (set.next()) - { - TalentTrackLevel level = new TalentTrackLevel(set); - - if (!this.talentTrackLevels.containsKey(level.type)) - { - this.talentTrackLevels.put(level.type, new LinkedHashMap<>()); - } - - this.talentTrackLevels.get(level.type).put(level.level, level); - } - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - Emulator.getLogging().logErrorLine("Achievement Manager -> Failed to load!"); - return; - } - } - - Emulator.getLogging().logStart("Achievement Manager -> Loaded! ("+(System.currentTimeMillis() - millis)+" MS)"); - } - - - public Achievement getAchievement(String name) - { - return this.achievements.get(name); - } - - - public Achievement getAchievement(int id) - { - synchronized (this.achievements) - { - for (Map.Entry set : this.achievements.entrySet()) - { - if (set.getValue().id == id) - { - return set.getValue(); - } - } - } - - return null; - } - - public THashMap getAchievements() - { - return this.achievements; - } - - public static void progressAchievement(int habboId, Achievement achievement) - { + public static void progressAchievement(int habboId, Achievement achievement) { progressAchievement(habboId, achievement, 1); } - public static void progressAchievement(int habboId, Achievement achievement, int amount) - { - if (achievement != null) - { + public static void progressAchievement(int habboId, Achievement achievement, int amount) { + if (achievement != null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId); - if (habbo != null) - { + if (habbo != null) { progressAchievement(habbo, achievement, amount); - } - else - { + } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("" + "INSERT INTO users_achievements_queue (user_id, achievement_id, amount) VALUES (?, ?, ?) " + - "ON DUPLICATE KEY UPDATE amount = amount + ?")) - { + "ON DUPLICATE KEY UPDATE amount = amount + ?")) { statement.setInt(1, habboId); statement.setInt(2, achievement.id); statement.setInt(3, amount); statement.setInt(4, amount); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } } - - - public static void progressAchievement(Habbo habbo, Achievement achievement) - { + public static void progressAchievement(Habbo habbo, Achievement achievement) { progressAchievement(habbo, achievement, 1); } - - public static void progressAchievement(Habbo habbo, Achievement achievement, int amount) - { + public static void progressAchievement(Habbo habbo, Achievement achievement, int amount) { if (achievement == null) return; @@ -192,41 +80,34 @@ public class AchievementManager int currentProgress = habbo.getHabboStats().getAchievementProgress(achievement); - if(currentProgress == -1) - { + if (currentProgress == -1) { currentProgress = 0; createUserEntry(habbo, achievement); habbo.getHabboStats().setProgress(achievement, 0); } - if(Emulator.getPluginManager().isRegistered(UserAchievementProgressEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(UserAchievementProgressEvent.class, true)) { Event userAchievementProgressedEvent = new UserAchievementProgressEvent(habbo, achievement, amount); Emulator.getPluginManager().fireEvent(userAchievementProgressedEvent); - if(userAchievementProgressedEvent.isCancelled()) + if (userAchievementProgressedEvent.isCancelled()) return; } AchievementLevel oldLevel = achievement.getLevelForProgress(currentProgress); - if(oldLevel != null && (oldLevel.level == achievement.levels.size() && currentProgress >= oldLevel.progress)) //Maximum achievement gotten. + if (oldLevel != null && (oldLevel.level == achievement.levels.size() && currentProgress >= oldLevel.progress)) //Maximum achievement gotten. return; habbo.getHabboStats().setProgress(achievement, currentProgress + amount); AchievementLevel newLevel = achievement.getLevelForProgress(currentProgress + amount); - if (AchievementManager.TALENTTRACK_ENABLED) - { - for (TalentTrackType type : TalentTrackType.values()) - { - if (Emulator.getGameEnvironment().getAchievementManager().talentTrackLevels.containsKey(type)) - { - for (Map.Entry entry : Emulator.getGameEnvironment().getAchievementManager().talentTrackLevels.get(type).entrySet()) - { - if (entry.getValue().achievements.containsKey(achievement)) - { + if (AchievementManager.TALENTTRACK_ENABLED) { + for (TalentTrackType type : TalentTrackType.values()) { + 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); break; } @@ -235,19 +116,15 @@ public class AchievementManager } } - if(newLevel == null || - (oldLevel != null &&(oldLevel.level == newLevel.level && newLevel.level < achievement.levels.size()))) - { + if (newLevel == null || + (oldLevel != null && (oldLevel.level == newLevel.level && newLevel.level < achievement.levels.size()))) { habbo.getClient().sendResponse(new AchievementProgressComposer(habbo, achievement)); - } - else - { - if(Emulator.getPluginManager().isRegistered(UserAchievementLeveledEvent.class, true)) - { + } else { + if (Emulator.getPluginManager().isRegistered(UserAchievementLeveledEvent.class, true)) { Event userAchievementLeveledEvent = new UserAchievementLeveledEvent(habbo, achievement, oldLevel, newLevel); Emulator.getPluginManager().fireEvent(userAchievementLeveledEvent); - if(userAchievementLeveledEvent.isCancelled()) + if (userAchievementLeveledEvent.isCancelled()) return; } @@ -259,25 +136,20 @@ public class AchievementManager //the badge would result in an nullpointer exception. This is normal behaviour. HabboBadge badge = null; - if (oldLevel != null) - { - try - { + if (oldLevel != null) { + try { badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase()); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return; } } - if (badge != null) - { + if (badge != null) { badge.setCode("ACH_" + achievement.name + newLevel.level); badge.needsInsert(false); badge.needsUpdate(true); - } else - { + } else { badge = new HabboBadge(0, "ACH_" + achievement.name + newLevel.level, 0, habbo); habbo.getClient().sendResponse(new AddUserBadgeComposer(badge)); badge.needsInsert(true); @@ -287,10 +159,8 @@ public class AchievementManager Emulator.getThreading().run(badge); - if(badge.getSlot() > 0) - { - if(habbo.getHabboInfo().getCurrentRoom() != null) - { + if (badge.getSlot() > 0) { + if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); } } @@ -299,31 +169,26 @@ public class AchievementManager habbo.getHabboStats().addAchievementScore(newLevel.points); - if (newLevel.rewardAmount > 0) - { + if (newLevel.rewardAmount > 0) { habbo.givePoints(newLevel.rewardType, newLevel.rewardAmount); } - - if (habbo.getHabboInfo().getCurrentRoom() != null) - { + + if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); } } } - - public static boolean hasAchieved(Habbo habbo, Achievement achievement) - { + public static boolean hasAchieved(Habbo habbo, Achievement achievement) { int currentProgress = habbo.getHabboStats().getAchievementProgress(achievement); - if(currentProgress == -1) - { + if (currentProgress == -1) { return false; } AchievementLevel level = achievement.getLevelForProgress(currentProgress); - if(level == null) + if (level == null) return false; AchievementLevel nextLevel = achievement.levels.get(level.level + 1); @@ -331,83 +196,128 @@ public class AchievementManager return nextLevel == null && currentProgress >= level.progress; } - - public static void createUserEntry(Habbo habbo, Achievement achievement) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_achievements (user_id, achievement_name, progress) VALUES (?, ?, ?)")) - { + public static void createUserEntry(Habbo habbo, Achievement achievement) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_achievements (user_id, achievement_name, progress) VALUES (?, ?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setString(2, achievement.name); statement.setInt(3, 1); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - - public static void saveAchievements(Habbo habbo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_achievements SET progress = ? WHERE achievement_name = ? AND user_id = ? LIMIT 1")) - { + public static void saveAchievements(Habbo habbo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_achievements SET progress = ? WHERE achievement_name = ? AND user_id = ? LIMIT 1")) { statement.setInt(3, habbo.getHabboInfo().getId()); - for(Map.Entry map : habbo.getHabboStats().getAchievementProgress().entrySet()) - { + for (Map.Entry map : habbo.getHabboStats().getAchievementProgress().entrySet()) { statement.setInt(1, map.getValue()); statement.setString(2, map.getKey().name); statement.addBatch(); } statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static int getAchievementProgressForHabbo(int userId, Achievement achievement) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1")) - { + public static int getAchievementProgressForHabbo(int userId, Achievement achievement) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1")) { statement.setInt(1, userId); statement.setString(2, achievement.name); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { return set.getInt("progress"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return 0; } - public LinkedHashMap getTalenTrackLevels(TalentTrackType type) - { + public void reload() { + long millis = System.currentTimeMillis(); + synchronized (this.achievements) { + for (Achievement achievement : this.achievements.values()) { + achievement.clearLevels(); + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM achievements")) { + while (set.next()) { + if (!this.achievements.containsKey(set.getString("name"))) { + this.achievements.put(set.getString("name"), new Achievement(set)); + } else { + this.achievements.get(set.getString("name")).addLevel(new AchievementLevel(set)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + + + synchronized (this.talentTrackLevels) { + this.talentTrackLevels.clear(); + + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM achievements_talents ORDER BY level ASC")) { + while (set.next()) { + TalentTrackLevel level = new TalentTrackLevel(set); + + if (!this.talentTrackLevels.containsKey(level.type)) { + this.talentTrackLevels.put(level.type, new LinkedHashMap<>()); + } + + this.talentTrackLevels.get(level.type).put(level.level, level); + } + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + Emulator.getLogging().logErrorLine("Achievement Manager -> Failed to load!"); + return; + } + } + + Emulator.getLogging().logStart("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + } + + public Achievement getAchievement(String name) { + return this.achievements.get(name); + } + + public Achievement getAchievement(int id) { + synchronized (this.achievements) { + for (Map.Entry set : this.achievements.entrySet()) { + if (set.getValue().id == id) { + return set.getValue(); + } + } + } + + return null; + } + + public THashMap getAchievements() { + return this.achievements; + } + + public LinkedHashMap getTalenTrackLevels(TalentTrackType type) { return this.talentTrackLevels.get(type); } - public TalentTrackLevel calculateTalenTrackLevel(Habbo habbo, TalentTrackType type) - { + public TalentTrackLevel calculateTalenTrackLevel(Habbo habbo, TalentTrackType type) { TalentTrackLevel level = null; - for (Map.Entry entry : this.talentTrackLevels.get(type).entrySet()) - { + for (Map.Entry entry : this.talentTrackLevels.get(type).entrySet()) { final boolean[] allCompleted = {true}; - entry.getValue().achievements.forEachEntry(new TObjectIntProcedure() - { + entry.getValue().achievements.forEachEntry(new TObjectIntProcedure() { @Override - public boolean execute(Achievement a, int b) - { - if (habbo.getHabboStats().getAchievementProgress(a) < b) - { + public boolean execute(Achievement a, int b) { + if (habbo.getHabboStats().getAchievementProgress(a) < b) { allCompleted[0] = false; } @@ -415,15 +325,11 @@ public class AchievementManager } }); - if (allCompleted[0]) - { - if (level == null || level.level < entry.getValue().level) - { + if (allCompleted[0]) { + if (level == null || level.level < entry.getValue().level) { level = entry.getValue(); } - } - else - { + } else { break; } } @@ -431,24 +337,17 @@ public class AchievementManager return level; } - public void handleTalentTrackAchievement(Habbo habbo, TalentTrackType type, Achievement achievement) - { + public void handleTalentTrackAchievement(Habbo habbo, TalentTrackType type, Achievement achievement) { TalentTrackLevel currentLevel = this.calculateTalenTrackLevel(habbo, type); - if (currentLevel != null) - { - if (currentLevel.level > habbo.getHabboStats().talentTrackLevel(type)) - { - for (int i = habbo.getHabboStats().talentTrackLevel(type); i <= currentLevel.level; i++) - { + if (currentLevel != null) { + if (currentLevel.level > habbo.getHabboStats().talentTrackLevel(type)) { + for (int i = habbo.getHabboStats().talentTrackLevel(type); i <= currentLevel.level; i++) { TalentTrackLevel level = this.getTalentTrackLevel(type, i); - if (level != null) - { - if (level.items != null && !level.items.isEmpty()) - { - for (Item item : level.items) - { + if (level != null) { + if (level.items != null && !level.items.isEmpty()) { + for (Item item : level.items) { HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); habbo.getInventory().getItemsComponent().addItem(rewardItem); habbo.getClient().sendResponse(new AddHabboItemComposer(rewardItem)); @@ -456,12 +355,9 @@ public class AchievementManager } } - if (level.badges != null && level.badges.length > 0 ) - { - for (String badge : level.badges) - { - if (!badge.isEmpty()) - { + if (level.badges != null && level.badges.length > 0) { + for (String badge : level.badges) { + if (!badge.isEmpty()) { HabboBadge b = new HabboBadge(0, badge, 0, habbo); Emulator.getThreading().run(b); habbo.getInventory().getBadgesComponent().addBadge(b); @@ -470,12 +366,9 @@ public class AchievementManager } } - if (level.perks != null && level.perks.length > 0 ) - { - for (String perk : level.perks) - { - if (perk.equalsIgnoreCase("TRADE")) - { + if (level.perks != null && level.perks.length > 0) { + for (String perk : level.perks) { + if (perk.equalsIgnoreCase("TRADE")) { habbo.getHabboStats().perkTrade = true; } } @@ -489,8 +382,7 @@ public class AchievementManager } } - public TalentTrackLevel getTalentTrackLevel(TalentTrackType type, int level) - { + public TalentTrackLevel getTalentTrackLevel(TalentTrackType type, int level) { return this.talentTrackLevels.get(type).get(level); } } \ No newline at end of file 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 4c02c7b7..31e5d861 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java @@ -9,8 +9,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class TalentTrackLevel -{ +public class TalentTrackLevel { public TalentTrackType type; @@ -29,56 +28,44 @@ public class TalentTrackLevel public String[] badges; - public TalentTrackLevel(ResultSet set) throws SQLException - { - this.type = TalentTrackType.valueOf(set.getString("type").toUpperCase()); - this.level = set.getInt("level"); + public TalentTrackLevel(ResultSet set) throws SQLException { + this.type = TalentTrackType.valueOf(set.getString("type").toUpperCase()); + this.level = set.getInt("level"); this.achievements = new TObjectIntHashMap<>(); - this.items = new THashSet<>(); + this.items = new THashSet<>(); - String[] achievements = set.getString("achievement_ids").split(","); + String[] achievements = set.getString("achievement_ids").split(","); String[] achievementLevels = set.getString("achievement_levels").split(","); - if (achievementLevels.length == achievements.length) - { - for (int i = 0; i < achievements.length; i++) - { + if (achievementLevels.length == achievements.length) { + for (int i = 0; i < achievements.length; i++) { if (achievements[i].isEmpty() || achievementLevels[i].isEmpty()) continue; Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(Integer.valueOf(achievements[i])); - if (achievement != null) - { + if (achievement != null) { this.achievements.put(achievement, Integer.valueOf(achievementLevels[i])); - } - else - { + } else { Emulator.getLogging().logErrorLine("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(",")) - { + for (String s : set.getString("reward_furni").split(",")) { Item item = Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(s)); - if (item != null) - { + if (item != null) { this.items.add(item); - } - else - { + } else { Emulator.getLogging().logStart("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); } } - if (!set.getString("reward_perks").isEmpty()) - { + if (!set.getString("reward_perks").isEmpty()) { this.perks = set.getString("reward_perks").split(","); } - if (!set.getString("reward_badges").isEmpty()) - { + if (!set.getString("reward_badges").isEmpty()) { this.badges = set.getString("reward_badges").split(","); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackType.java b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackType.java index 2018a88a..6c3d9b8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackType.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.achievements; -public enum TalentTrackType -{ +public enum TalentTrackType { CITIZENSHIP, 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 de168ee4..aa5078cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -23,55 +23,23 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; -public class Bot implements Runnable -{ +public class Bot implements Runnable { public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; - - private transient int id; - - - private String name; - - - private String motto; - - - private String figure; - - - private HabboGender gender; - - - private int ownerId; - - - private String ownerName; - - - private Room room; - - - private RoomUnit roomUnit; - - - private boolean chatAuto; - - - private boolean chatRandom; - - - private short chatDelay; - - - private int chatTimeOut; - - - private int chatTimestamp; - - private final ArrayList chatLines; - - + private transient int id; + private String name; + private String motto; + private String figure; + private HabboGender gender; + private int ownerId; + private String ownerName; + private Room room; + private RoomUnit roomUnit; + private boolean chatAuto; + private boolean chatRandom; + private short chatDelay; + private int chatTimeOut; + private int chatTimestamp; private short lastChatIndex; @@ -88,8 +56,7 @@ public class Bot implements Runnable private transient int followingHabboId; - public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) - { + public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) { this.id = id; this.name = name; this.motto = motto; @@ -105,66 +72,65 @@ public class Bot implements Runnable this.room = null; } - public Bot(ResultSet set) throws SQLException - { - this.id = set.getInt("id"); - this.name = set.getString("name"); - this.motto = set.getString("motto"); - this.figure = set.getString("figure"); - this.gender = HabboGender.valueOf(set.getString("gender")); - this.ownerId = set.getInt("user_id"); - this.ownerName = set.getString("owner_name"); - this.chatAuto = set.getString("chat_auto").equals("1"); - this.chatRandom = set.getString("chat_random").equals("1"); - this.chatDelay = set.getShort("chat_delay"); - this.chatLines = new ArrayList<>(Arrays.asList(set.getString("chat_lines").split("\r"))); - this.type = set.getString("type"); - this.effect = set.getInt("effect"); - this.canWalk = set.getString("freeroam").equals("1"); - this.room = null; - this.roomUnit = null; - this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; - this.needsUpdate = false; + public Bot(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.name = set.getString("name"); + this.motto = set.getString("motto"); + this.figure = set.getString("figure"); + this.gender = HabboGender.valueOf(set.getString("gender")); + this.ownerId = set.getInt("user_id"); + this.ownerName = set.getString("owner_name"); + this.chatAuto = set.getString("chat_auto").equals("1"); + this.chatRandom = set.getString("chat_random").equals("1"); + this.chatDelay = set.getShort("chat_delay"); + this.chatLines = new ArrayList<>(Arrays.asList(set.getString("chat_lines").split("\r"))); + this.type = set.getString("type"); + this.effect = set.getInt("effect"); + this.canWalk = set.getString("freeroam").equals("1"); + this.room = null; + this.roomUnit = null; + this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; + this.needsUpdate = false; } - public Bot(Bot bot) - { - this.name = bot.getName(); - this.motto = bot.getMotto(); - this.figure = bot.getFigure(); - this.gender = bot.getGender(); - this.ownerId = bot.getOwnerId(); - this.ownerName = bot.getOwnerName(); - this.chatAuto = true; - this.chatRandom = false; - this.chatDelay = 10; - this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; - this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D")); - this.type = bot.getType(); - this.effect = bot.getEffect(); + public Bot(Bot bot) { + this.name = bot.getName(); + this.motto = bot.getMotto(); + this.figure = bot.getFigure(); + this.gender = bot.getGender(); + this.ownerId = bot.getOwnerId(); + this.ownerName = bot.getOwnerName(); + this.chatAuto = true; + this.chatRandom = false; + this.chatDelay = 10; + this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; + this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D")); + this.type = bot.getType(); + this.effect = bot.getEffect(); this.needsUpdate = false; } + public static void initialise() { - public void needsUpdate(boolean needsUpdate) - { + } + + public static void dispose() { + + } + + public void needsUpdate(boolean needsUpdate) { this.needsUpdate = needsUpdate; } - - public boolean needsUpdate() - { + public boolean needsUpdate() { return this.needsUpdate; } @Override - public void run() - { - if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ? WHERE id = ?")) - { + public void run() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.motto); statement.setString(3, this.figure); @@ -178,8 +144,7 @@ public class Bot implements Runnable statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType()); statement.setString(12, this.canWalk ? "1" : "0"); StringBuilder text = new StringBuilder(); - for(String s : this.chatLines) - { + for (String s : this.chatLines) { text.append(s).append("\r"); } statement.setString(13, text.toString()); @@ -190,46 +155,33 @@ public class Bot implements Runnable statement.setInt(18, this.id); statement.execute(); this.needsUpdate = false; - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - - public void cycle(boolean allowBotsWalk) - { - if(this.roomUnit != null) - { - if(allowBotsWalk && this.canWalk) - { - if (!this.roomUnit.isWalking()) - { - if (this.roomUnit.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) - { + public void cycle(boolean allowBotsWalk) { + if (this.roomUnit != null) { + if (allowBotsWalk && this.canWalk) { + if (!this.roomUnit.isWalking()) { + if (this.roomUnit.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) { this.roomUnit.setGoalLocation(this.room.getRandomWalkableTile()); int timeOut = Emulator.getRandom().nextInt(20) * 2; this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); } - } else - { - for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) - { + } else { + for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) { WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray()); } } } - if(!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) - { - if(this.room != null) - { - this.lastChatIndex = (this.chatRandom ? (short)Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++)); + if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) { + if (this.room != null) { + this.lastChatIndex = (this.chatRandom ? (short) Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++)); - if (this.lastChatIndex >= this.chatLines.size()) - { + if (this.lastChatIndex >= this.chatLines.size()) { this.lastChatIndex = 0; } @@ -246,13 +198,10 @@ public class Bot implements Runnable } } - - public void talk(String message) - { - if(this.room != null) - { + public void talk(String message) { + if (this.room != null) { BotChatEvent event = new BotTalkEvent(this, message); - if(Emulator.getPluginManager().fireEvent(event).isCancelled()) + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); @@ -260,13 +209,10 @@ public class Bot implements Runnable } } - - public void shout(String message) - { - if(this.room != null) - { + public void shout(String message) { + if (this.room != null) { BotChatEvent event = new BotShoutEvent(this, message); - if(Emulator.getPluginManager().fireEvent(event).isCancelled()) + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); @@ -274,13 +220,10 @@ public class Bot implements Runnable } } - - public void whisper(String message, Habbo habbo) - { - if(this.room != null && habbo != null) - { + public void whisper(String message, Habbo habbo) { + if (this.room != null && habbo != null) { BotWhisperEvent event = new BotWhisperEvent(this, message, habbo); - if(Emulator.getPluginManager().fireEvent(event).isCancelled()) + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); @@ -288,308 +231,212 @@ public class Bot implements Runnable } } - - public void onPlace(Habbo habbo, Room room) - { - if (this.roomUnit != null) - { + public void onPlace(Habbo habbo, Room room) { + if (this.roomUnit != null) { room.giveEffect(this.roomUnit, this.effect, -1); } } - - public void onPickUp(Habbo habbo, Room room) - { + public void onPickUp(Habbo habbo, Room room) { } - - public void onUserSay(final RoomChatMessage message) - { + public void onUserSay(final RoomChatMessage message) { } - - public int getId() - { + public int getId() { return this.id; } - - public void setId(int id) - { + public void setId(int id) { this.id = id; } - - public String getName() - { + public String getName() { return this.name; } - - public void setName(String name) - { - this.name = name; + public void setName(String name) { + this.name = name; this.needsUpdate = true; //if(this.room != null) - //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose()); + //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose()); } - - public String getMotto() - { + public String getMotto() { return this.motto; } - - public void setMotto(String motto) - { - this.motto = motto; + public void setMotto(String motto) { + this.motto = motto; this.needsUpdate = true; } - - public String getFigure() - { + public String getFigure() { return this.figure; } - - public void setFigure(String figure) - { - this.figure = figure; + public void setFigure(String figure) { + this.figure = figure; this.needsUpdate = true; - if(this.room != null) + if (this.room != null) this.room.sendComposer(new RoomUsersComposer(this).compose()); } - - public HabboGender getGender() - { + public HabboGender getGender() { return this.gender; } - - public void setGender(HabboGender gender) - { - this.gender = gender; + public void setGender(HabboGender gender) { + this.gender = gender; this.needsUpdate = true; - if(this.room != null) + if (this.room != null) this.room.sendComposer(new RoomUsersComposer(this).compose()); } - - public int getOwnerId() - { + public int getOwnerId() { return this.ownerId; } - - public void setOwnerId(int ownerId) - { - this.ownerId = ownerId; + public void setOwnerId(int ownerId) { + this.ownerId = ownerId; this.needsUpdate = true; - if(this.room != null) + if (this.room != null) this.room.sendComposer(new RoomUsersComposer(this).compose()); } - - public String getOwnerName() - { + public String getOwnerName() { return this.ownerName; } - - public void setOwnerName(String ownerName) - { - this.ownerName = ownerName; + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; this.needsUpdate = true; - if(this.room != null) + if (this.room != null) this.room.sendComposer(new RoomUsersComposer(this).compose()); } - - public Room getRoom() - { + public Room getRoom() { return this.room; } - - public void setRoom(Room room) - { + public void setRoom(Room room) { this.room = room; } - - public RoomUnit getRoomUnit() - { + public RoomUnit getRoomUnit() { return this.roomUnit; } - - public void setRoomUnit(RoomUnit roomUnit) - { + public void setRoomUnit(RoomUnit roomUnit) { this.roomUnit = roomUnit; } - - public boolean isChatAuto() - { + public boolean isChatAuto() { return this.chatAuto; } - - public void setChatAuto(boolean chatAuto) - { - this.chatAuto = chatAuto; + public void setChatAuto(boolean chatAuto) { + this.chatAuto = chatAuto; this.needsUpdate = true; } - - public boolean isChatRandom() - { + public boolean isChatRandom() { return this.chatRandom; } - - public boolean hasChat() - { - return !this.chatLines.isEmpty(); - } - - - public void setChatRandom(boolean chatRandom) - { - this.chatRandom = chatRandom; + public void setChatRandom(boolean chatRandom) { + this.chatRandom = chatRandom; this.needsUpdate = true; } + public boolean hasChat() { + return !this.chatLines.isEmpty(); + } - public int getChatDelay() - { + public int getChatDelay() { return this.chatDelay; } - - public void setChatDelay(short chatDelay) - { - this.chatDelay = (short)Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED); + public void setChatDelay(short chatDelay) { + this.chatDelay = (short) Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED); this.needsUpdate = true; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; } - - public int getChatTimestamp() - { + public int getChatTimestamp() { return this.chatTimestamp; } - public void clearChat() - { - synchronized (this.chatLines) - { + public void clearChat() { + synchronized (this.chatLines) { this.chatLines.clear(); this.needsUpdate = true; } } - - public String getType() - { + public String getType() { return this.type; } - - public int getEffect() - { + public int getEffect() { return this.effect; } - - public void setEffect(int effect, int duration) - { - this.effect = effect; + public void setEffect(int effect, int duration) { + this.effect = effect; this.needsUpdate = true; - if (this.roomUnit != null) - { - if (this.room != null) - { + if (this.roomUnit != null) { + if (this.room != null) { this.room.giveEffect(this.roomUnit, this.effect, duration); } } } - - public void addChatLines(ArrayList chatLines) - { - synchronized (this.chatLines) - { + public void addChatLines(ArrayList chatLines) { + synchronized (this.chatLines) { this.chatLines.addAll(chatLines); this.needsUpdate = true; } } - - public void addChatLine(String chatLine) - { - synchronized (this.chatLines) - { + public void addChatLine(String chatLine) { + synchronized (this.chatLines) { this.chatLines.add(chatLine); this.needsUpdate = true; } } - - public ArrayList getChatLines() - { + public ArrayList getChatLines() { return this.chatLines; } - - public int getFollowingHabboId() - { + public int getFollowingHabboId() { return this.followingHabboId; } - - public void startFollowingHabbo(Habbo habbo) - { + public void startFollowingHabbo(Habbo habbo) { this.followingHabboId = habbo.getHabboInfo().getId(); Emulator.getThreading().run(new BotFollowHabbo(this, habbo, habbo.getHabboInfo().getCurrentRoom())); } - public void stopFollowingHabbo() - { + public void stopFollowingHabbo() { this.followingHabboId = 0; } - - public static void initialise() - { - - } - - - public static void dispose() - { - - } - - public boolean canWalk() - { + public boolean canWalk() { return this.canWalk; } - public void setCanWalk(boolean canWalk) - { + public void setCanWalk(boolean canWalk) { this.canWalk = canWalk; } 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 f1208640..97484248 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -20,25 +20,16 @@ import java.lang.reflect.Method; import java.sql.*; import java.util.Map; -public class BotManager -{ - - public static int MINIMUM_CHAT_SPEED = 7; - - - public static int MAXIMUM_CHAT_SPEED = 604800; - - - public static int MAXIMUM_CHAT_LENGTH = 120; - - - public static int MAXIMUM_NAME_LENGTH = 15; +public class BotManager { final private static THashMap> botDefenitions = new THashMap<>(); + public static int MINIMUM_CHAT_SPEED = 7; + public static int MAXIMUM_CHAT_SPEED = 604800; + public static int MAXIMUM_CHAT_LENGTH = 120; + public static int MAXIMUM_NAME_LENGTH = 15; - public BotManager() throws Exception - { + public BotManager() throws Exception { long millis = System.currentTimeMillis(); addBotDefinition("generic", Bot.class); @@ -47,27 +38,29 @@ public class BotManager this.reload(); - Emulator.getLogging().logStart("Bot Manager -> Loaded! ("+(System.currentTimeMillis() - millis)+" MS)"); + Emulator.getLogging().logStart("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } + public static void addBotDefinition(String type, Class botClazz) throws Exception { + if (botClazz.getDeclaredConstructor(ResultSet.class) == null) { + throw new Exception("Missing Bot(ResultSet) constructor!"); + } else { + botClazz.getDeclaredConstructor(ResultSet.class).setAccessible(true); - public boolean reload() - { - for(Map.Entry> set : botDefenitions.entrySet()) - { - try - { + botDefenitions.put(type, botClazz); + } + } + + public boolean reload() { + for (Map.Entry> set : botDefenitions.entrySet()) { + try { Method m = set.getValue().getMethod("initialise"); m.setAccessible(true); m.invoke(null); - } - catch (NoSuchMethodException e) - { + } catch (NoSuchMethodException e) { Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); return false; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); return false; } @@ -76,63 +69,46 @@ public class BotManager return true; } - - public Bot createBot(THashMap data, String type) - { + public Bot createBot(THashMap data, String type) { Bot bot = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setString(1, data.get("name")); statement.setString(2, data.get("motto")); statement.setString(3, data.get("figure")); statement.setString(4, data.get("gender").toUpperCase()); statement.setString(5, type); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { - try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.user_id = users.id WHERE bots.id = ? LIMIT 1")) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { + try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.user_id = users.id WHERE bots.id = ? LIMIT 1")) { stmt.setInt(1, set.getInt(1)); - try (ResultSet resultSet = stmt.executeQuery()) - { - if (resultSet.next()) - { + try (ResultSet resultSet = stmt.executeQuery()) { + if (resultSet.next()) { bot = this.loadBot(resultSet); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return bot; } - - public void placeBot(Bot bot, Habbo habbo, Room room, RoomTile location) - { + public void placeBot(Bot bot, Habbo habbo, Room room, RoomTile location) { BotPlacedEvent event = new BotPlacedEvent(bot, location, habbo); Emulator.getPluginManager().fireEvent(event); - if(event.isCancelled()) + if (event.isCancelled()) return; - if(room != null && bot != null && habbo != null) - { - if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission("acc_placefurni")) - { - if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission("acc_unlimited_bots")) - { + if (room != null && bot != null && habbo != null) { + if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission("acc_placefurni")) { + if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission("acc_unlimited_bots")) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } @@ -159,48 +135,36 @@ public class BotManager habbo.getClient().sendResponse(new RemoveBotComposer(bot)); bot.onPlace(habbo, room); - if (topItem != null) - { + if (topItem != null) { roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem)); - try - { + try { topItem.onWalkOn(bot.getRoomUnit(), room, null); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } bot.cycle(false); - } - else - { + } else { habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); } } } - - public void pickUpBot(int botId, Habbo habbo) - { - if(habbo.getHabboInfo().getCurrentRoom() != null) - { + public void pickUpBot(int botId, Habbo habbo) { + if (habbo.getHabboInfo().getCurrentRoom() != null) { this.pickUpBot(habbo.getHabboInfo().getCurrentRoom().getBot(Math.abs(botId)), habbo); } } - - public void pickUpBot(Bot bot, Habbo habbo) - { - if(bot != null && habbo != null) - { + public void pickUpBot(Bot bot, Habbo habbo) { + if (bot != null && habbo != null) { BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo); Emulator.getPluginManager().fireEvent(pickedUpEvent); - if(pickedUpEvent.isCancelled()) + if (pickedUpEvent.isCancelled()) return; - if (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) { if (!habbo.hasPermission("acc_unlimited_bots") && habbo.getInventory().getBotsComponent().getBots().size() >= 15) return; @@ -218,79 +182,44 @@ public class BotManager } } - - public Bot loadBot(ResultSet set) - { - try - { + public Bot loadBot(ResultSet set) { + try { String type = set.getString("type"); Class botClazz = botDefenitions.get(type); - if(botClazz != null) + if (botClazz != null) return botClazz.getDeclaredConstructor(ResultSet.class).newInstance(set); else Emulator.getLogging().logErrorLine("Unknown Bot Type: " + type); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - - public boolean deleteBot(Bot bot) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM bots WHERE id = ? LIMIT 1")) - { + public boolean 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(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return false; } - - public static void addBotDefinition(String type, Class botClazz) throws Exception - { - if(botClazz.getDeclaredConstructor(ResultSet.class) == null) - { - throw new Exception("Missing Bot(ResultSet) constructor!"); - } - else - { - botClazz.getDeclaredConstructor(ResultSet.class).setAccessible(true); - - botDefenitions.put(type, botClazz); - } - } - - - public void dispose() - { - for(Map.Entry> set : botDefenitions.entrySet()) - { - try - { + public void dispose() { + for (Map.Entry> set : botDefenitions.entrySet()) { + try { Method m = set.getValue().getMethod("dispose"); m.setAccessible(true); m.invoke(null); - } - catch (NoSuchMethodException e) - { + } catch (NoSuchMethodException e) { Emulator.getLogging().logStart("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logStart("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 a3da7344..7d56944c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -18,71 +18,55 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class ButlerBot extends Bot -{ +public class ButlerBot extends Bot { public static THashMap, Integer> serveItems = new THashMap<>(); - public ButlerBot(ResultSet set) throws SQLException - { + public ButlerBot(ResultSet set) throws SQLException { super(set); } - public ButlerBot(Bot bot) - { + public ButlerBot(Bot bot) { super(bot); } - public static void initialise() - { - if(serveItems == null) + public static void initialise() { + if (serveItems == null) serveItems = new THashMap<>(); serveItems.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM bot_serves")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM bot_serves")) { + while (set.next()) { String[] keys = set.getString("keys").split(";"); THashSet ks = new THashSet<>(); Collections.addAll(ks, keys); serveItems.put(ks, set.getInt("item")); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static void dispose() - { + public static void dispose() { serveItems.clear(); } @Override - public void onUserSay(final RoomChatMessage message) - { - if(this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + public void onUserSay(final RoomChatMessage message) { + if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) return; if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance")) - if(message.getUnfilteredMessage() != null) - { - for(Map.Entry, Integer> set : serveItems.entrySet()) - { - for(String s : set.getKey()) - { - if(message.getUnfilteredMessage().toLowerCase().contains(s)) - { + if (message.getUnfilteredMessage() != null) { + for (Map.Entry, Integer> set : serveItems.entrySet()) { + for (String s : set.getKey()) { + if (message.getUnfilteredMessage().toLowerCase().contains(s)) { BotServerItemEvent serveEvent = new BotServerItemEvent(this, message.getHabbo(), set.getValue()); - if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled()) { return; } - if (this.getRoomUnit().canWalk()) - { + if (this.getRoomUnit().canWalk()) { final String key = s; final Bot b = this; b.lookAt(serveEvent.habbo); @@ -91,20 +75,16 @@ public class ButlerBot extends Bot tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId)); tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0)); - tasks.add(new Runnable() - { + tasks.add(new Runnable() { @Override - public void run() - { + public void run() { b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername())); } }); List failedReached = new ArrayList(); - failedReached.add(new Runnable() - { - public void run() - { + failedReached.add(new Runnable() { + public void run() { if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) { for (Runnable t : tasks) { t.run(); @@ -117,13 +97,10 @@ public class ButlerBot extends Bot if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) { Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3))); - } - else { + } else { Emulator.getThreading().run(failedReached.get(0), 1000); } - } - else - { + } else { this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId); this.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).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 96f4b313..bfb9b297 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java @@ -11,36 +11,33 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Date; -public class VisitorBot extends Bot -{ +public class VisitorBot extends Bot { private static SimpleDateFormat DATE_FORMAT; private boolean showedLog = false; private THashSet visits = new THashSet<>(3); - public VisitorBot(ResultSet set) throws SQLException - { + public VisitorBot(ResultSet set) throws SQLException { super(set); } - public VisitorBot(Bot bot) - { + public VisitorBot(Bot bot) { super(bot); } + public static void initialise() { + DATE_FORMAT = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat")); + } + @Override - public void onUserSay(final RoomChatMessage message) - { - if(!this.showedLog) - { - if(message.getMessage().equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) - { + public void onUserSay(final RoomChatMessage message) { + if (!this.showedLog) { + if (message.getMessage().equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { this.showedLog = true; String visitMessage = Emulator.getTexts().getValue("bots.visitor.list").replace("%count%", this.visits.size() + ""); StringBuilder list = new StringBuilder(); - for(ModToolRoomVisit visit : this.visits) - { + for (ModToolRoomVisit visit : this.visits) { list.append("\r"); list.append(visit.roomName).append(" "); list.append(Emulator.getTexts().getValue("generic.time.at")).append(" "); @@ -56,29 +53,18 @@ public class VisitorBot extends Bot } } - public void onUserEnter(Habbo habbo) - { - if(!this.showedLog) - { - if(habbo.getHabboInfo().getCurrentRoom() != null) - { + public void onUserEnter(Habbo habbo) { + if (!this.showedLog) { + if (habbo.getHabboInfo().getCurrentRoom() != null) { this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getHabboInfo().getCurrentRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp()); - if(this.visits.isEmpty()) - { + if (this.visits.isEmpty()) { this.talk(Emulator.getTexts().getValue("bots.visitor.no_visits")); - } - else - { + } else { this.talk(Emulator.getTexts().getValue("bots.visitor.visits").replace("%count%", this.visits.size() + "").replace("%positive%", Emulator.getTexts().getValue("generic.yes"))); } } } } - public static void initialise() - { - DATE_FORMAT = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat")); - } - } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java index 270ff4c9..6940f759 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java @@ -6,8 +6,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class CalendarRewardObject -{ +public class CalendarRewardObject { private final int id; private final String name; private final String customImage; @@ -17,8 +16,7 @@ public class CalendarRewardObject private final String badge; private final int catalogItemId; - public CalendarRewardObject(ResultSet set) throws SQLException - { + public CalendarRewardObject(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.customImage = set.getString("custom_image"); @@ -29,71 +27,57 @@ public class CalendarRewardObject this.catalogItemId = set.getInt("catalog_item_id"); } - public void give(Habbo habbo) - { - if (this.credits > 0) - { + public void give(Habbo habbo) { + if (this.credits > 0) { habbo.giveCredits(this.credits); } - if (this.points > 0) - { + if (this.points > 0) { habbo.givePoints(this.pointsType, this.points); } - if (!this.badge.isEmpty()) - { + if (!this.badge.isEmpty()) { habbo.addBadge(this.badge); } - if (this.catalogItemId > 0) - { + if (this.catalogItemId > 0) { CatalogItem item = this.getCatalogItem(); - if (item != null) - { + if (item != null) { Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, habbo, 1, "", true); } } } - public int getId() - { + public int getId() { return this.id; } - public String getName() - { + public String getName() { return this.name; } - public String getCustomImage() - { + public String getCustomImage() { return this.customImage; } - public int getCredits() - { + public int getCredits() { return this.credits; } - public int getPoints() - { + public int getPoints() { return this.points; } - public int getPointsType() - { + public int getPointsType() { return this.pointsType; } - public String getBadge() - { + public String getBadge() { return this.badge; } - public CatalogItem getCatalogItem() - { + public CatalogItem getCatalogItem() { return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.catalogItemId); } } 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 67b7843f..30da0eb1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogFeaturedPage.java @@ -4,21 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; -public class CatalogFeaturedPage implements ISerialize -{ - public enum Type - { - PAGE_NAME(0), - PAGE_ID(1), - PRODUCT_NAME(2); - - public final int type; - Type(int type) - { - this.type = type; - } - } - +public class CatalogFeaturedPage implements ISerialize { private final int slotId; private final String caption; private final String image; @@ -27,9 +13,7 @@ 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) - { + 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; @@ -41,21 +25,34 @@ public class CatalogFeaturedPage implements ISerialize } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.slotId); message.appendString(this.caption); message.appendString(this.image); message.appendInt(this.type.type); - switch (this.type) - { + switch (this.type) { case PAGE_NAME: - message.appendString(this.pageName); break; + message.appendString(this.pageName); + break; case PAGE_ID: - message.appendInt(this.pageId); break; + message.appendInt(this.pageId); + break; case PRODUCT_NAME: - message.appendString(this.productName); break; + message.appendString(this.productName); + break; } message.appendInt(Emulator.getIntUnixTimestamp() - this.expireTimestamp); } + + public enum Type { + PAGE_NAME(0), + PAGE_ID(1), + PRODUCT_NAME(2); + + public final int type; + + Type(int type) { + this.type = 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 201e3857..9abeae91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -13,39 +13,18 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -public class CatalogItem implements ISerialize, Runnable, Comparable -{ +public class CatalogItem implements ISerialize, Runnable, Comparable { int id; - - - private int pageId; - - - private String itemId; - - - private String name; - - - private int credits; - - - private int points; - - - private short pointsType; - - - private int amount; - - - private boolean allowGift = false; - - int limitedStack; - - + private int pageId; + private String itemId; + private String name; + private int credits; + private int points; + private short pointsType; + private int amount; + private boolean allowGift = false; private int limitedSells; @@ -69,202 +48,173 @@ public class CatalogItem implements ISerialize, Runnable, Comparable bundle; - public CatalogItem(ResultSet set) throws SQLException - { + public CatalogItem(ResultSet set) throws SQLException { this.load(set); this.needsUpdate = false; } + public static boolean haveOffer(CatalogItem item) { + if (!item.haveOffer) + return false; - public void update(ResultSet set) throws SQLException - { + if (item.getAmount() != 1) + return false; + + if (item.isLimited()) + return false; + + if (item.bundle.size() > 1) + return false; + + if (item.getName().toLowerCase().startsWith("cf_") || item.getName().toLowerCase().startsWith("cfc_")) + return false; + + for (Item i : item.getBaseItems()) { + if (i.getName().toLowerCase().startsWith("cf_") || i.getName().toLowerCase().startsWith("cfc_") || i.getName().toLowerCase().startsWith("rentable_bot")) + return false; + } + + return !item.getName().toLowerCase().startsWith("rentable_bot_"); + } + + public void update(ResultSet set) throws SQLException { this.load(set); } - private void load(ResultSet set) throws SQLException - { - this.id = set.getInt("id"); - this.pageId = set.getInt("page_id"); - this.itemId = set.getString("item_Ids"); - this.name = set.getString("catalog_name"); - this.credits = set.getInt("cost_credits"); - this.points = set.getInt("cost_points"); - this.pointsType = set.getShort("points_type"); - this.amount = set.getInt("amount"); + private void load(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.pageId = set.getInt("page_id"); + this.itemId = set.getString("item_Ids"); + this.name = set.getString("catalog_name"); + this.credits = set.getInt("cost_credits"); + this.points = set.getInt("cost_points"); + this.pointsType = set.getShort("points_type"); + this.amount = set.getInt("amount"); this.limitedStack = set.getInt("limited_stack"); this.limitedSells = set.getInt("limited_sells"); - this.extradata = set.getString("extradata"); - this.clubOnly = set.getBoolean("club_only"); - this.haveOffer = set.getBoolean("have_offer"); - this.offerId = set.getInt("offer_id"); + this.extradata = set.getString("extradata"); + this.clubOnly = set.getBoolean("club_only"); + this.haveOffer = set.getBoolean("have_offer"); + this.offerId = set.getInt("offer_id"); this.orderNumber = set.getInt("order_number"); this.bundle = new HashMap<>(); this.loadBundle(); } - - public int getId() - { + public int getId() { return this.id; } - - public int getPageId() - { + public int getPageId() { return this.pageId; } - - public void setPageId(int pageId) - { + public void setPageId(int pageId) { this.pageId = pageId; } - - public String getItemId() - { + public String getItemId() { return this.itemId; } - - public void setItemId(String itemId) - { + public void setItemId(String itemId) { this.itemId = itemId; } - - public String getName() - { + public String getName() { return this.name; } - - public int getCredits() - { + public int getCredits() { return this.credits; } - - public int getPoints() - { + public int getPoints() { return this.points; } - - public int getPointsType() - { + public int getPointsType() { return this.pointsType; } - - public int getAmount() - { + public int getAmount() { return this.amount; } - - public int getLimitedStack() - { + public int getLimitedStack() { return this.limitedStack; } - - public int getLimitedSells() - { + public int getLimitedSells() { CatalogLimitedConfiguration ltdConfig = Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(this); - if (ltdConfig != null) - { + if (ltdConfig != null) { return this.limitedStack - ltdConfig.available(); } return this.limitedStack; } - - public String getExtradata() - { + public String getExtradata() { return this.extradata; } - - public boolean isClubOnly() - { + public boolean isClubOnly() { return this.clubOnly; } - - public boolean isHaveOffer() - { + public boolean isHaveOffer() { return this.haveOffer; } - - public int getOfferId() - { + public int getOfferId() { return this.offerId; } - - public boolean isLimited() - { + public boolean isLimited() { return this.limitedStack > 0; } - - private int getOrderNumber() - { + private int getOrderNumber() { return this.orderNumber; } - - public synchronized void sellRare() - { + public synchronized void sellRare() { this.limitedSells++; this.needsUpdate = true; - if(this.limitedSells == this.limitedStack) - { + if (this.limitedSells == this.limitedStack) { Emulator.getGameEnvironment().getCatalogManager().moveCatalogItem(this, Emulator.getConfig().getInt("catalog.ltd.page.soldout")); } Emulator.getThreading().run(this); } - - public THashSet getBaseItems() - { + public THashSet getBaseItems() { THashSet items = new THashSet<>(); - if(!this.itemId.isEmpty()) - { + if (!this.itemId.isEmpty()) { String[] itemIds = this.itemId.split(";"); - for (String itemId : itemIds) - { + for (String itemId : itemIds) { if (itemId.isEmpty()) continue; - if (itemId.contains(":")) - { + if (itemId.contains(":")) { itemId = itemId.split(":")[0]; } int identifier; - try - { + try { - identifier = Integer.parseInt(itemId); - } - catch (Exception e) - { + identifier = Integer.parseInt(itemId); + } catch (Exception e) { Emulator.getLogging().logStart("Invalid value (" + itemId + ") for items_base column for catalog_item id (" + this.id + "). Value must be integer or of the format of integer:amount;integer:amount"); continue; } - if (identifier > 0) - { + if (identifier > 0) { Item item = Emulator.getGameEnvironment().getItemManager().getItem(identifier); if (item != null) @@ -276,76 +226,55 @@ public class CatalogItem implements ISerialize, Runnable, Comparable getBundle() - { + public HashMap getBundle() { return this.bundle; } - - public void loadBundle() - { + public void loadBundle() { int intItemId; - if(this.itemId.contains(";")) - { - try - { + if (this.itemId.contains(";")) { + try { String[] itemIds = this.itemId.split(";"); - for (String itemId : itemIds) - { - if (itemId.contains(":")) - { + for (String itemId : itemIds) { + if (itemId.contains(":")) { String[] data = itemId.split(":"); - if (data.length > 1 && Integer.parseInt(data[0]) > 0 && Integer.parseInt(data[1]) > 0) - { + if (data.length > 1 && Integer.parseInt(data[0]) > 0 && Integer.parseInt(data[1]) > 0) { this.bundle.put(Integer.parseInt(data[0]), Integer.parseInt(data[1])); } - } else - { - if (!itemId.isEmpty()) - { + } else { + if (!itemId.isEmpty()) { intItemId = (Integer.parseInt(itemId)); this.bundle.put(intItemId, 1); } } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logDebugLine("Failed to load " + this.itemId); Emulator.getLogging().logErrorLine(e); } - } - else - { - try - { + } else { + try { Item item = Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(this.itemId)); - if (item != null) - { + if (item != null) { this.allowGift = item.allowGift(); } + } catch (Exception e) { } - catch (Exception e) - {} } } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.getId()); message.appendString(this.getName()); message.appendBoolean(false); @@ -358,60 +287,41 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 1) - return false; - - if(item.getName().toLowerCase().startsWith("cf_") || item.getName().toLowerCase().startsWith("cfc_")) - return false; - - for(Item i : item.getBaseItems()) - { - if(i.getName().toLowerCase().startsWith("cf_") || i.getName().toLowerCase().startsWith("cfc_") || i.getName().toLowerCase().startsWith("rentable_bot")) - return false; - } - - return !item.getName().toLowerCase().startsWith("rentable_bot_"); - } } 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 37a7e473..2477bfce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java @@ -10,119 +10,94 @@ import java.sql.SQLException; import java.util.Collections; import java.util.LinkedList; -public class CatalogLimitedConfiguration implements Runnable -{ +public class CatalogLimitedConfiguration implements Runnable { private final int itemId; - private int totalSet; private final LinkedList limitedNumbers; + private int totalSet; - public CatalogLimitedConfiguration(int itemId, LinkedList availableNumbers, int totalSet) - { + public CatalogLimitedConfiguration(int itemId, LinkedList availableNumbers, int totalSet) { this.itemId = itemId; this.totalSet = totalSet; this.limitedNumbers = availableNumbers; - if(Emulator.getConfig().getBoolean("catalog.ltd.random", true)) { + if (Emulator.getConfig().getBoolean("catalog.ltd.random", true)) { Collections.shuffle(this.limitedNumbers); - } - else { + } else { Collections.reverse(this.limitedNumbers); } } - public int getNumber() - { - synchronized (this.limitedNumbers) - { + public int getNumber() { + synchronized (this.limitedNumbers) { int num = this.limitedNumbers.pop(); - if(this.limitedNumbers.isEmpty()) - { + if (this.limitedNumbers.isEmpty()) { Emulator.getGameEnvironment().getCatalogManager().moveCatalogItem(Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.itemId), Emulator.getConfig().getInt("catalog.ltd.page.soldout")); } return num; } } - public void limitedSold(int catalogItemId, Habbo habbo, HabboItem item) - { - synchronized (this.limitedNumbers) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items_limited SET user_id = ?, timestamp = ?, item_id = ? WHERE catalog_item_id = ? AND number = ? AND user_id = 0 LIMIT 1")) - { + public void limitedSold(int catalogItemId, Habbo habbo, HabboItem item) { + synchronized (this.limitedNumbers) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items_limited SET user_id = ?, timestamp = ?, item_id = ? WHERE catalog_item_id = ? AND number = ? AND user_id = 0 LIMIT 1")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getIntUnixTimestamp()); statement.setInt(3, item.getId()); statement.setInt(4, catalogItemId); statement.setInt(5, item.getLimitedSells()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public void generateNumbers(int starting, int amount) - { - synchronized (this.limitedNumbers) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items_limited (catalog_item_id, number) VALUES (?, ?)")) - { + public void generateNumbers(int starting, int amount) { + synchronized (this.limitedNumbers) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items_limited (catalog_item_id, number) VALUES (?, ?)")) { statement.setInt(1, this.itemId); - for (int i = starting; i <= amount; i++) - { + for (int i = starting; i <= amount; i++) { statement.setInt(2, i); statement.addBatch(); this.limitedNumbers.push(i); } statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } this.totalSet += amount; - if(Emulator.getConfig().getBoolean("catalog.ltd.random", true)) { + if (Emulator.getConfig().getBoolean("catalog.ltd.random", true)) { Collections.shuffle(this.limitedNumbers); - } - else { + } else { Collections.reverse(this.limitedNumbers); } } } - public int available() - { + public int available() { return this.limitedNumbers.size(); } - public int getTotalSet() - { + public int getTotalSet() { return this.totalSet; } - public void setTotalSet(int totalSet) - { + public void setTotalSet(int totalSet) { this.totalSet = totalSet; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items SET limited_stack = ?, limited_sells = ? WHERE id = ?")) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items SET limited_stack = ?, limited_sells = ? WHERE id = ?")) { statement.setInt(1, this.totalSet); statement.setInt(2, this.totalSet - this.available()); statement.setInt(3, this.itemId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } 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 6acfe1c3..2658c248 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -43,173 +43,175 @@ import java.sql.*; import java.util.*; import java.util.stream.Collectors; -public class CatalogManager -{ +public class CatalogManager { - public final TIntObjectMap catalogPages; - - - public final TIntObjectMap catalogFeaturedPages; - - - public final THashMap> prizes; - - - public final THashMap giftWrappers; - - - public final THashMap giftFurnis; - - - public final THashSet clubItems; - - - public final THashMap clubOffers; - - - public final THashMap targetOffers; - - - public final THashMap clothing; - - - public final TIntIntHashMap offerDefs; - - - private final List vouchers; - - - public final Item ecotronItem; - - - public final THashMap limitedNumbers; - - - public static int catalogItemAmount; - - - public static int PURCHASE_COOLDOWN = 1; - - - public static boolean SORT_USING_ORDERNUM = false; - - public final THashMap calendarRewards; - - - public static final THashMap> pageDefinitions = new THashMap>(CatalogPageLayouts.values().length) - { + public static final THashMap> pageDefinitions = new THashMap>(CatalogPageLayouts.values().length) { { - for (CatalogPageLayouts layout : CatalogPageLayouts.values()) - { - switch(layout) - { + for (CatalogPageLayouts layout : CatalogPageLayouts.values()) { + switch (layout) { case frontpage: - this.put(layout.name().toLowerCase(), FrontpageLayout.class); break; + this.put(layout.name().toLowerCase(), FrontpageLayout.class); + break; case badge_display: - this.put(layout.name().toLowerCase(), BadgeDisplayLayout.class); break; + this.put(layout.name().toLowerCase(), BadgeDisplayLayout.class); + break; case spaces_new: - this.put(layout.name().toLowerCase(), SpacesLayout.class); break; + this.put(layout.name().toLowerCase(), SpacesLayout.class); + break; case trophies: - this.put(layout.name().toLowerCase(), TrophiesLayout.class); break; + this.put(layout.name().toLowerCase(), TrophiesLayout.class); + break; case bots: - this.put(layout.name().toLowerCase(), BotsLayout.class); break; + this.put(layout.name().toLowerCase(), BotsLayout.class); + break; case club_buy: - this.put(layout.name().toLowerCase(), ClubBuyLayout.class); break; + this.put(layout.name().toLowerCase(), ClubBuyLayout.class); + break; case club_gift: - this.put(layout.name().toLowerCase(), ClubGiftsLayout.class); break; + this.put(layout.name().toLowerCase(), ClubGiftsLayout.class); + break; case sold_ltd_items: - this.put(layout.name().toLowerCase(), SoldLTDItemsLayout.class); break; + this.put(layout.name().toLowerCase(), SoldLTDItemsLayout.class); + break; case single_bundle: - this.put(layout.name().toLowerCase(), SingleBundle.class); break; + this.put(layout.name().toLowerCase(), SingleBundle.class); + break; case roomads: - this.put(layout.name().toLowerCase(), RoomAdsLayout.class); break; - case recycler: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) - this.put(layout.name().toLowerCase(), RecyclerLayout.class); break; - case recycler_info: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) - this.put(layout.name().toLowerCase(), RecyclerInfoLayout.class); - case recycler_prizes: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) - this.put(layout.name().toLowerCase(), RecyclerPrizesLayout.class); break; - case marketplace: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) - this.put(layout.name().toLowerCase(), MarketplaceLayout.class); break; - case marketplace_own_items: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) - this.put(layout.name().toLowerCase(), MarketplaceOwnItems.class); break; + this.put(layout.name().toLowerCase(), RoomAdsLayout.class); + break; + case recycler: + if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) + this.put(layout.name().toLowerCase(), RecyclerLayout.class); + break; + case recycler_info: + if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) + this.put(layout.name().toLowerCase(), RecyclerInfoLayout.class); + case recycler_prizes: + if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) + this.put(layout.name().toLowerCase(), RecyclerPrizesLayout.class); + break; + case marketplace: + if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) + this.put(layout.name().toLowerCase(), MarketplaceLayout.class); + break; + case marketplace_own_items: + if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) + this.put(layout.name().toLowerCase(), MarketplaceOwnItems.class); + break; case info_duckets: - this.put(layout.name().toLowerCase(), InfoDucketsLayout.class); break; + this.put(layout.name().toLowerCase(), InfoDucketsLayout.class); + break; case info_pets: - this.put(layout.name().toLowerCase(), InfoPetsLayout.class); break; + this.put(layout.name().toLowerCase(), InfoPetsLayout.class); + break; case info_rentables: - this.put(layout.name().toLowerCase(), InfoRentablesLayout.class); break; + this.put(layout.name().toLowerCase(), InfoRentablesLayout.class); + break; case info_loyalty: - this.put(layout.name().toLowerCase(), InfoLoyaltyLayout.class); break; + this.put(layout.name().toLowerCase(), InfoLoyaltyLayout.class); + break; case loyalty_vip_buy: - this.put(layout.name().toLowerCase(), LoyaltyVipBuyLayout.class); break; + this.put(layout.name().toLowerCase(), LoyaltyVipBuyLayout.class); + break; case guilds: - this.put(layout.name().toLowerCase(), GuildFrontpageLayout.class); break; + this.put(layout.name().toLowerCase(), GuildFrontpageLayout.class); + break; case guild_furni: - this.put(layout.name().toLowerCase(), GuildFurnitureLayout.class); break; + this.put(layout.name().toLowerCase(), GuildFurnitureLayout.class); + break; case guild_forum: - this.put(layout.name().toLowerCase(), GuildForumLayout.class); break; + this.put(layout.name().toLowerCase(), GuildForumLayout.class); + break; case pets: - this.put(layout.name().toLowerCase(), PetsLayout.class); break; + this.put(layout.name().toLowerCase(), PetsLayout.class); + break; case pets2: - this.put(layout.name().toLowerCase(), Pets2Layout.class); break; + this.put(layout.name().toLowerCase(), Pets2Layout.class); + break; case pets3: - this.put(layout.name().toLowerCase(), Pets3Layout.class); break; + this.put(layout.name().toLowerCase(), Pets3Layout.class); + break; case soundmachine: - this.put(layout.name().toLowerCase(), TraxLayout.class); break; + this.put(layout.name().toLowerCase(), TraxLayout.class); + break; case default_3x3_color_grouping: - this.put(layout.name().toLowerCase(), ColorGroupingLayout.class); break; + this.put(layout.name().toLowerCase(), ColorGroupingLayout.class); + break; case recent_purchases: - this.put(layout.name().toLowerCase(), RecentPurchasesLayout.class); break; + this.put(layout.name().toLowerCase(), RecentPurchasesLayout.class); + break; case room_bundle: - this.put(layout.name().toLowerCase(), RoomBundleLayout.class); break; + this.put(layout.name().toLowerCase(), RoomBundleLayout.class); + break; case petcustomization: - this.put(layout.name().toLowerCase(), PetCustomizationLayout.class); break; + this.put(layout.name().toLowerCase(), PetCustomizationLayout.class); + break; case vip_buy: - this.put(layout.name().toLowerCase(), VipBuyLayout.class); break; + this.put(layout.name().toLowerCase(), VipBuyLayout.class); + break; case frontpage_featured: - this.put(layout.name().toLowerCase(), FrontPageFeaturedLayout.class); break; + this.put(layout.name().toLowerCase(), FrontPageFeaturedLayout.class); + break; case builders_club_addons: - this.put(layout.name().toLowerCase(), BuildersClubAddonsLayout.class); break; + this.put(layout.name().toLowerCase(), BuildersClubAddonsLayout.class); + break; case builders_club_frontpage: - this.put(layout.name().toLowerCase(), BuildersClubFrontPageLayout.class); break; + this.put(layout.name().toLowerCase(), BuildersClubFrontPageLayout.class); + break; case builders_club_loyalty: - this.put(layout.name().toLowerCase(), BuildersClubLoyaltyLayout.class); break; + this.put(layout.name().toLowerCase(), BuildersClubLoyaltyLayout.class); + break; case default_3x3: default: - this.put("default_3x3", Default_3x3Layout.class); break; + this.put("default_3x3", Default_3x3Layout.class); + break; } } } }; + public static int catalogItemAmount; + public static int PURCHASE_COOLDOWN = 1; + public static boolean SORT_USING_ORDERNUM = false; + public final TIntObjectMap catalogPages; + public final TIntObjectMap catalogFeaturedPages; + public final THashMap> prizes; + public final THashMap giftWrappers; + public final THashMap giftFurnis; + public final THashSet clubItems; + public final THashMap clubOffers; + public final THashMap targetOffers; + public final THashMap clothing; + public final TIntIntHashMap offerDefs; + public final Item ecotronItem; + public final THashMap limitedNumbers; + public final THashMap calendarRewards; + private final List vouchers; - public CatalogManager() - { - long millis = System.currentTimeMillis(); - this.catalogPages = TCollections.synchronizedMap(new TIntObjectHashMap<>()); - this.catalogFeaturedPages = new TIntObjectHashMap<>(); - this.prizes = new THashMap<>(); - this.giftWrappers = new THashMap<>(); - this.giftFurnis = new THashMap<>(); - this.clubItems = new THashSet<>(); - this.clubOffers = new THashMap<>(); - this.targetOffers = new THashMap<>(); - this.clothing = new THashMap<>(); - this.offerDefs = new TIntIntHashMap(); - this.vouchers = new ArrayList<>(); - this.limitedNumbers = new THashMap<>(); - this.calendarRewards = new THashMap<>(); + public CatalogManager() { + long millis = System.currentTimeMillis(); + this.catalogPages = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + this.catalogFeaturedPages = new TIntObjectHashMap<>(); + this.prizes = new THashMap<>(); + this.giftWrappers = new THashMap<>(); + this.giftFurnis = new THashMap<>(); + this.clubItems = new THashSet<>(); + this.clubOffers = new THashMap<>(); + this.targetOffers = new THashMap<>(); + this.clothing = new THashMap<>(); + this.offerDefs = new TIntIntHashMap(); + this.vouchers = new ArrayList<>(); + this.limitedNumbers = new THashMap<>(); + this.calendarRewards = new THashMap<>(); this.initialize(); this.ecotronItem = Emulator.getGameEnvironment().getItemManager().getItem("ecotron_box"); - Emulator.getLogging().logStart("Catalog Manager -> Loaded! ("+(System.currentTimeMillis() - millis)+" MS)"); + Emulator.getLogging().logStart("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public synchronized void initialize() - { + public synchronized void initialize() { Emulator.getPluginManager().fireEvent(new EmulatorLoadCatalogManagerEvent()); this.loadLimitedNumbers(); @@ -225,99 +227,73 @@ public class CatalogManager this.loadCalendarRewards(); } - private synchronized void loadLimitedNumbers() - { + private synchronized void loadLimitedNumbers() { this.limitedNumbers.clear(); THashMap> limiteds = new THashMap<>(); TIntIntHashMap totals = new TIntIntHashMap(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_items_limited")) - { - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - if (!limiteds.containsKey(set.getInt("catalog_item_id"))) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_items_limited")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (!limiteds.containsKey(set.getInt("catalog_item_id"))) { limiteds.put(set.getInt("catalog_item_id"), new LinkedList<>()); } totals.adjustOrPutValue(set.getInt("catalog_item_id"), 1, 1); - if (set.getInt("user_id") == 0) - { + if (set.getInt("user_id") == 0) { limiteds.get(set.getInt("catalog_item_id")).push(set.getInt("number")); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - for (Map.Entry> set : limiteds.entrySet()) - { + for (Map.Entry> set : limiteds.entrySet()) { this.limitedNumbers.put(set.getKey(), new CatalogLimitedConfiguration(set.getKey(), set.getValue(), totals.get(set.getKey()))); } } - private synchronized void loadCatalogPages() - { + private synchronized void loadCatalogPages() { this.catalogPages.clear(); final THashMap pages = new THashMap<>(); pages.put(-1, new CatalogRootLayout()); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_pages ORDER BY parent_id, id")) - { - try (ResultSet set = statement.executeQuery()) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_pages ORDER BY parent_id, id")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Class pageClazz = pageDefinitions.get(set.getString("page_layout")); - if (pageClazz == null) - { + if (pageClazz == null) { Emulator.getLogging().logStart("Unknown Page Layout: " + set.getString("page_layout")); continue; } - try - { + try { CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set); pages.put(page.getId(), page); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to load layout: " + set.getString("page_layout")); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - pages.forEachValue(new TObjectProcedure() - { + pages.forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogPage object) - { + public boolean execute(CatalogPage object) { CatalogPage page = pages.get(object.parentId); - if (page != null) - { - if (page.id != object.id) - { + if (page != null) { + if (page.id != object.id) { page.addChildPage(object); } - } - else - { - if (object.parentId != -2) - { + } else { + if (object.parentId != -2) { Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); } } @@ -331,14 +307,11 @@ public class CatalogManager } - private synchronized void loadCatalogFeaturedPages() - { + private synchronized void loadCatalogFeaturedPages() { this.catalogFeaturedPages.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_featured_pages ORDER BY slot_id ASC")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_featured_pages ORDER BY slot_id ASC")) { + while (set.next()) { this.catalogFeaturedPages.put(set.getInt("slot_id"), new CatalogFeaturedPage( set.getInt("slot_id"), set.getString("caption"), @@ -348,30 +321,24 @@ public class CatalogManager set.getString("page_name"), set.getInt("page_id"), set.getString("product_name") - )); + )); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private synchronized void loadCatalogItems() - { + private synchronized void loadCatalogItems() { this.clubItems.clear(); catalogItemAmount = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_items")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_items")) { CatalogItem item; - while (set.next()) - { + while (set.next()) { if (set.getString("item_ids").equals("0")) continue; - if(set.getString("catalog_name").contains("HABBO_CLUB_")) - { + if (set.getString("catalog_name").contains("HABBO_CLUB_")) { this.clubItems.add(new CatalogItem(set)); continue; } @@ -383,163 +350,119 @@ public class CatalogManager item = page.getCatalogItem(set.getInt("id")); - if (item == null) - { + if (item == null) { catalogItemAmount++; item = new CatalogItem(set); page.addItem(item); - if(item.getOfferId() != -1) - { + if (item.getOfferId() != -1) { page.addOfferId(item.getOfferId()); this.offerDefs.put(item.getOfferId(), item.getId()); } - } - else + } else item.update(set); - if (item.isLimited()) - { + if (item.isLimited()) { this.createOrUpdateLimitedConfig(item); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - for (CatalogPage page : this.catalogPages.valueCollection()) - { - for (Integer id : page.getIncluded()) - { + for (CatalogPage page : this.catalogPages.valueCollection()) { + for (Integer id : page.getIncluded()) { CatalogPage p = this.catalogPages.get(id); - if (p != null) - { + if (p != null) { page.getCatalogItems().putAll(p.getCatalogItems()); } } } } - private void loadClubOffers() - { - this.clubOffers.clear(); + private void loadClubOffers() { + this.clubOffers.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_club_offers WHERE enabled = ?")) - { - statement.setString(1, "1"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - this.clubOffers.put(set.getInt("id"), new ClubOffer(set)); - } - } - } - catch (SQLException e) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_club_offers WHERE enabled = ?")) { + statement.setString(1, "1"); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.clubOffers.put(set.getInt("id"), new ClubOffer(set)); + } + } + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadTargetOffers() - { - synchronized (this.targetOffers) - { + private void loadTargetOffers() { + synchronized (this.targetOffers) { this.targetOffers.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_target_offers WHERE end_timestamp > ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_target_offers WHERE end_timestamp > ?")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.targetOffers.put(set.getInt("id"), new TargetOffer(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - private void loadVouchers() - { - synchronized (this.vouchers) - { + private void loadVouchers() { + synchronized (this.vouchers) { this.vouchers.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM vouchers")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM vouchers")) { + while (set.next()) { this.vouchers.add(new Voucher(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public void loadRecycler() - { - synchronized (this.prizes) - { + public void loadRecycler() { + synchronized (this.prizes) { this.prizes.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM recycler_prizes")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM recycler_prizes")) { + while (set.next()) { Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("item_id")); - if (item != null) - { - if (this.prizes.get(set.getInt("rarity")) == null) - { + if (item != null) { + if (this.prizes.get(set.getInt("rarity")) == null) { this.prizes.put(set.getInt("rarity"), new THashSet<>()); } this.prizes.get(set.getInt("rarity")).add(item); - } - else - { + } else { Emulator.getLogging().logErrorLine("Cannot load item with ID:" + set.getInt("item_id") + " as recycler reward!"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public void loadGiftWrappers() - { - synchronized (this.giftWrappers) - { - synchronized (this.giftFurnis) - { + public void loadGiftWrappers() { + synchronized (this.giftWrappers) { + synchronized (this.giftFurnis) { this.giftWrappers.clear(); this.giftFurnis.clear(); - 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")) - { + 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; @@ -549,65 +472,47 @@ public class CatalogManager break; } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } } - private void loadCalendarRewards() - { - synchronized (this.calendarRewards) - { + private void loadCalendarRewards() { + synchronized (this.calendarRewards) { this.calendarRewards.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) - { - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.calendarRewards.put(set.getInt("id"), new CalendarRewardObject(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - private void loadClothing() - { - synchronized (this.clothing) - { + private void loadClothing() { + synchronized (this.clothing) { this.clothing.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_clothing")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_clothing")) { + while (set.next()) { this.clothing.put(set.getInt("id"), new ClothItem(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public ClothItem getClothing(String name) - { - for (ClothItem item : this.clothing.values()) - { - if (item.name.equalsIgnoreCase(name)) - { + public ClothItem getClothing(String name) { + for (ClothItem item : this.clothing.values()) { + if (item.name.equalsIgnoreCase(name)) { return item; } } @@ -616,14 +521,10 @@ public class CatalogManager } - public Voucher getVoucher(String code) - { - synchronized (this.vouchers) - { - for (Voucher voucher : this.vouchers) - { - if (voucher.code.equals(code)) - { + public Voucher getVoucher(String code) { + synchronized (this.vouchers) { + for (Voucher voucher : this.vouchers) { + if (voucher.code.equals(code)) { return voucher; } } @@ -632,34 +533,27 @@ public class CatalogManager } - public void redeemVoucher(GameClient client, String voucherCode) - { + public void redeemVoucher(GameClient client, String voucherCode) { Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode); - if(voucher != null) - { - if(Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) - { + if (voucher != null) { + if (Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { client.getHabbo().getHabboInfo().addCredits(voucher.credits); - if(voucher.points > 0) - { + if (voucher.points > 0) { client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType)); } - if(voucher.credits > 0) - { + if (voucher.credits > 0) { client.getHabbo().getHabboInfo().addCredits(voucher.credits); client.sendResponse(new UserCreditsComposer(client.getHabbo())); } - if (voucher.catalogItemId > 0) - { + if (voucher.catalogItemId > 0) { CatalogItem item = this.getCatalogItem(voucher.catalogItemId); - if (item != null) - { + if (item != null) { this.purchaseItem(null, item, client.getHabbo(), 1, "", true); } } @@ -674,21 +568,16 @@ public class CatalogManager } - public boolean deleteVoucher(Voucher voucher) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM vouchers WHERE code = ?")) - { + 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); - synchronized (this.vouchers) - { + synchronized (this.vouchers) { this.vouchers.remove(voucher); } return statement.executeUpdate() >= 1; - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -696,24 +585,18 @@ public class CatalogManager } - public CatalogPage getCatalogPage(int pageId) - { + public CatalogPage getCatalogPage(int pageId) { return this.catalogPages.get(pageId); } - public CatalogPage getCatalogPage(final String captionSafe) - { + public CatalogPage getCatalogPage(final String captionSafe) { final CatalogPage[] page = {null}; - synchronized (this.catalogPages) - { - this.catalogPages.forEachValue(new TObjectProcedure() - { + synchronized (this.catalogPages) { + this.catalogPages.forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogPage object) - { - if(object.getPageName().equalsIgnoreCase(captionSafe)) - { + public boolean execute(CatalogPage object) { + if (object.getPageName().equalsIgnoreCase(captionSafe)) { page[0] = object; return false; } @@ -727,16 +610,12 @@ public class CatalogManager } - public CatalogItem getCatalogItem(int id) - { + public CatalogItem getCatalogItem(int id) { final CatalogItem[] item = {null}; - synchronized (this.catalogPages) - { - this.catalogPages.forEachValue(new TObjectProcedure() - { + synchronized (this.catalogPages) { + this.catalogPages.forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogPage object) - { + public boolean execute(CatalogPage object) { item[0] = object.getCatalogItem(id); return item[0] == null; @@ -748,17 +627,13 @@ public class CatalogManager } - public List getCatalogPages(int parentId, final Habbo habbo) - { + public List getCatalogPages(int parentId, final Habbo habbo) { final List pages = new ArrayList<>(); - this.catalogPages.get(parentId).childPages.forEachValue(new TObjectProcedure() - { + this.catalogPages.get(parentId).childPages.forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogPage object) - { - if (object.getRank() <= habbo.getHabboInfo().getRank().getId() && object.visible) - { + public boolean execute(CatalogPage object) { + if (object.getRank() <= habbo.getHabboInfo().getRank().getId() && object.visible) { pages.add(object); } @@ -770,18 +645,14 @@ public class CatalogManager return pages; } - public TIntObjectMap getCatalogFeaturedPages() - { + public TIntObjectMap getCatalogFeaturedPages() { return this.catalogFeaturedPages; } - public CatalogItem getClubItem(int itemId) - { - synchronized (this.clubItems) - { - for (CatalogItem item : this.clubItems) - { + public CatalogItem getClubItem(int itemId) { + synchronized (this.clubItems) { + for (CatalogItem item : this.clubItems) { if (item.getId() == itemId) return item; } @@ -791,11 +662,10 @@ public class CatalogManager } - public boolean moveCatalogItem(CatalogItem item, int pageId) - { + public boolean moveCatalogItem(CatalogItem item, int pageId) { CatalogPage page = this.getCatalogPage(item.getPageId()); - if(page == null) + if (page == null) return false; page.getCatalogItems().remove(item.getId()); @@ -811,33 +681,22 @@ public class CatalogManager } - public Item getRandomRecyclerPrize() - { + public Item getRandomRecyclerPrize() { int level = 1; - if(Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.5")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.5")) - { + if (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.5")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.5")) { level = 5; - } - else if(Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.4")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.4")) - { + } else if (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.4")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.4")) { level = 4; - } - else if(Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.3")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.3")) - { + } else if (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.3")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.3")) { level = 3; - } - else if(Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.2")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.2")) - { + } else if (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.2")) + 1 == Emulator.getConfig().getInt("hotel.ecotron.rarity.chance.2")) { level = 2; } - if (this.prizes.containsKey(level) && !this.prizes.get(level).isEmpty()) - { + 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 - { + } else { Emulator.getLogging().logErrorLine("[Recycler] No rewards specified for rarity level " + level); } @@ -845,11 +704,9 @@ public class CatalogManager } - public CatalogPage createCatalogPage(String caption, String captionSave, int roomId, int icon, CatalogPageLayouts layout, int minRank, int parentId) - { + public CatalogPage createCatalogPage(String caption, String captionSave, int roomId, int icon, CatalogPageLayouts layout, int minRank, int parentId) { CatalogPage catalogPage = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_pages (parent_id, caption, caption_save, icon_image, visible, enabled, min_rank, page_layout, room_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_pages (parent_id, caption, caption_save, icon_image, visible, enabled, min_rank, page_layout, room_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, parentId); statement.setString(2, caption); statement.setString(3, captionSave); @@ -860,32 +717,21 @@ public class CatalogManager statement.setString(8, layout.name()); statement.setInt(9, roomId); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { - try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM catalog_pages WHERE id = ?")) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { + try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM catalog_pages WHERE id = ?")) { stmt.setInt(1, set.getInt(1)); - try (ResultSet page = stmt.executeQuery()) - { - if (page.next()) - { + try (ResultSet page = stmt.executeQuery()) { + if (page.next()) { Class pageClazz = pageDefinitions.get(page.getString("page_layout")); - if (pageClazz != null) - { - try - { + if (pageClazz != null) { + try { catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - } - else - { + } else { Emulator.getLogging().logErrorLine("Unknown Page Layout: " + page.getString("page_layout")); } } @@ -893,14 +739,11 @@ public class CatalogManager } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if(catalogPage != null) - { + if (catalogPage != null) { this.catalogPages.put(catalogPage.getId(), catalogPage); } @@ -908,41 +751,28 @@ public class CatalogManager } - public CatalogLimitedConfiguration getLimitedConfig(CatalogItem item) - { - synchronized (this.limitedNumbers) - { + public CatalogLimitedConfiguration getLimitedConfig(CatalogItem item) { + synchronized (this.limitedNumbers) { return this.limitedNumbers.get(item.getId()); } } - public CatalogLimitedConfiguration createOrUpdateLimitedConfig(CatalogItem item) - { - if (item.isLimited()) - { + public CatalogLimitedConfiguration createOrUpdateLimitedConfig(CatalogItem item) { + if (item.isLimited()) { CatalogLimitedConfiguration limitedConfiguration = this.limitedNumbers.get(item.getId()); - if (limitedConfiguration == null) - { + if (limitedConfiguration == null) { limitedConfiguration = new CatalogLimitedConfiguration(item.getId(), new LinkedList<>(), 0); limitedConfiguration.generateNumbers(1, item.limitedStack); this.limitedNumbers.put(item.getId(), limitedConfiguration); - } - else - { - if (limitedConfiguration.getTotalSet() != item.limitedStack) - { - if (limitedConfiguration.getTotalSet() == 0) - { + } else { + if (limitedConfiguration.getTotalSet() != item.limitedStack) { + if (limitedConfiguration.getTotalSet() == 0) { limitedConfiguration.setTotalSet(item.limitedStack); - } - else if (item.limitedStack > limitedConfiguration.getTotalSet()) - { + } else if (item.limitedStack > limitedConfiguration.getTotalSet()) { limitedConfiguration.generateNumbers(item.limitedStack + 1, item.limitedStack - limitedConfiguration.getTotalSet()); - } - else - { + } else { item.limitedStack = limitedConfiguration.getTotalSet(); } } @@ -955,19 +785,15 @@ public class CatalogManager } - public void dispose() - { + public void dispose() { TIntObjectIterator pageIterator = this.catalogPages.iterator(); - while (pageIterator.hasNext()) - { + while (pageIterator.hasNext()) { pageIterator.advance(); - for(CatalogItem item : pageIterator.value().getCatalogItems().valueCollection()) - { + for (CatalogItem item : pageIterator.value().getCatalogItems().valueCollection()) { item.run(); - if(item.isLimited()) - { + if (item.isLimited()) { this.limitedNumbers.get(item.getId()).run(); } } @@ -977,73 +803,58 @@ public class CatalogManager } - public void purchaseItem(CatalogPage page, CatalogItem item, Habbo habbo, int amount, String extradata, boolean free) - { + public void purchaseItem(CatalogPage page, CatalogItem item, Habbo habbo, int amount, String extradata, boolean free) { Item cBaseItem = null; - if(item == null || habbo.getHabboStats().isPurchasingFurniture) - { + if (item == null || habbo.getHabboStats().isPurchasingFurniture) { habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } habbo.getHabboStats().isPurchasingFurniture = true; - try - { - if (item.isClubOnly() && !habbo.getClient().getHabbo().getHabboStats().hasActiveClub()) - { + try { + if (item.isClubOnly() && !habbo.getClient().getHabbo().getHabboStats().hasActiveClub()) { habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.REQUIRES_CLUB)); return; } - if (amount <= 0) - { + if (amount <= 0) { habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } - try - { + try { CatalogLimitedConfiguration limitedConfiguration = null; int limitedStack = 0; int limitedNumber = 0; - if (item.isLimited()) - { + if (item.isLimited()) { amount = 1; - if (this.getLimitedConfig(item).available() == 0) - { + if (this.getLimitedConfig(item).available() == 0) { habbo.getClient().sendResponse(new AlertLimitedSoldOutComposer()); return; } - if (Emulator.getConfig().getBoolean("hotel.catalog.ltd.limit.enabled")) - { + if (Emulator.getConfig().getBoolean("hotel.catalog.ltd.limit.enabled")) { int ltdLimit = Emulator.getConfig().getInt("hotel.purchase.ltd.limit.daily.total"); - if (habbo.getHabboStats().totalLtds() >= ltdLimit) - { + if (habbo.getHabboStats().totalLtds() >= ltdLimit) { habbo.alert(Emulator.getTexts().getValue("error.catalog.buy.limited.daily.total").replace("%itemname%", item.getBaseItems().iterator().next().getFullName()).replace("%limit%", ltdLimit + "")); return; } ltdLimit = Emulator.getConfig().getInt("hotel.purchase.ltd.limit.daily.item"); - if (habbo.getHabboStats().totalLtds(item.id) >= ltdLimit) - { + if (habbo.getHabboStats().totalLtds(item.id) >= ltdLimit) { habbo.alert(Emulator.getTexts().getValue("error.catalog.buy.limited.daily.item").replace("%itemname%", item.getBaseItems().iterator().next().getFullName()).replace("%limit%", ltdLimit + "")); return; } } } - if (amount > 1) - { - if (amount == item.getAmount()) - { + if (amount > 1) { + if (amount == item.getAmount()) { amount = 1; - } else - { - if (amount * item.getAmount() > 100) - { + } else { + if (amount * item.getAmount() > 100) { habbo.alert("Whoops! You tried to buy this " + (amount * item.getAmount()) + " times. This must've been a mistake."); habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; @@ -1054,8 +865,7 @@ public class CatalogManager THashSet itemsList = new THashSet<>(); - if (amount > 1 && !CatalogItem.haveOffer(item)) - { + if (amount > 1 && !CatalogItem.haveOffer(item)) { String message = Emulator.getTexts().getValue("scripter.warning.catalog.amount").replace("%username%", habbo.getHabboInfo().getUsername()).replace("%itemname%", item.getName()).replace("%pagename%", page.getCaption()); ScripterManager.scripterDetected(habbo.getClient(), message); Emulator.getLogging().logUserLine(message); @@ -1063,12 +873,10 @@ public class CatalogManager return; } - if (item.isLimited()) - { + if (item.isLimited()) { limitedConfiguration = this.getLimitedConfig(item); - if (limitedConfiguration == null) - { + if (limitedConfiguration == null) { limitedConfiguration = this.createOrUpdateLimitedConfig(item); } @@ -1080,7 +888,8 @@ public class CatalogManager int totalPoints = free ? 0 : this.calculateDiscountedPrice(item.getPoints(), amount, item); if (totalCredits > 0 && habbo.getHabboInfo().getCredits() - totalCredits < 0) return; - if (totalPoints > 0 && habbo.getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints < 0) return; + if (totalPoints > 0 && habbo.getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints < 0) + return; List badges = new ArrayList<>(); Map> unseenItems = new HashMap<>(); @@ -1248,45 +1057,36 @@ public class CatalogManager UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges); Emulator.getPluginManager().fireEvent(purchasedEvent); - if (badgeFound) - { + if (badgeFound) { habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE)); - if (item.getBaseItems().size() == 1) - { + if (item.getBaseItems().size() == 1) { return; } } - if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_credits")) - { - if (purchasedEvent.totalCredits > 0) - { + if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_credits")) { + if (purchasedEvent.totalCredits > 0) { habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.totalCredits); habbo.getClient().sendResponse(new UserCreditsComposer(habbo.getClient().getHabbo())); } } - if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_points")) - { - if (purchasedEvent.totalPoints > 0) - { + if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_points")) { + if (purchasedEvent.totalPoints > 0) { habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -purchasedEvent.totalPoints); habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -purchasedEvent.totalPoints, item.getPointsType())); } } - if (purchasedEvent.itemsList != null && !purchasedEvent.itemsList.isEmpty()) - { + if (purchasedEvent.itemsList != null && !purchasedEvent.itemsList.isEmpty()) { habbo.getClient().getHabbo().getInventory().getItemsComponent().addItems(purchasedEvent.itemsList); unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(HabboItem::getId).collect(Collectors.toList())); Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList)); - if (limitedConfiguration != null) - { - for (HabboItem itm : purchasedEvent.itemsList) - { + if (limitedConfiguration != null) { + for (HabboItem itm : purchasedEvent.itemsList) { limitedConfiguration.limitedSold(item.getId(), habbo, itm); } } @@ -1296,8 +1096,7 @@ public class CatalogManager unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BADGE, new ArrayList<>()); } - for (String b : purchasedEvent.badges) - { + for (String b : purchasedEvent.badges) { HabboBadge badge = new HabboBadge(0, b, 0, habbo); Emulator.getThreading().run(badge); habbo.getInventory().getBadgesComponent().addBadge(badge); @@ -1316,26 +1115,20 @@ public class CatalogManager habbo.getClient().sendResponse(new PurchaseOKComposer(purchasedEvent.catalogItem)); habbo.getClient().sendResponse(new InventoryRefreshComposer()); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logPacketError(e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } - } - finally - { + } finally { habbo.getHabboStats().isPurchasingFurniture = false; } } - public List getClubOffers() - { + public List getClubOffers() { List offers = new ArrayList<>(); - for (Map.Entry entry : this.clubOffers.entrySet()) - { - if (!entry.getValue().isDeal()) - { + for (Map.Entry entry : this.clubOffers.entrySet()) { + if (!entry.getValue().isDeal()) { offers.add(entry.getValue()); } } @@ -1343,28 +1136,22 @@ public class CatalogManager return offers; } - public void claimCalendarReward(Habbo habbo, int day) - { - if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) - { + public void claimCalendarReward(Habbo habbo, int day) { + if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) { habbo.getHabboStats().calendarRewardsClaimed.add(day); CalendarRewardObject object = this.calendarRewards.get(day); - if (object != null) - { + if (object != null) { object.give(habbo); habbo.getClient().sendResponse(new InventoryRefreshComposer()); habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object)); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, day); statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -1373,8 +1160,7 @@ public class CatalogManager } } - public TargetOffer getTargetOffer(int offerId) - { + public TargetOffer getTargetOffer(int offerId) { return this.targetOffers.get(offerId); } 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 c0e847ea..4c7562ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -13,8 +13,11 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -public abstract class CatalogPage implements Comparable, ISerialize -{ +public abstract class CatalogPage implements Comparable, ISerialize { + protected final TIntArrayList offerIds = new TIntArrayList(); + protected final THashMap childPages = new THashMap<>(); + private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + private final ArrayList included = new ArrayList<>(); protected int id; protected int parentId; protected int rank; @@ -34,50 +37,39 @@ public abstract class CatalogPage implements Comparable, ISerialize protected String textTwo; protected String textDetails; protected String textTeaser; - protected final TIntArrayList offerIds = new TIntArrayList(); - protected final THashMap childPages = new THashMap<>(); - private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); - private final ArrayList included = new ArrayList<>(); - public CatalogPage() - { + public CatalogPage() { } - public CatalogPage(ResultSet set) throws SQLException - { + public CatalogPage(ResultSet set) throws SQLException { if (set == null) return; this.id = set.getInt("id"); - this.parentId = set.getInt("parent_id"); - this.rank = set.getInt("min_rank"); - this.caption = set.getString("caption"); - this.pageName = set.getString("caption_save"); - this.iconColor = set.getInt("icon_color"); - this.iconImage = set.getInt("icon_image"); - this.orderNum = set.getInt("order_num"); - this.visible = set.getBoolean("visible"); - this.enabled = set.getBoolean("enabled"); - this.clubOnly = set.getBoolean("club_only"); - this.layout = set.getString("page_layout"); - this.headerImage = set.getString("page_headline"); - this.teaserImage = set.getString("page_teaser"); + this.parentId = set.getInt("parent_id"); + this.rank = set.getInt("min_rank"); + this.caption = set.getString("caption"); + this.pageName = set.getString("caption_save"); + this.iconColor = set.getInt("icon_color"); + this.iconImage = set.getInt("icon_image"); + this.orderNum = set.getInt("order_num"); + this.visible = set.getBoolean("visible"); + this.enabled = set.getBoolean("enabled"); + this.clubOnly = set.getBoolean("club_only"); + this.layout = set.getString("page_layout"); + this.headerImage = set.getString("page_headline"); + this.teaserImage = set.getString("page_teaser"); this.specialImage = set.getString("page_special"); - this.textOne = set.getString("page_text1"); - this.textTwo = set.getString("page_text2"); - this.textDetails = set.getString("page_text_details"); - this.textTeaser = set.getString("page_text_teaser"); + this.textOne = set.getString("page_text1"); + this.textTwo = set.getString("page_text2"); + this.textDetails = set.getString("page_text_details"); + this.textTeaser = set.getString("page_text_teaser"); - if (!set.getString("includes").isEmpty()) - { - for (String id : set.getString("includes").split(";")) - { - try - { + if (!set.getString("includes").isEmpty()) { + for (String id : set.getString("includes").split(";")) { + try { this.included.add(Integer.valueOf(id)); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); } @@ -85,147 +77,118 @@ public abstract class CatalogPage implements Comparable, ISerialize } } - public int getId() - { + public int getId() { return this.id; } - public int getParentId() - { + public int getParentId() { return this.parentId; } - public int getRank() - { + public int getRank() { return this.rank; } - public void setRank(int rank) - { + public void setRank(int rank) { this.rank = rank; } - public String getCaption() - { + public String getCaption() { return this.caption; } - public String getPageName() - { + public String getPageName() { return this.pageName; } - public int getIconColor() - { + public int getIconColor() { return this.iconColor; } - public int getIconImage() - { + public int getIconImage() { return this.iconImage; } - public int getOrderNum() - { + public int getOrderNum() { return this.orderNum; } - public boolean isVisible() - { + public boolean isVisible() { return this.visible; } - public boolean isEnabled() - { + public boolean isEnabled() { return this.enabled; } - public boolean isClubOnly() - { + public boolean isClubOnly() { return this.clubOnly; } - public String getLayout() - { + public String getLayout() { return this.layout; } - public String getHeaderImage() - { + public String getHeaderImage() { return this.headerImage; } - public String getTeaserImage() - { + public String getTeaserImage() { return this.teaserImage; } - public String getSpecialImage() - { + public String getSpecialImage() { return this.specialImage; } - public String getTextOne() - { + public String getTextOne() { return this.textOne; } - public String getTextTwo() - { + public String getTextTwo() { return this.textTwo; } - public String getTextDetails() - { + public String getTextDetails() { return this.textDetails; } - public String getTextTeaser() - { + public String getTextTeaser() { return this.textTeaser; } - public TIntArrayList getOfferIds() - { + public TIntArrayList getOfferIds() { return this.offerIds; } - public void addOfferId(int offerId) - { + public void addOfferId(int offerId) { this.offerIds.add(offerId); } - public void addItem(CatalogItem item) - { + public void addItem(CatalogItem item) { this.catalogItems.put(item.getId(), item); } - public TIntObjectMap getCatalogItems() - { + public TIntObjectMap getCatalogItems() { return this.catalogItems; } - public CatalogItem getCatalogItem(int id) - { + public CatalogItem getCatalogItem(int id) { return this.catalogItems.get(id); } - public ArrayList getIncluded() - { + public ArrayList getIncluded() { return this.included; } - public THashMap getChildPages() - { + public THashMap getChildPages() { return this.childPages; } - public void addChildPage(CatalogPage page) - { + public void addChildPage(CatalogPage page) { this.childPages.put(page.getId(), page); - if (page.getRank() < this.getRank()) - { + if (page.getRank() < this.getRank()) { page.setRank(this.getRank()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageLayouts.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageLayouts.java index 4791e652..9a8df100 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageLayouts.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageLayouts.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.catalog; -public enum CatalogPageLayouts -{ +public enum CatalogPageLayouts { default_3x3, diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageType.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageType.java index 4cc3fc6d..d270395f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageType.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPageType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.catalog; -public enum CatalogPageType -{ +public enum CatalogPageType { NORMAL, 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 21fd32bf..c99f81d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/ClothItem.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import java.sql.ResultSet; import java.sql.SQLException; -public class ClothItem -{ +public class ClothItem { public int id; @@ -14,15 +13,13 @@ public class ClothItem public int[] setId; - public ClothItem(ResultSet set) throws SQLException - { - this.id = set.getInt("id"); - this.name = set.getString("name"); + public ClothItem(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.name = set.getString("name"); String[] parts = set.getString("setid").split(","); this.setId = new int[parts.length]; - for (int i = 0; i < this.setId.length; i++) - { + for (int i = 0; i < this.setId.length; i++) { this.setId[i] = Integer.valueOf(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 b9b4be53..4ba103ba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import java.sql.ResultSet; import java.sql.SQLException; -public class ClubOffer -{ +public class ClubOffer { private final int id; @@ -29,8 +28,7 @@ public class ClubOffer private final boolean deal; - public ClubOffer(ResultSet set) throws SQLException - { + public ClubOffer(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.days = set.getInt("days"); @@ -41,43 +39,35 @@ public class ClubOffer this.deal = set.getString("deal").equals("1"); } - public int getId() - { + public int getId() { return this.id; } - public String getName() - { + public String getName() { return this.name; } - public int getDays() - { + public int getDays() { return this.days; } - public int getCredits() - { + public int getCredits() { return this.credits; } - public int getPoints() - { + public int getPoints() { return this.points; } - public int getPointsType() - { + public int getPointsType() { return this.pointsType; } - public boolean isVip() - { + public boolean isVip() { return this.vip; } - public boolean isDeal() - { + public boolean isDeal() { return this.deal; } } \ No newline at end of file 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 0a7879c7..3766c16a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/TargetOffer.java @@ -8,8 +8,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class TargetOffer -{ +public class TargetOffer { public static int ACTIVE_TARGET_OFFER_ID = 0; private final int id; @@ -26,8 +25,7 @@ public class TargetOffer private final String icon; private final String[] vars; - public TargetOffer(ResultSet set) throws SQLException - { + public TargetOffer(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.identifier = set.getString("offer_code"); this.priceInCredits = set.getInt("credits"); @@ -43,8 +41,7 @@ public class TargetOffer this.catalogItem = set.getInt("catalog_item"); } - public void serialize(ServerMessage message, HabboOfferPurchase purchase) - { + public void serialize(ServerMessage message, HabboOfferPurchase purchase) { message.appendInt(purchase.getState()); message.appendInt(this.id); message.appendString(this.identifier); @@ -60,74 +57,60 @@ public class TargetOffer message.appendString(this.icon); message.appendInt(0); message.appendInt(this.vars.length); - for (String variable : this.vars) - { + for (String variable : this.vars) { message.appendString(variable); } } - public int getId() - { + public int getId() { return this.id; } - public String getIdentifier() - { + public String getIdentifier() { return this.identifier; } - public int getPriceInCredits() - { + public int getPriceInCredits() { return this.priceInCredits; } - public int getPriceInActivityPoints() - { + public int getPriceInActivityPoints() { return this.priceInActivityPoints; } - public int getActivityPointsType() - { + public int getActivityPointsType() { return this.activityPointsType; } - public int getPurchaseLimit() - { + public int getPurchaseLimit() { return this.purchaseLimit; } - public int getExpirationTime() - { + public int getExpirationTime() { return this.expirationTime; } - public String getTitle() - { + public String getTitle() { return this.title; } - public String getDescription() - { + public String getDescription() { return this.description; } - public String getImageUrl() - { + public String getImageUrl() { return this.imageUrl; } - public String getIcon() - { + public String getIcon() { return this.icon; } - public String[] getVars() - { + public String[] getVars() { return this.vars; } - public int getCatalogItem() - { + 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 503aee37..643a3d1d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import java.sql.ResultSet; import java.sql.SQLException; -public class Voucher -{ +public class Voucher { public final int id; @@ -24,13 +23,12 @@ public class Voucher public final int catalogItemId; - public Voucher(ResultSet set) throws SQLException - { - this.id = set.getInt("id"); - this.code = set.getString("code"); - this.credits = set.getInt("credits"); - this.points = set.getInt("points"); - this.pointsType = set.getInt("points_type"); + public Voucher(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.code = set.getString("code"); + this.credits = set.getInt("credits"); + this.points = set.getInt("points"); + this.pointsType = set.getInt("points_type"); this.catalogItemId = set.getInt("catalog_item_id"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java index 8de0220e..de8cf5e8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java @@ -7,10 +7,8 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class BadgeDisplayLayout extends CatalogPage -{ - public BadgeDisplayLayout(ResultSet set) throws SQLException - { +public class BadgeDisplayLayout extends CatalogPage { + public BadgeDisplayLayout(ResultSet set) throws SQLException { super(set); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BotsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BotsLayout.java index c7d6e09b..57815b95 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BotsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BotsLayout.java @@ -7,16 +7,13 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class BotsLayout extends CatalogPage -{ - public BotsLayout(ResultSet set) throws SQLException - { +public class BotsLayout extends CatalogPage { + public BotsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("bots"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java index e393d37c..d3f64dab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java @@ -7,16 +7,13 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class BuildersClubAddonsLayout extends CatalogPage -{ - public BuildersClubAddonsLayout(ResultSet set) throws SQLException - { +public class BuildersClubAddonsLayout extends CatalogPage { + public BuildersClubAddonsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("builders_club_addons"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubFrontPageLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubFrontPageLayout.java index e82d8ea9..d53bbe94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubFrontPageLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubFrontPageLayout.java @@ -7,16 +7,13 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class BuildersClubFrontPageLayout extends CatalogPage -{ - public BuildersClubFrontPageLayout(ResultSet set) throws SQLException - { +public class BuildersClubFrontPageLayout extends CatalogPage { + public BuildersClubFrontPageLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("builders_club_frontpage"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java index 2925a055..cdedbf07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java @@ -7,16 +7,13 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class BuildersClubLoyaltyLayout extends CatalogPage -{ - public BuildersClubLoyaltyLayout(ResultSet set) throws SQLException - { +public class BuildersClubLoyaltyLayout extends CatalogPage { + public BuildersClubLoyaltyLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("builders_club_loyalty"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java index 02c39bee..d219baf4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java @@ -6,15 +6,12 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class CatalogRootLayout extends CatalogPage -{ - public CatalogRootLayout() - { +public class CatalogRootLayout extends CatalogPage { + public CatalogRootLayout() { super(); } - public CatalogRootLayout(ResultSet set) throws SQLException - { + public CatalogRootLayout(ResultSet set) throws SQLException { super(null); this.id = -1; @@ -30,8 +27,7 @@ public class CatalogRootLayout extends CatalogPage } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubBuyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubBuyLayout.java index 6eb9e399..1f7d4743 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubBuyLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubBuyLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class ClubBuyLayout extends CatalogPage -{ - public ClubBuyLayout(ResultSet set) throws SQLException - { +public class ClubBuyLayout extends CatalogPage { + public ClubBuyLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("club_buy"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubGiftsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubGiftsLayout.java index 2c78f6a3..0f0e4cce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubGiftsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubGiftsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class ClubGiftsLayout extends CatalogPage -{ - public ClubGiftsLayout(ResultSet set) throws SQLException - { +public class ClubGiftsLayout extends CatalogPage { + public ClubGiftsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("club_gifts"); message.appendInt(1); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java index 9254c26f..1cfbe354 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java @@ -6,10 +6,8 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class ColorGroupingLayout extends CatalogPage -{ - public ColorGroupingLayout(ResultSet set) throws SQLException - { +public class ColorGroupingLayout extends CatalogPage { + public ColorGroupingLayout(ResultSet set) throws SQLException { super(set); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java index f2cc92be..2846ce2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java @@ -8,14 +8,12 @@ import java.sql.SQLException; public class Default_3x3Layout extends CatalogPage { - public Default_3x3Layout(ResultSet set) throws SQLException - { + public Default_3x3Layout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("default_3x3"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontPageFeaturedLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontPageFeaturedLayout.java index 114fa9c2..e2380beb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontPageFeaturedLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontPageFeaturedLayout.java @@ -8,29 +8,24 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class FrontPageFeaturedLayout extends CatalogPage -{ - public FrontPageFeaturedLayout(ResultSet set) throws SQLException - { +public class FrontPageFeaturedLayout extends CatalogPage { + public FrontPageFeaturedLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("frontpage_featured"); String[] teaserImages = super.getTeaserImage().split(";"); String[] specialImages = super.getSpecialImage().split(";"); message.appendInt(1 + teaserImages.length + specialImages.length); message.appendString(super.getHeaderImage()); - for (String s : teaserImages) - { + for (String s : teaserImages) { message.appendString(s); } - for (String s : specialImages) - { + for (String s : specialImages) { message.appendString(s); } message.appendInt(3); @@ -39,13 +34,11 @@ public class FrontPageFeaturedLayout extends CatalogPage message.appendString(super.getTextTeaser()); } - public void serializeExtra(ServerMessage message) - { + public void serializeExtra(ServerMessage message) { message.appendInt(Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().size()); - for (CatalogFeaturedPage page : Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().valueCollection()) - { + for (CatalogFeaturedPage page : Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().valueCollection()) { page.serialize(message); } message.appendInt(1); //Position diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontpageLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontpageLayout.java index bf999366..93d74094 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontpageLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/FrontpageLayout.java @@ -8,8 +8,7 @@ import java.sql.SQLException; public class FrontpageLayout extends CatalogPage { - public FrontpageLayout(ResultSet set) throws SQLException - { + public FrontpageLayout(ResultSet set) throws SQLException { super(set); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java index 3672cf25..40de36aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class GuildForumLayout extends CatalogPage -{ - public GuildForumLayout(ResultSet set) throws SQLException - { +public class GuildForumLayout extends CatalogPage { + public GuildForumLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("guild_forum"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java index f31eada9..a2adeb2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class GuildFrontpageLayout extends CatalogPage -{ - public GuildFrontpageLayout(ResultSet set) throws SQLException - { +public class GuildFrontpageLayout extends CatalogPage { + public GuildFrontpageLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("guild_frontpage"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java index a994db34..e6c3c85e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class GuildFurnitureLayout extends CatalogPage -{ - public GuildFurnitureLayout(ResultSet set) throws SQLException - { +public class GuildFurnitureLayout extends CatalogPage { + public GuildFurnitureLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("guild_custom_furni"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoDucketsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoDucketsLayout.java index e48bd9b0..55912494 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoDucketsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoDucketsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InfoDucketsLayout extends CatalogPage -{ - public InfoDucketsLayout(ResultSet set) throws SQLException - { +public class InfoDucketsLayout extends CatalogPage { + public InfoDucketsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("info_duckets"); message.appendInt(1); message.appendString(this.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoLoyaltyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoLoyaltyLayout.java index d310fb84..2c09de87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoLoyaltyLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoLoyaltyLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InfoLoyaltyLayout extends CatalogPage -{ - public InfoLoyaltyLayout(ResultSet set) throws SQLException - { +public class InfoLoyaltyLayout extends CatalogPage { + public InfoLoyaltyLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("info_loyalty"); message.appendInt(1); message.appendString(this.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoPetsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoPetsLayout.java index bea9a296..1e70f752 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoPetsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoPetsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InfoPetsLayout extends CatalogPage -{ - public InfoPetsLayout(ResultSet set) throws SQLException - { +public class InfoPetsLayout extends CatalogPage { + public InfoPetsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("info_pets"); message.appendInt(2); message.appendString(this.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoRentablesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoRentablesLayout.java index fa5170e0..ab7dc183 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoRentablesLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoRentablesLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InfoRentablesLayout extends CatalogPage -{ - public InfoRentablesLayout(ResultSet set) throws SQLException - { +public class InfoRentablesLayout extends CatalogPage { + public InfoRentablesLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { String[] data = this.getTextOne().split("\\|\\|"); message.appendString("info_rentables"); message.appendInt(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java index c8d04ca5..fbcd15fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class LoyaltyVipBuyLayout extends CatalogPage -{ - public LoyaltyVipBuyLayout(ResultSet set) throws SQLException - { +public class LoyaltyVipBuyLayout extends CatalogPage { + public LoyaltyVipBuyLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("loyalty_vip_buy"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceLayout.java index 57a3786d..a959dda8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class MarketplaceLayout extends CatalogPage -{ - public MarketplaceLayout(ResultSet set) throws SQLException - { +public class MarketplaceLayout extends CatalogPage { + public MarketplaceLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("marketplace"); message.appendInt(0); message.appendInt(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceOwnItems.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceOwnItems.java index aada7a1e..b38ea07b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceOwnItems.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/MarketplaceOwnItems.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class MarketplaceOwnItems extends CatalogPage -{ - public MarketplaceOwnItems(ResultSet set) throws SQLException - { +public class MarketplaceOwnItems extends CatalogPage { + public MarketplaceOwnItems(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("marketplace_own_items"); message.appendInt(0); message.appendInt(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java index 0944be35..5474a423 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class PetCustomizationLayout extends CatalogPage -{ - public PetCustomizationLayout(ResultSet set) throws SQLException - { +public class PetCustomizationLayout extends CatalogPage { + public PetCustomizationLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("petcustomization"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java index 1f0fd39b..7ebbf45a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class Pets2Layout extends CatalogPage -{ - public Pets2Layout(ResultSet set) throws SQLException - { +public class Pets2Layout extends CatalogPage { + public Pets2Layout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("pets2"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java index bdcd86f0..0c430519 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class Pets3Layout extends CatalogPage -{ - public Pets3Layout(ResultSet set) throws SQLException - { +public class Pets3Layout extends CatalogPage { + public Pets3Layout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("pets3"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java index cf35e04f..d708b013 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class PetsLayout extends CatalogPage -{ - public PetsLayout(ResultSet set) throws SQLException - { +public class PetsLayout extends CatalogPage { + public PetsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("pets"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java index eb5c2c0f..b8cfe136 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class ProductPage1Layout extends CatalogPage -{ - public ProductPage1Layout(ResultSet set) throws SQLException - { +public class ProductPage1Layout extends CatalogPage { + public ProductPage1Layout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("productpage1"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java index 48a13e80..11485a12 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java @@ -6,10 +6,8 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class RecentPurchasesLayout extends CatalogPage -{ - public RecentPurchasesLayout(ResultSet set) throws SQLException - { +public class RecentPurchasesLayout extends CatalogPage { + public RecentPurchasesLayout(ResultSet set) throws SQLException { super(set); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java index 8da70fb4..9d923b53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class RecyclerInfoLayout extends CatalogPage -{ - public RecyclerInfoLayout(ResultSet set) throws SQLException - { +public class RecyclerInfoLayout extends CatalogPage { + public RecyclerInfoLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("recycler_info"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerLayout.java index a863b34c..6022cd38 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class RecyclerLayout extends CatalogPage -{ - public RecyclerLayout(ResultSet set) throws SQLException - { +public class RecyclerLayout extends CatalogPage { + public RecyclerLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("recycler"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java index 67332037..fe5693b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class RecyclerPrizesLayout extends CatalogPage -{ - public RecyclerPrizesLayout(ResultSet set) throws SQLException - { +public class RecyclerPrizesLayout extends CatalogPage { + public RecyclerPrizesLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("recycler_prizes"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomAdsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomAdsLayout.java index 647a8947..e5a2cec7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomAdsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomAdsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class RoomAdsLayout extends CatalogPage -{ - public RoomAdsLayout(ResultSet set) throws SQLException - { +public class RoomAdsLayout extends CatalogPage { + public RoomAdsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("roomads"); message.appendInt(2); message.appendString(super.getHeaderImage()); 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 8ef4c321..e05ccb84 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 @@ -17,57 +17,46 @@ import gnu.trove.procedure.TObjectProcedure; import java.sql.*; import java.util.Map; -public class RoomBundleLayout extends SingleBundle -{ +public class RoomBundleLayout extends SingleBundle { public int roomId; public Room room; private int lastUpdate = 0; private boolean loaded = false; - public RoomBundleLayout(ResultSet set) throws SQLException - { + public RoomBundleLayout(ResultSet set) throws SQLException { super(set); this.roomId = set.getInt("room_id"); } @Override - public TIntObjectMap getCatalogItems() - { - if(Emulator.getIntUnixTimestamp() - this.lastUpdate < 120) - { + public TIntObjectMap getCatalogItems() { + if (Emulator.getIntUnixTimestamp() - this.lastUpdate < 120) { this.lastUpdate = Emulator.getIntUnixTimestamp(); return super.getCatalogItems(); } - if(this.room == null) - { - if (this.roomId > 0) - { + if (this.room == null) { + if (this.roomId > 0) { this.room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId); if (this.room != null) this.room.preventUnloading = true; - } - else - { + } else { Emulator.getLogging().logErrorLine("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); } } - if(this.room == null) - { + if (this.room == null) { return super.getCatalogItems(); } final CatalogItem[] item = {null}; - super.getCatalogItems().forEachValue(new TObjectProcedure() - { + super.getCatalogItems().forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogItem object) - { - if(object == null) + public boolean execute(CatalogItem object) { + if (object == null) return true; item[0] = object; @@ -75,47 +64,39 @@ public class RoomBundleLayout extends SingleBundle } }); - if (this.room.isPreLoaded()) - { + if (this.room.isPreLoaded()) { this.room.loadData(); this.room.preventUncaching = true; this.room.preventUnloading = true; } - if(item[0] != null) - { + if (item[0] != null) { item[0].getBundle().clear(); THashMap items = new THashMap<>(); - for(HabboItem i : this.room.getFloorItems()) - { - if(!items.contains(i.getBaseItem())) - { + for (HabboItem i : this.room.getFloorItems()) { + if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } items.put(i.getBaseItem(), items.get(i.getBaseItem()) + 1); } - for(HabboItem i : this.room.getWallItems()) - { - if(!items.contains(i.getBaseItem())) - { + for (HabboItem i : this.room.getWallItems()) { + if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } items.put(i.getBaseItem(), items.get(i.getBaseItem()) + 1); } - if (!item[0].getExtradata().isEmpty()) - { + if (!item[0].getExtradata().isEmpty()) { items.put(Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(item[0].getExtradata())), 1); } StringBuilder data = new StringBuilder(); - for(Map.Entry set : items.entrySet()) - { + for (Map.Entry set : items.entrySet()) { data.append(set.getKey().getId()).append(":").append(set.getValue()).append(";"); } @@ -126,73 +107,60 @@ public class RoomBundleLayout extends SingleBundle return super.getCatalogItems(); } - public void loadItems(Room room) - { - if(this.room != null) - { + public void loadItems(Room room) { + if (this.room != null) { this.room.preventUnloading = false; } this.room = room; this.room.preventUnloading = true; this.getCatalogItems(); - this.loaded = true; + this.loaded = true; } - public void buyRoom(Habbo habbo) - { + public void buyRoom(Habbo habbo) { this.buyRoom(habbo, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername()); } - public void buyRoom(Habbo habbo, int userId, String userName) - { - if (!this.loaded) - { + public void buyRoom(Habbo habbo, int userId, String userName) { + if (!this.loaded) { this.loadItems(Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId)); } - if (habbo != null) - { + if (habbo != null) { int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo).size(); int max = habbo.getHabboStats().hasActiveClub() ? Emulator.getConfig().getInt("hotel.max.rooms.vip") : Emulator.getConfig().getInt("hotel.max.rooms.user"); - if (count >= max) - { + if (count >= max) { habbo.getClient().sendResponse(new CanCreateRoomComposer(count, max)); return; } } - if(this.room == null) + if (this.room == null) return; this.room.save(); - for(HabboItem item : this.room.getFloorItems()) - { + for (HabboItem item : this.room.getFloorItems()) { item.run(); } - for(HabboItem item : this.room.getWallItems()) - { + for (HabboItem item : this.room.getWallItems()) { item.run(); } this.getCatalogItems(); int roomId = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model) (SELECT ?, ?, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model FROM rooms WHERE id = ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model) (SELECT ?, ?, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model FROM rooms WHERE id = ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userId); statement.setString(2, userName); statement.setInt(3, this.room.getId()); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { roomId = set.getInt(1); } } @@ -201,8 +169,7 @@ public class RoomBundleLayout extends SingleBundle if (roomId == 0) return; - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, room_id, item_id, wall_pos, x, y, z, rot, extra_data, wired_data, limited_data, guild_id) (SELECT ?, ?, item_id, wall_pos, x, y, z, rot, extra_data, wired_data, ?, ? FROM items WHERE room_id = ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, room_id, item_id, wall_pos, x, y, z, rot, extra_data, wired_data, limited_data, guild_id) (SELECT ?, ?, item_id, wall_pos, x, y, z, rot, extra_data, wired_data, ?, ? FROM items WHERE room_id = ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userId); statement.setInt(2, roomId); statement.setString(3, "0:0"); @@ -211,31 +178,23 @@ public class RoomBundleLayout extends SingleBundle statement.execute(); } - if (this.room.hasCustomLayout()) - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) (SELECT ?, ?, door_x, door_y, door_dir, heightmap FROM room_models_custom WHERE id = ? LIMIT 1)", Statement.RETURN_GENERATED_KEYS)) - { + if (this.room.hasCustomLayout()) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) (SELECT ?, ?, door_x, door_y, door_dir, heightmap FROM room_models_custom WHERE id = ? LIMIT 1)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, roomId); statement.setString(2, "custom_" + roomId); statement.setInt(3, this.room.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { - synchronized (this.room.getCurrentBots()) - { + if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + synchronized (this.room.getCurrentBots()) { statement.setInt(1, userId); statement.setInt(2, roomId); - for (Bot bot : this.room.getCurrentBots().valueCollection()) - { + for (Bot bot : this.room.getCurrentBots().valueCollection()) { statement.setString(3, bot.getName()); statement.setString(4, bot.getMotto()); statement.setString(5, bot.getFigure()); @@ -244,8 +203,7 @@ public class RoomBundleLayout extends SingleBundle statement.setInt(8, bot.getRoomUnit().getY()); statement.setDouble(9, bot.getRoomUnit().getZ()); StringBuilder text = new StringBuilder(); - for (String s : bot.getChatLines()) - { + for (String s : bot.getChatLines()) { text.append(s).append("\r"); } statement.setString(10, text.toString()); @@ -260,9 +218,7 @@ public class RoomBundleLayout extends SingleBundle statement.executeBatch(); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -279,8 +235,7 @@ public class RoomBundleLayout extends SingleBundle keys.put("OWNER", r.getOwnerName()); keys.put("image", "${image.library.url}/notifications/room_bundle_" + this.getId() + ".png"); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.PURCHASING_ROOM.key, keys)); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SingleBundle.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SingleBundle.java index 77baa8ff..db6bddd6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SingleBundle.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SingleBundle.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class SingleBundle extends CatalogPage -{ - public SingleBundle(ResultSet set) throws SQLException - { +public class SingleBundle extends CatalogPage { + public SingleBundle(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("single_bundle"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SoldLTDItemsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SoldLTDItemsLayout.java index 28fa8a90..4a68b0a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SoldLTDItemsLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SoldLTDItemsLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class SoldLTDItemsLayout extends CatalogPage -{ - public SoldLTDItemsLayout(ResultSet set) throws SQLException - { +public class SoldLTDItemsLayout extends CatalogPage { + public SoldLTDItemsLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("sold_ltd_items"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java index 9aac02ca..752673d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java @@ -8,14 +8,12 @@ import java.sql.SQLException; public class SpacesLayout extends CatalogPage { - public SpacesLayout(ResultSet set) throws SQLException - { + public SpacesLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("spaces_new"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TraxLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TraxLayout.java index 56dfd6d4..f14d9504 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TraxLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TraxLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class TraxLayout extends CatalogPage -{ - public TraxLayout(ResultSet set) throws SQLException - { +public class TraxLayout extends CatalogPage { + public TraxLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("soundmachine"); message.appendInt(2); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java index 01018020..48234910 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java @@ -8,14 +8,12 @@ import java.sql.SQLException; public class TrophiesLayout extends CatalogPage { - public TrophiesLayout(ResultSet set) throws SQLException - { + public TrophiesLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("trophies"); message.appendInt(3); message.appendString(super.getHeaderImage()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java index 6ab0c3e4..ce963413 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java @@ -6,16 +6,13 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class VipBuyLayout extends CatalogPage -{ - public VipBuyLayout(ResultSet set) throws SQLException - { +public class VipBuyLayout extends CatalogPage { + public VipBuyLayout(ResultSet set) throws SQLException { super(set); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString("vip_buy"); message.appendInt(3); message.appendString(super.getHeaderImage()); 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 7660b824..1a7109dc 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 @@ -25,8 +25,7 @@ import java.util.ArrayList; import java.util.List; -public class MarketPlace -{ +public class MarketPlace { //Configuration. Loaded from database & updated accordingly. public static boolean MARKETPLACE_ENABLED = true; @@ -34,80 +33,60 @@ public class MarketPlace public static int MARKETPLACE_CURRENCY = 0; - public static THashSet getOwnOffers(Habbo habbo) - { + public static THashSet getOwnOffers(Habbo habbo) { THashSet offers = new THashSet<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_base.type AS type, items.item_id AS base_item_id, items.limited_data AS ltd_data, marketplace_items.* 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 marketplace_items.user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_base.type AS type, items.item_id AS base_item_id, items.limited_data AS ltd_data, marketplace_items.* 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 marketplace_items.user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { offers.add(new MarketPlaceOffer(set, true)); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - return offers; + return offers; } - public static void takeBackItem(Habbo habbo, int offerId) - { + public static void takeBackItem(Habbo habbo, int offerId) { MarketPlaceOffer offer = habbo.getInventory().getOffer(offerId); - if (!Emulator.getPluginManager().fireEvent(new MarketPlaceItemCancelledEvent(offer)).isCancelled()) - { + if (!Emulator.getPluginManager().fireEvent(new MarketPlaceItemCancelledEvent(offer)).isCancelled()) { takeBackItem(habbo, offer); } } - private static void takeBackItem(Habbo habbo, MarketPlaceOffer offer) - { - if(offer != null && habbo.getInventory().getMarketplaceItems().contains(offer)) - { + private static void takeBackItem(Habbo habbo, MarketPlaceOffer offer) { + if (offer != null && habbo.getInventory().getMarketplaceItems().contains(offer)) { RequestOffersEvent.cachedResults.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?")) { ownerCheck.setInt(1, offer.getOfferId()); - try (ResultSet ownerSet = ownerCheck.executeQuery()) - { + try (ResultSet ownerSet = ownerCheck.executeQuery()) { ownerSet.last(); - if (ownerSet.getRow() == 0) - { + if (ownerSet.getRow() == 0) { return; } - try (PreparedStatement statement = connection.prepareStatement("DELETE FROM marketplace_items WHERE id = ? AND state != 2")) - { + try (PreparedStatement statement = connection.prepareStatement("DELETE FROM marketplace_items WHERE id = ? AND state != 2")) { statement.setInt(1, offer.getOfferId()); int count = statement.executeUpdate(); - if (count != 0) - { + if (count != 0) { habbo.getInventory().removeMarketplaceOffer(offer); - try (PreparedStatement updateItems = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) - { + try (PreparedStatement updateItems = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) { updateItems.setInt(1, habbo.getHabboInfo().getId()); updateItems.setInt(2, offer.getSoldItemId()); updateItems.execute(); - try (PreparedStatement selectItem = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) - { + try (PreparedStatement selectItem = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { selectItem.setInt(1, offer.getSoldItemId()); - try (ResultSet set = selectItem.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = selectItem.executeQuery()) { + while (set.next()) { HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); habbo.getInventory().getItemsComponent().addItem(item); habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, true)); @@ -121,9 +100,7 @@ public class MarketPlace } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, false)); } @@ -134,23 +111,19 @@ public class MarketPlace public static List getOffers(int minPrice, int maxPrice, String search, int sort) { List offers = new ArrayList<>(10); String query = "SELECT B.* FROM marketplace_items a INNER JOIN (SELECT b.item_id AS base_item_id, b.limited_data AS ltd_data, marketplace_items.*, AVG(price) as avg, MIN(marketplace_items.price) as minPrice, MAX(marketplace_items.price) as maxPrice, COUNT(*) as number, (SELECT COUNT(*) FROM marketplace_items c INNER JOIN items as items_b ON c.item_id = items_b.id WHERE state = 2 AND items_b.item_id = base_item_id AND DATE(from_unixtime(sold_timestamp)) = CURDATE()) as sold_count_today FROM marketplace_items INNER JOIN items b ON marketplace_items.item_id = b.id INNER JOIN items_base bi ON b.item_id = bi.id WHERE price = (SELECT MIN(e.price) FROM marketplace_items e, items d WHERE e.item_id = d.id AND d.item_id = b.item_id AND e.state = 1 AND e.timestamp > ? GROUP BY d.item_id) AND state = 1 AND timestamp > ?"; - if (minPrice > 0) - { + if (minPrice > 0) { query += " AND CEIL(price + (price / 100)) >= " + minPrice; } - if(maxPrice > 0 && maxPrice > minPrice) - { + if (maxPrice > 0 && maxPrice > minPrice) { query += " AND CEIL(price + (price / 100)) <= " + maxPrice; } - if(search.length() > 0) - { + if (search.length() > 0) { query += " AND bi.public_name LIKE ?"; } query += " GROUP BY base_item_id, ltd_data"; - switch (sort) - { + switch (sort) { case 6: query += " ORDER BY number ASC"; break; @@ -178,23 +151,18 @@ public class MarketPlace query += " LIMIT 100"; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { statement.setInt(1, Emulator.getIntUnixTimestamp() - 172800); statement.setInt(2, Emulator.getIntUnixTimestamp() - 172800); - if(search.length() > 0) - statement.setString(3, "%"+search+"%"); + if (search.length() > 0) + statement.setString(3, "%" + search + "%"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { offers.add(new MarketPlaceOffer(set, false)); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -202,24 +170,20 @@ public class MarketPlace } - public static void serializeItemInfo(int itemId, ServerMessage message) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(timestamp))")) - { + public static void serializeItemInfo(int itemId, ServerMessage message) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(timestamp))")) { statement.setInt(1, itemId); message.appendInt(avarageLastXDays(itemId, 7)); message.appendInt(itemsOnSale(itemId)); message.appendInt(30); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { set.last(); message.appendInt(set.getRow()); set.beforeFirst(); - while (set.next()) - { + while (set.next()) { message.appendInt(-set.getInt("day")); message.appendInt(MarketPlace.calculateCommision(set.getInt("price"))); message.appendInt(set.getInt("sold")); @@ -228,29 +192,22 @@ public class MarketPlace message.appendInt(1); message.appendInt(itemId); - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static int itemsOnSale(int baseItemId) - { + public static int itemsOnSale(int baseItemId) { int number = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg 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 state = 1 AND timestamp >= ? AND items_base.sprite_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg 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 state = 1 AND timestamp >= ? AND items_base.sprite_id = ?")) { statement.setInt(1, Emulator.getIntUnixTimestamp() - 172800); statement.setInt(2, baseItemId); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { set.first(); number = set.getInt("number"); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -258,22 +215,17 @@ public class MarketPlace } - private static int avarageLastXDays(int baseItemId, int days) - { + private static int avarageLastXDays(int baseItemId, int days) { int avg = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg 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 state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg 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 state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?")) { statement.setInt(1, days); statement.setInt(2, baseItemId); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { set.first(); avg = set.getInt("avg"); } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -281,40 +233,26 @@ public class MarketPlace } - public static void buyItem(int offerId, GameClient client) - { + public static void buyItem(int offerId, GameClient client) { RequestOffersEvent.cachedResults.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM marketplace_items WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM marketplace_items WHERE id = ? LIMIT 1")) { statement.setInt(1, offerId); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { itemStatement.setInt(1, set.getInt("item_id")); - try (ResultSet itemSet = itemStatement.executeQuery()) - { + try (ResultSet itemSet = itemStatement.executeQuery()) { itemSet.first(); - if (itemSet.getRow() > 0) - { + if (itemSet.getRow() > 0) { int price = MarketPlace.calculateCommision(set.getInt("price")); - if (set.getInt("state") != 1) - { + if (set.getInt("state") != 1) { sendErrorMessage(client, set.getInt("item_id"), offerId); - } - else if ((MARKETPLACE_CURRENCY == 0 && price > client.getHabbo().getHabboInfo().getCredits()) || (MARKETPLACE_CURRENCY > 0 && price > client.getHabbo().getHabboInfo().getCurrencyAmount(MARKETPLACE_CURRENCY))) - { + } else if ((MARKETPLACE_CURRENCY == 0 && price > client.getHabbo().getHabboInfo().getCredits()) || (MARKETPLACE_CURRENCY > 0 && price > client.getHabbo().getHabboInfo().getCurrencyAmount(MARKETPLACE_CURRENCY))) { client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.NOT_ENOUGH_CREDITS, 0, offerId, price)); - } - else - { - try (PreparedStatement updateOffer = connection.prepareStatement("UPDATE marketplace_items SET state = 2, sold_timestamp = ? WHERE id = ?")) - { + } else { + try (PreparedStatement updateOffer = connection.prepareStatement("UPDATE marketplace_items SET state = 2, sold_timestamp = ? WHERE id = ?")) { updateOffer.setInt(1, Emulator.getIntUnixTimestamp()); updateOffer.setInt(2, offerId); updateOffer.execute(); @@ -323,8 +261,7 @@ public class MarketPlace HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet); MarketPlaceItemSoldEvent event = new MarketPlaceItemSoldEvent(habbo, client.getHabbo(), item, set.getInt("price")); - if (Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; } event.price = calculateCommision(event.price); @@ -335,12 +272,9 @@ public class MarketPlace client.getHabbo().getInventory().getItemsComponent().addItem(item); - if (MARKETPLACE_CURRENCY == 0) - { + if (MARKETPLACE_CURRENCY == 0) { client.getHabbo().getHabboInfo().addCredits(-event.price); - } - else - { + } else { client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price); } @@ -349,8 +283,7 @@ public class MarketPlace client.sendResponse(new InventoryRefreshComposer()); client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.REFRESH, 0, offerId, price)); - if (habbo != null) - { + if (habbo != null) { habbo.getInventory().getOffer(offerId).setState(MarketPlaceState.SOLD); } } @@ -360,16 +293,13 @@ public class MarketPlace } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static void sendErrorMessage(GameClient client, int baseItemId, int offerId) - { + 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" + @@ -379,39 +309,32 @@ public class MarketPlace "FROM items_base\n" + "WHERE items_base.id = ? LIMIT 1)\n" + "ORDER BY price ASC\n" + - "LIMIT 1")) - { + "LIMIT 1")) { statement.setInt(1, baseItemId); - try (ResultSet countSet = statement.executeQuery()) - { + try (ResultSet countSet = statement.executeQuery()) { countSet.last(); if (countSet.getRow() == 0) client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.SOLD_OUT, 0, offerId, 0)); - else - { + else { countSet.first(); client.sendResponse(new MarketplaceBuyErrorComposer(MarketplaceBuyErrorComposer.UPDATES, countSet.getInt("count"), countSet.getInt("id"), MarketPlace.calculateCommision(countSet.getInt("price")))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static boolean sellItem(GameClient client, HabboItem item, int price) - { - if(item == null || client == null) + public static boolean sellItem(GameClient client, HabboItem item, int price) { + if (item == null || client == null) return false; if (!item.getBaseItem().allowMarketplace() || price < 0) return false; MarketPlaceItemOfferedEvent event = new MarketPlaceItemOfferedEvent(client.getHabbo(), item, price); - if (Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return false; } @@ -433,17 +356,14 @@ public class MarketPlace } - public static void getCredits(GameClient client) - { + public static void getCredits(GameClient client) { int credits = 0; THashSet offers = new THashSet<>(); offers.addAll(client.getHabbo().getInventory().getMarketplaceItems()); - for(MarketPlaceOffer offer : offers) - { - if(offer.getState().equals(MarketPlaceState.SOLD)) - { + for (MarketPlaceOffer offer : offers) { + if (offer.getState().equals(MarketPlaceState.SOLD)) { client.getHabbo().getInventory().removeMarketplaceOffer(offer); credits += offer.getPrice(); removeUser(offer); @@ -454,34 +374,26 @@ public class MarketPlace offers.clear(); - if (MARKETPLACE_CURRENCY == 0) - { + if (MARKETPLACE_CURRENCY == 0) { client.getHabbo().getHabboInfo().addCredits(credits); - } - else - { + } else { client.getHabbo().givePoints(MARKETPLACE_CURRENCY, credits); } client.sendResponse(new UserCreditsComposer(client.getHabbo())); } - private static void removeUser(MarketPlaceOffer offer) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE marketplace_items SET user_id = ? WHERE id = ?")) - { + private static void removeUser(MarketPlaceOffer offer) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE marketplace_items SET user_id = ? WHERE id = ?")) { statement.setInt(1, -1); statement.setInt(2, offer.getOfferId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static int calculateCommision(int price) - { - return price + (int)Math.ceil(price / 100.0); + public static int calculateCommision(int price) { + return price + (int) Math.ceil(price / 100.0); } } 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 62985faa..f8b68e5a 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 @@ -8,8 +8,9 @@ import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.*; -public class MarketPlaceOffer implements Runnable -{ +public class MarketPlaceOffer implements Runnable { + public int avarage; + public int count; private int offerId; private Item baseItem; private int itemId; @@ -21,11 +22,7 @@ public class MarketPlaceOffer implements Runnable private MarketPlaceState state = MarketPlaceState.OPEN; private boolean needsUpdate = false; - public int avarage; - public int count; - - public MarketPlaceOffer(ResultSet set, boolean privateOffer) throws SQLException - { + public MarketPlaceOffer(ResultSet set, boolean privateOffer) throws SQLException { this.offerId = set.getInt("id"); this.price = set.getInt("price"); this.timestamp = set.getInt("timestamp"); @@ -34,33 +31,28 @@ public class MarketPlaceOffer implements Runnable this.state = MarketPlaceState.getType(set.getInt("state")); this.itemId = set.getInt("item_id"); - if(!set.getString("ltd_data").split(":")[1].equals("0")) - { + 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]); } - if(!privateOffer) - { + if (!privateOffer) { this.avarage = set.getInt("avg"); this.count = set.getInt("number"); this.price = set.getInt("minPrice"); } } - public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) - { + public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) { this.price = price; this.baseItem = item.getBaseItem(); this.itemId = item.getId(); - if(item.getLimitedSells() > 0) - { + if (item.getLimitedSells() > 0) { this.limitedNumber = item.getLimitedSells(); this.limitedStack = item.getLimitedStack(); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO marketplace_items (item_id, user_id, price, timestamp, state) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO marketplace_items (item_id, user_id, price, timestamp, state) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, item.getId()); statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, this.price); @@ -68,119 +60,18 @@ public class MarketPlaceOffer implements Runnable statement.setString(5, this.state.getState() + ""); statement.execute(); - try (ResultSet id = statement.getGeneratedKeys()) - { - while (id.next()) - { + try (ResultSet id = statement.getGeneratedKeys()) { + while (id.next()) { this.offerId = id.getInt(1); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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() - { - if(this.needsUpdate) - { - this.needsUpdate = false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE marketplace_items SET state = ?, sold_timestamp = ? WHERE id = ?")) - { - statement.setInt(1, this.state.getState()); - statement.setInt(2, this.soldTimestamp); - statement.setInt(3, this.offerId); - statement.execute(); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - } - } - - public static void insert(MarketPlaceOffer offer, Habbo habbo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO marketplace_items VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + public static void insert(MarketPlaceOffer offer, Habbo habbo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO marketplace_items VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, offer.getItemId()); statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, offer.getPrice()); @@ -189,17 +80,88 @@ public class MarketPlaceOffer implements Runnable statement.setString(6, offer.getState().getState() + ""); statement.execute(); - try (ResultSet id = statement.getGeneratedKeys()) - { - while (id.next()) - { + try (ResultSet id = statement.getGeneratedKeys()) { + while (id.next()) { offer.setOfferId(id.getInt(1)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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() { + if (this.needsUpdate) { + this.needsUpdate = false; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE marketplace_items SET state = ?, sold_timestamp = ? WHERE id = ?")) { + statement.setInt(1, this.state.getState()); + statement.setInt(2, this.soldTimestamp); + statement.setInt(3, this.offerId); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + } } 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 536b6157..3cd7386d 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,7 +1,6 @@ package com.eu.habbo.habbohotel.catalog.marketplace; -public enum MarketPlaceState -{ +public enum MarketPlaceState { OPEN(1), @@ -13,27 +12,25 @@ public enum MarketPlaceState private final int state; - MarketPlaceState(int state) - { + MarketPlaceState(int state) { this.state = state; } - public int getState() - { - return this.state; - } - - - public static MarketPlaceState getType(int type) - { - switch(type) - { - case 1: return OPEN; - case 2: return SOLD; - case 3: return CLOSED; + public static MarketPlaceState getType(int type) { + switch (type) { + case 1: + return OPEN; + case 2: + return SOLD; + case 3: + return CLOSED; } return CLOSED; } + public int getState() { + return this.state; + } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java index 9472cf82..ab4ece28 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import java.util.concurrent.TimeUnit; -public class AboutCommand extends Command -{ - public AboutCommand() - { - super(null, new String[]{ "about", "info", "online", "server" }); +public class AboutCommand extends Command { + public AboutCommand() { + super(null, new String[]{"about", "info", "online", "server"}); } @Override @@ -20,15 +17,14 @@ public class AboutCommand extends Command Emulator.getRuntime().gc(); int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted(); - int day = (int)TimeUnit.SECONDS.toDays(seconds); - long hours = TimeUnit.SECONDS.toHours(seconds) - (day *24); - long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds)* 60); - long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + int day = (int) TimeUnit.SECONDS.toDays(seconds); + long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24); + long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60); String message = "" + Emulator.version + "\r\n"; - if (Emulator.getConfig().getBoolean("info.shown", true)) - { + if (Emulator.getConfig().getBoolean("info.shown", true)) { message += "Hotel Statistics\r" + "- Online Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "\r" + "- Active Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "\r" + @@ -42,7 +38,7 @@ public class AboutCommand extends Command "- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB" + "\r\n"; } - message += "\r" + + message += "\r" + "Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" + " - The General"; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AlertCommand.java index 5e4e52e3..17c2042f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AlertCommand.java @@ -4,25 +4,20 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; public class AlertCommand extends Command { - public AlertCommand() - { + public AlertCommand() { super("cmd_alert", Emulator.getTexts().getValue("commands.keys.cmd_alert").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_alert.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } - if(params.length < 3) - { + if (params.length < 3) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_alert.forgot_message"), RoomChatMessageBubbles.ALERT); return true; } @@ -30,8 +25,7 @@ public class AlertCommand extends Command { String targetUsername = params[1]; StringBuilder message = new StringBuilder(); - for(int i = 2; i < params.length; i++) - { + for (int i = 2; i < params.length; i++) { message.append(params[i]).append(" "); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java index 895a1d78..d6ab608c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java @@ -8,63 +8,50 @@ import com.eu.habbo.messages.outgoing.users.UserPerksComposer; import java.sql.Connection; import java.sql.PreparedStatement; -public class AllowTradingCommand extends Command -{ - public AllowTradingCommand() - { +public class AllowTradingCommand extends Command { + public AllowTradingCommand() { super("cmd_allow_trading", Emulator.getTexts().getValue("commands.keys.cmd_allow_trading").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.forgot_username")); return true; } - if (params.length == 2) - { + if (params.length == 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.forgot_trade").replace("%username%", params[1])); return true; } - if (params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) - { + if (params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) { String username = params[1]; boolean enabled = params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().setAllowTrade(enabled); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); habbo.getClient().sendResponse(new UserPerksComposer(habbo)); return true; - } - else - { + } else { boolean found; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) { statement.setString(1, enabled ? "1" : "0"); statement.setString(2, username); found = statement.executeUpdate() > 0; } - if (!found) - { + if (!found) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.user_not_found").replace("%username%", params[1])); return true; } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.incorrect_setting").replace("%enabled%", Emulator.getTexts().getValue("generic.yes")).replace("%disabled%", Emulator.getTexts().getValue("generic.no"))); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ArcturusCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ArcturusCommand.java index ab2829b8..d3a786cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ArcturusCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ArcturusCommand.java @@ -3,23 +3,20 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class ArcturusCommand extends Command -{ - public ArcturusCommand() - { - super(null, new String[]{ "arcturus", "emulator" }); +public class ArcturusCommand extends Command { + public ArcturusCommand() { + super(null, new String[]{"arcturus", "emulator"}); } + @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { gameClient.getHabbo().whisper("This hotel is powered by Arcturus Emulator! \r" + - "Cet hôtel est alimenté par Arcturus émulateur! \r" + - "Dit hotel draait op Arcturus Emulator! \r" + - "Este hotel está propulsado por Arcturus emulador! \r" + - "Hotellet drivs av Arcturus Emulator! \r" + - "Das Hotel gehört zu Arcturus Emulator betrieben!" + "Cet hôtel est alimenté par Arcturus émulateur! \r" + + "Dit hotel draait op Arcturus Emulator! \r" + + "Este hotel está propulsado por Arcturus emulador! \r" + + "Hotellet drivs av Arcturus Emulator! \r" + + "Das Hotel gehört zu Arcturus Emulator betrieben!" , RoomChatMessageBubbles.ALERT); } 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 b7d05c3f..7e5e1208 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -10,69 +10,50 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class BadgeCommand extends Command -{ - public BadgeCommand() - { +public class BadgeCommand extends Command { + public BadgeCommand() { super("cmd_badge", Emulator.getTexts().getValue("commands.keys.cmd_badge").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } - if(params.length == 2) - { + if (params.length == 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.forgot_badge").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(params.length == 3) - { + if (params.length == 3) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(habbo != null) - { - if (habbo.addBadge(params[2])) - { + if (habbo != null) { + if (habbo.addBadge(params[2])) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owned").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); } return true; - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { boolean found; - try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1")) { statement.setString(1, params[1]); statement.setString(2, params[2]); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { found = set.next(); } } - if(found) - { + 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, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)")) - { + } else { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)")) { statement.setString(1, params[1]); statement.setString(2, params[2]); statement.execute(); @@ -81,9 +62,7 @@ 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; } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 3556324b..b9946ffa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java @@ -9,47 +9,37 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; -public class BanCommand extends Command -{ - public BanCommand() - { +public class BanCommand extends Command { + public BanCommand() { super("cmd_ban", Emulator.getTexts().getValue("commands.keys.cmd_ban").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.forgot_user"), RoomChatMessageBubbles.ALERT); return true; } - if(params.length < 3) - { + if (params.length < 3) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.forgot_time"), RoomChatMessageBubbles.ALERT); return true; } int banTime; - try - { + try { banTime = Integer.valueOf(params[2]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.invalid_time"), RoomChatMessageBubbles.ALERT); return true; } - if(banTime < 600) - { + if (banTime < 600) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.time_to_short"), RoomChatMessageBubbles.ALERT); return true; } - if(params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) - { + if (params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.ban_self"), RoomChatMessageBubbles.ALERT); return true; } @@ -57,23 +47,18 @@ public class BanCommand extends Command Habbo t = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); HabboInfo target; - if (t != null) - { + if (t != null) { target = t.getHabboInfo(); - } - else - { + } else { target = HabboManager.getOfflineHabboInfo(params[1]); } - if (target == null) - { + if (target == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT); return true; } - if (target.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (target.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT); return true; } @@ -81,10 +66,8 @@ public class BanCommand extends Command StringBuilder reason = new StringBuilder(); - if(params.length > 3) - { - for(int i = 3; i < params.length; i++) - { + if (params.length > 3) { + for (int i = 3; i < params.length; i++) { reason.append(params[i]).append(" "); } } 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 908806d6..b2fc711c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BlockAlertCommand.java @@ -4,18 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class BlockAlertCommand extends Command -{ - public BlockAlertCommand() - { +public class BlockAlertCommand extends Command { + public BlockAlertCommand() { super("cmd_blockalert", Emulator.getTexts().getValue("commands.keys.cmd_blockalert").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + 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); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BotsCommand.java index af9042c8..10650e19 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BotsCommand.java @@ -3,27 +3,21 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; -public class BotsCommand extends Command -{ - public BotsCommand() - { +public class BotsCommand extends Command { + public BotsCommand() { super("cmd_bots", Emulator.getTexts().getValue("commands.keys.cmd_bots").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) return false; StringBuilder data = new StringBuilder(Emulator.getTexts().getValue("total") + ": " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values().length); - for(Object bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values()) - { - if(bot instanceof Bot) - { + for (Object bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values()) { + if (bot instanceof Bot) { data.append("\r"); data.append("").append(Emulator.getTexts().getValue("generic.bot.name")).append(": ").append(((Bot) bot).getName()).append(" ").append(Emulator.getTexts().getValue("generic.bot.id")).append(": ").append(((Bot) bot).getId()); } 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 005dc212..5d996740 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java @@ -5,19 +5,15 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; -public class CalendarCommand extends Command -{ - public CalendarCommand() - { +public class CalendarCommand extends Command { + public CalendarCommand() { super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) - { - gameClient.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int)Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400) , gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, true)); + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { + gameClient.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, true)); gameClient.sendResponse(new NuxAlertComposer("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 f01cf394..0fa9bbc9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChangeNameCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.users.UserDataComposer; -public class ChangeNameCommand extends Command -{ - public ChangeNameCommand() - { +public class ChangeNameCommand extends Command { + public ChangeNameCommand() { super("cmd_changename", Emulator.getTexts().getValue("commands.keys.cmd_changename").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { gameClient.getHabbo().getHabboStats().allowNameChange = !gameClient.getHabbo().getHabboStats().allowNameChange; gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo())); 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 289bb469..005911f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java @@ -5,47 +5,35 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.messages.outgoing.users.MeMenuSettingsComposer; -public class ChatTypeCommand extends Command -{ - public ChatTypeCommand() - { +public class ChatTypeCommand extends Command { + public ChatTypeCommand() { super("cmd_chatcolor", Emulator.getTexts().getValue("commands.keys.cmd_chatcolor").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { - if(params.length >= 2) - { + if (params.length >= 2) { int chatColor; - try - { + try { chatColor = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.numbers"), RoomChatMessageBubbles.ALERT); return true; } - if(RoomChatMessageBubbles.values().length < chatColor) - { + if (RoomChatMessageBubbles.values().length < chatColor) { chatColor = 0; } - if(chatColor < 0) - { + if (chatColor < 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.numbers"), RoomChatMessageBubbles.ALERT); return true; } - if(!gameClient.getHabbo().hasPermission("acc_anychatcolor")) - { - for(String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) - { - if(Integer.valueOf(s) == chatColor) - { + if (!gameClient.getHabbo().hasPermission("acc_anychatcolor")) { + for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { + if (Integer.valueOf(s) == chatColor) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.banned"), RoomChatMessageBubbles.ALERT); return true; } @@ -56,9 +44,7 @@ public class ChatTypeCommand extends Command gameClient.sendResponse(new MeMenuSettingsComposer(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 - { + } else { gameClient.getHabbo().getHabboStats().chatColor = RoomChatMessageBubbles.NORMAL; gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_chatcolor.reset"), RoomChatMessageBubbles.ALERT); 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 1194f7c6..6c71c7a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/Command.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/Command.java @@ -2,16 +2,14 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.habbohotel.gameclients.GameClient; -public abstract class Command -{ +public abstract class Command { public final String permission; public final String[] keys; - public Command(String permission, String[] keys) - { + public Command(String permission, String[] keys) { this.permission = permission; this.keys = keys; } 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 7a02ae72..1ba4be67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -16,21 +16,154 @@ import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.NoSuchElementException; -public class CommandHandler -{ +public class CommandHandler { 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); + } + }; - public CommandHandler() - { + public CommandHandler() { long millis = System.currentTimeMillis(); this.reloadCommands(); Emulator.getLogging().logStart("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void reloadCommands() - { + public static void addCommand(Command command) { + if (command == null) + return; + + commands.put(command.getClass().getName(), command); + } + + + public static void addCommand(Class command) { + try { + //command.getConstructor().setAccessible(true); + addCommand(command.newInstance()); + Emulator.getLogging().logDebugLine("Added command: " + command.getName()); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } + + + public static boolean handleCommand(GameClient gameClient, String commandLine) { + if (gameClient != null) { + if (commandLine.startsWith(":")) { + commandLine = commandLine.replaceFirst(":", ""); + + String[] parts = commandLine.split(" "); + + if (parts.length >= 1) { + for (Command command : commands.values()) { + for (String s : command.keys) { + if (s.toLowerCase().equals(parts[0].toLowerCase())) { + boolean succes = false; + if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission("acc_placefurni") || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().guildRightLevel(gameClient.getHabbo()) >= 2))) { + try { + Emulator.getPluginManager().fireEvent(new UserExecuteCommandEvent(gameClient.getHabbo(), command, parts)); + + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) + gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTypingComposer(gameClient.getHabbo().getRoomUnit(), false).compose()); + + UserCommandEvent event = new UserCommandEvent(gameClient.getHabbo(), parts, command.handle(gameClient, parts)); + Emulator.getPluginManager().fireEvent(event); + + succes = event.succes; + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + + if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) { + Emulator.getLogging().addLog(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes)); + } + } + + return succes; + } + } + } + } + } else { + String[] args = commandLine.split(" "); + + if (args.length <= 1) + return false; + + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + + if (room.getCurrentPets().isEmpty()) + return false; + + TIntObjectIterator petIterator = room.getCurrentPets().iterator(); + + for (int j = room.getCurrentPets().size(); j-- > 0; ) { + try { + petIterator.advance(); + } catch (NoSuchElementException e) { + break; + } + + Pet pet = petIterator.value(); + + if (pet != null) { + if (pet.getName().equalsIgnoreCase(args[0])) { + StringBuilder s = new StringBuilder(); + + for (int i = 1; i < args.length; i++) { + s.append(args[i]).append(" "); + } + + s = new StringBuilder(s.substring(0, s.length() - 1)); + + for (PetCommand command : pet.getPetData().getPetCommands()) { + if (command.key.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(); + } + break; + } + + if (command.level <= pet.getLevel()) + pet.handleCommand(command, gameClient.getHabbo(), args); + else + pet.say(pet.getPetData().randomVocal(PetVocalsType.UNKNOWN_COMMAND)); + + break; + } + } + } + } + } + } + } + } + return false; + } + + public static Command getCommand(String key) { + for (Command command : commands.values()) { + for (String k : command.keys) { + if (key.equalsIgnoreCase(k)) { + return command; + } + } + } + + return null; + } + + public void reloadCommands() { addCommand(new AboutCommand()); addCommand(new AlertCommand()); addCommand(new AllowTradingCommand()); @@ -147,166 +280,16 @@ public class CommandHandler addCommand(new TestCommand()); } - - public static void addCommand(Command command) - { - if(command == null) - return; - - commands.put(command.getClass().getName(), command); - } - - - public static void addCommand(Class command) - { - try - { - //command.getConstructor().setAccessible(true); - addCommand(command.newInstance()); - Emulator.getLogging().logDebugLine("Added command: " + command.getName()); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - } - - - public static boolean handleCommand(GameClient gameClient, String commandLine) - { - if(gameClient != null) - { - if (commandLine.startsWith(":")) - { - commandLine = commandLine.replaceFirst(":", ""); - - String[] parts = commandLine.split(" "); - - if (parts.length >= 1) - { - for (Command command : commands.values()) - { - for (String s : command.keys) - { - if (s.toLowerCase().equals(parts[0].toLowerCase())) - { - boolean succes = false; - if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission("acc_placefurni") || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().guildRightLevel(gameClient.getHabbo()) >= 2) )) - { - try - { - Emulator.getPluginManager().fireEvent(new UserExecuteCommandEvent(gameClient.getHabbo(), command, parts)); - - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTypingComposer(gameClient.getHabbo().getRoomUnit(), false).compose()); - - UserCommandEvent event = new UserCommandEvent(gameClient.getHabbo(), parts, command.handle(gameClient, parts)); - Emulator.getPluginManager().fireEvent(event); - - succes = event.succes; - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - - if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) - { - Emulator.getLogging().addLog(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes)); - } - } - - return succes; - } - } - } - } - } - else - { - String[] args = commandLine.split(" "); - - if (args.length <= 1) - return false; - - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - - if (room.getCurrentPets().isEmpty()) - return false; - - TIntObjectIterator petIterator = room.getCurrentPets().iterator(); - - for (int j = room.getCurrentPets().size(); j-- > 0; ) - { - try - { - petIterator.advance(); - } - catch (NoSuchElementException e) - { - break; - } - - Pet pet = petIterator.value(); - - if (pet != null) - { - if (pet.getName().equalsIgnoreCase(args[0])) - { - StringBuilder s = new StringBuilder(); - - for (int i = 1; i < args.length; i++) - { - s.append(args[i]).append(" "); - } - - s = new StringBuilder(s.substring(0, s.length() - 1)); - - for (PetCommand command : pet.getPetData().getPetCommands()) - { - if (command.key.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(); - } - break; - } - - if (command.level <= pet.getLevel()) - pet.handleCommand(command, gameClient.getHabbo(), args); - else - pet.say(pet.getPetData().randomVocal(PetVocalsType.UNKNOWN_COMMAND)); - - break; - } - } - } - } - } - } - } - } - return false; - } - - - public List getCommandsForRank(int rankId) - { + public List getCommandsForRank(int rankId) { List allowedCommands = new ArrayList<>(); - if (Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) - { + if (Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) { THashMap permissions = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId).getPermissions(); - for (Command command : commands.values()) - { + for (Command command : commands.values()) { 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).setting != PermissionSetting.DISALLOWED) { allowedCommands.add(command); } } @@ -317,35 +300,9 @@ public class CommandHandler return allowedCommands; } - public static Command getCommand(String key) - { - for (Command command : commands.values()) - { - for (String k : command.keys) - { - if (key.equalsIgnoreCase(k)) - { - return command; - } - } - } - - return null; - } - - - public void dispose() - { + public void dispose() { commands.clear(); Emulator.getLogging().logShutdownLine("Command Handler -> Disposed!"); } - - - 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); - } - }; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java index 159a93a8..026a1d53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java @@ -5,22 +5,18 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import java.util.List; -public class CommandsCommand extends Command -{ - public CommandsCommand() - { +public class CommandsCommand extends Command { + public CommandsCommand() { super("cmd_commands", Emulator.getTexts().getValue("commands.keys.cmd_commands").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { StringBuilder message = new StringBuilder("Your Commands"); List commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId()); message.append("(").append(commands.size()).append("):\r\n"); - for(Command c : commands) - { + for (Command c : commands) { message.append(Emulator.getTexts().getValue("commands.description." + c.permission, "commands.description." + c.permission)).append("\r"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ConnectCameraCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ConnectCameraCommand.java index 6ed6ddd8..34ba2b0b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ConnectCameraCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ConnectCameraCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class ConnectCameraCommand extends Command -{ - public ConnectCameraCommand() - { +public class ConnectCameraCommand extends Command { + public ConnectCameraCommand() { super("cmd_connect_camera", Emulator.getTexts().getValue("commands.keys.cmd_connect_camera").split(";")); } - @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { return false; } } \ No newline at end of file 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 df148edd..d14bdb17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ControlCommand.java @@ -5,38 +5,30 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class ControlCommand extends Command -{ - public ControlCommand() - { +public class ControlCommand extends Command { + public ControlCommand() { super("cmd_control", Emulator.getTexts().getValue("commands.keys.cmd_control").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (params.length == 2) { Habbo target = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - if(target == null) - { + if (target == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_control.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(target == gameClient.getHabbo()) - { + if (target == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_control.not_self"), RoomChatMessageBubbles.ALERT); return true; } - Habbo oldHabbo = (Habbo)gameClient.getHabbo().getRoomUnit().getCacheable().remove("control"); + Habbo oldHabbo = (Habbo) gameClient.getHabbo().getRoomUnit().getCacheable().remove("control"); - if(oldHabbo != null) - { + if (oldHabbo != null) { oldHabbo.getRoomUnit().getCacheable().remove("controller"); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", oldHabbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); } @@ -44,16 +36,13 @@ public class ControlCommand extends Command 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 - { + } else { Object habbo = gameClient.getHabbo().getRoomUnit().getCacheable().get("control"); - if(habbo != null) - { + if (habbo != null) { gameClient.getHabbo().getRoomUnit().getCacheable().remove("control"); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", ((Habbo)habbo).getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", ((Habbo) habbo).getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); } 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 5b5b8fde..405dbfde 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CoordsCommand.java @@ -1,26 +1,22 @@ - package com.eu.habbo.habbohotel.commands; +package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; public class CoordsCommand extends Command { - public CoordsCommand() - { + public CoordsCommand() { super("cmd_coords", Emulator.getTexts().getValue("commands.keys.cmd_coords").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) return false; - if (params.length == 1) - { + if (params.length == 1) { gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" + "x: " + gameClient.getHabbo().getRoomUnit().getX() + "\r" + "y: " + gameClient.getHabbo().getRoomUnit().getY() + "\r" + @@ -33,24 +29,19 @@ public class CoordsCommand extends Command { "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 - { + } else { RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(Short.valueOf(params[1]), Short.valueOf(params[2])); - if (tile != null) - { + 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" + - "Tile Relative Height: " + tile.relativeHeight() + "\r" + - "Tile Stack Height: " + tile.getStackHeight() + "\r" + - "Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r"); - } - else - { + "x: " + tile.x + "\r" + + "y: " + tile.y + "\r" + + "z: " + tile.z + "\r" + + "Tile State: " + tile.state.name() + "\r" + + "Tile Relative Height: " + tile.relativeHeight() + "\r" + + "Tile Stack Height: " + tile.getStackHeight() + "\r" + + "Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r"); + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.tile.not.exists")); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CreditsCommand.java index beb95c3d..4e6dc387 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CreditsCommand.java @@ -6,64 +6,49 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; -public class CreditsCommand extends Command -{ - public CreditsCommand() - { +public class CreditsCommand extends Command { + public CreditsCommand() { super("cmd_credits", Emulator.getTexts().getValue("commands.keys.cmd_credits").split(";")); } + @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 3) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 3) { HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]); - if (info != null) - { + if (info != null) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]); int credits; - try - { + try { credits = Integer.parseInt(params[2]); - } catch (NumberFormatException e) - { + } catch (NumberFormatException e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if (habbo != null) - { - if (credits != 0) - { - habbo.giveCredits(credits); - if (habbo.getHabboInfo().getCurrentRoom() != null) - habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT); - else - habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + "")); + if (habbo != null) { + if (credits != 0) { + habbo.giveCredits(credits); + if (habbo.getHabboInfo().getCurrentRoom() != null) + habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT); + else + habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + "")); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - } else - { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT); - } - } else - { + } else { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT); + } + } else { Emulator.getGameEnvironment().getHabboManager().giveCredits(info.getId(), credits); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.user_not_found").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/DiagonalCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/DiagonalCommand.java index 8610d0ca..002393be 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/DiagonalCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/DiagonalCommand.java @@ -4,28 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class DiagonalCommand extends Command -{ - public DiagonalCommand() - { +public class DiagonalCommand extends Command { + public DiagonalCommand() { super("cmd_diagonal", Emulator.getTexts().getValue("commands.keys.cmd_diagonal").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()); - if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()) - { + if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_diagonal.disabled"), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_diagonal.enabled"), RoomChatMessageBubbles.ALERT); } 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 78b208d7..867e7a95 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/DisconnectCommand.java @@ -5,38 +5,31 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class DisconnectCommand extends Command -{ - public DisconnectCommand() - { +public class DisconnectCommand extends Command { + public DisconnectCommand() { super("cmd_disconnect", Emulator.getTexts().getValue("commands.keys.cmd_disconnect").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } - if(params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) - { + if (params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.disconnect_self"), RoomChatMessageBubbles.ALERT); return true; } Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(target == null) - { + if (target == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.user_offline"), RoomChatMessageBubbles.ALERT); return true; } - if (target.getHabboInfo().getRank().getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (target.getHabboInfo().getRank().getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.higher_rank"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EjectAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EjectAllCommand.java index 3cf22758..8e5ab590 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EjectAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EjectAllCommand.java @@ -4,22 +4,17 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -public class EjectAllCommand extends Command -{ - public EjectAllCommand() - { +public class EjectAllCommand extends Command { + public EjectAllCommand() { super("cmd_ejectall", Emulator.getTexts().getValue("commands.keys.cmd_ejectall").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.guildRightLevel(gameClient.getHabbo()) == 3)) - { + if (room != null) { + if (room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.guildRightLevel(gameClient.getHabbo()) == 3)) { room.ejectAll(gameClient.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java index 4b76d518..2745aa0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java @@ -6,31 +6,22 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; -public class EmptyBotsInventoryCommand extends Command -{ - public EmptyBotsInventoryCommand() - { +public class EmptyBotsInventoryCommand extends Command { + public EmptyBotsInventoryCommand() { super("cmd_empty_bots", Emulator.getTexts().getValue("commands.keys.cmd_empty_bots").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1 || (params.length >= 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1 || (params.length >= 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes"))); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")), RoomChatMessageBubbles.ALERT); } } @@ -38,24 +29,19 @@ public class EmptyBotsInventoryCommand extends Command return true; } - if(params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) - { + if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { Habbo habbo = gameClient.getHabbo(); - if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) - { + if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) { habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]); } - if (habbo != null) - { + if (habbo != null) { TIntObjectHashMap bots = new TIntObjectHashMap<>(); bots.putAll(habbo.getInventory().getBotsComponent().getBots()); habbo.getInventory().getBotsComponent().getBots().clear(); - bots.forEachValue(new TObjectProcedure() - { + bots.forEachValue(new TObjectProcedure() { @Override - public boolean execute(Bot object) - { + public boolean execute(Bot object) { Emulator.getGameEnvironment().getBotManager().deleteBot(object); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java index 844a262a..ba7323a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java @@ -6,50 +6,38 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryItemsComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -public class EmptyInventoryCommand extends Command -{ - public EmptyInventoryCommand() - { +public class EmptyInventoryCommand extends Command { + public EmptyInventoryCommand() { super("cmd_empty", Emulator.getTexts().getValue("commands.keys.cmd_empty").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1 || (params.length == 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) - { - gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes"))); - } - else - { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")), RoomChatMessageBubbles.ALERT); - } - } + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1 || (params.length == 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { + gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes"))); + } else { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")), RoomChatMessageBubbles.ALERT); + } + } return true; } - if(params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) - { + if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { Habbo habbo = gameClient.getHabbo(); - if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) - { + if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) { habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]); } - if (habbo != null) - { + if (habbo != null) { TIntObjectMap items = new TIntObjectHashMap<>(); items.putAll(habbo.getInventory().getItemsComponent().getItems()); 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 1ecf90a9..6ab16663 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java @@ -6,31 +6,22 @@ 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.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; -public class EmptyPetsInventoryCommand extends Command -{ - public EmptyPetsInventoryCommand() - { +public class EmptyPetsInventoryCommand extends Command { + public EmptyPetsInventoryCommand() { super("cmd_empty_pets", Emulator.getTexts().getValue("commands.keys.cmd_empty_pets").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1 || (params.length >= 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1 || (params.length >= 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes"))); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")), RoomChatMessageBubbles.ALERT); } } @@ -38,24 +29,19 @@ public class EmptyPetsInventoryCommand extends Command return true; } - if(params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) - { + if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { Habbo habbo = gameClient.getHabbo(); - if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) - { + if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) { habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]); } - if (habbo != null) - { + if (habbo != null) { TIntObjectHashMap pets = new TIntObjectHashMap<>(); pets.putAll(habbo.getInventory().getPetsComponent().getPets()); habbo.getInventory().getPetsComponent().getPets().clear(); - pets.forEachValue(new TObjectProcedure() - { + pets.forEachValue(new TObjectProcedure() { @Override - public boolean execute(Pet object) - { + public boolean execute(Pet object) { Emulator.getGameEnvironment().getPetManager().deletePet(object); return true; } 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 837bd3db..3b459feb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java @@ -5,45 +5,31 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class EnableCommand extends Command -{ - public EnableCommand() - { +public class EnableCommand extends Command { + public EnableCommand() { super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length >= 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length >= 2) { int effectId; - try - { + try { effectId = Integer.parseInt(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { return false; } Habbo target = gameClient.getHabbo(); - if (params.length == 3) - { + if (params.length == 3) { target = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[2]); } - if (target != null) - { - if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission("acc_enable_others")) - { - try - { - if (target.getHabboInfo().getCurrentRoom() != null) - { - if (target.getHabboInfo().getRiding() == null) - { - if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getRank().getId())) - { + if (target != null) { + if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission("acc_enable_others")) { + try { + if (target.getHabboInfo().getCurrentRoom() != null) { + if (target.getHabboInfo().getRiding() == null) { + if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getRank().getId())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT); return true; } @@ -51,9 +37,7 @@ public class EnableCommand extends Command target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1); } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(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 bc5b9747..21d57835 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java @@ -9,24 +9,18 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class EventCommand extends Command -{ - public EventCommand() - { +public class EventCommand extends Command { + public EventCommand() { super("cmd_event", Emulator.getTexts().getValue("commands.keys.cmd_event").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if (params.length >= 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (params.length >= 2) { StringBuilder message = new StringBuilder(); - for (int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { message.append(params[i]); message.append(" "); } @@ -41,10 +35,9 @@ public class EventCommand extends Command ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if(habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().blockStaffAlerts) 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 ed6dbf61..cbcdf4ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FacelessCommand.java @@ -6,27 +6,20 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; -public class FacelessCommand extends Command -{ - public FacelessCommand() - { +public class FacelessCommand extends Command { + public FacelessCommand() { super("cmd_faceless", Emulator.getTexts().getValue("commands.keys.cmd_faceless").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - try - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + try { String[] figureParts = gameClient.getHabbo().getHabboInfo().getLook().split("\\."); - for (String part : figureParts) - { - if (part.startsWith("hd")) - { + for (String part : figureParts) { + if (part.startsWith("hd")) { String[] headParts = part.split("-"); if (!headParts[1].equals("99999")) @@ -43,9 +36,7 @@ public class FacelessCommand extends Command } } - } - catch (Exception e) - { + } catch (Exception e) { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FastwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FastwalkCommand.java index 49c9a4ae..51c4c399 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FastwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FastwalkCommand.java @@ -4,32 +4,27 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.users.Habbo; -public class FastwalkCommand extends Command -{ - public FastwalkCommand() - { +public class FastwalkCommand extends Command { + public FastwalkCommand() { super("cmd_fastwalk", Emulator.getTexts().getValue("commands.keys.cmd_fastwalk").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { if (gameClient.getHabbo().getHabboInfo().getRiding() != null) //TODO Make this an event plugin which fires that can be cancelled - return true; + return true; } Habbo habbo = gameClient.getHabbo(); - if(params.length >= 2) - { + if (params.length >= 2) { String username = params[1]; habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(username); - if(habbo == null) + if (habbo == null) return false; } habbo.getRoomUnit().setFastWalk(!habbo.getRoomUnit().isFastWalk()); 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 f146f296..148fa4c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java @@ -9,18 +9,14 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class FilterWordCommand extends Command -{ - public FilterWordCommand() - { +public class FilterWordCommand extends Command { + public FilterWordCommand() { super("cmd_filterword", Emulator.getTexts().getValue("commands.keys.cmd_filterword").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.missing_word")); return true; } @@ -28,21 +24,17 @@ public class FilterWordCommand extends Command String word = params[1]; String replacement = WordFilter.DEFAULT_REPLACEMENT; - if (params.length == 3) - { + if (params.length == 3) { replacement = params[2]; } WordFilterWord wordFilterWord = new WordFilterWord(word, replacement); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wordfilter (`key`, `replacement`) VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wordfilter (`key`, `replacement`) VALUES (?, ?)")) { statement.setString(1, word); statement.setString(2, replacement); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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/FreezeBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeBotsCommand.java index 6c608cb2..37b57aaa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FreezeBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeBotsCommand.java @@ -5,25 +5,18 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class FreezeBotsCommand extends Command -{ - public FreezeBotsCommand() - { +public class FreezeBotsCommand extends Command { + public FreezeBotsCommand() { super("cmd_freeze_bots", Emulator.getTexts().getValue("commands.keys.cmd_freeze_bots").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || gameClient.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || gameClient.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().setAllowBotsWalk(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk()); gameClient.getHabbo().whisper(gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk() ? Emulator.getTexts().getValue("commands.succes.cmd_freeze_bots.unfrozen") : Emulator.getTexts().getValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.cannot_do_that"), RoomChatMessageBubbles.ALERT); } 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 a989d207..b640a806 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java @@ -5,45 +5,33 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class FreezeCommand extends Command -{ - public FreezeCommand() - { +public class FreezeCommand extends Command { + public FreezeCommand() { super("cmd_freeze", Emulator.getTexts().getValue("commands.keys.cmd_freeze").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_freeze.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else - { - if(habbo.getRoomUnit().canWalk()) - { + } else { + if (habbo.getRoomUnit().canWalk()) { 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 - { + } 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; } } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_freeze.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT); return true; } 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 797926ff..e0a3390c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java @@ -13,59 +13,47 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import gnu.trove.map.hash.THashMap; -public class GiftCommand extends Command -{ - public GiftCommand() - { +public class GiftCommand extends Command { + public GiftCommand() { super("cmd_gift", Emulator.getTexts().getValue("commands.keys.cmd_gift").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length >= 3) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length >= 3) { String username = params[1]; int itemId; - try - { + try { itemId = Integer.valueOf(params[2]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } - if(itemId <= 0) - { + if (itemId <= 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(itemId); - if(baseItem == null) - { + if (baseItem == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT); return true; } HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username); - if(habboInfo == null) - { + if (habboInfo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.user_not_found").replace("%username%", username), RoomChatMessageBubbles.ALERT); return true; } StringBuilder message = new StringBuilder(); - if(params.length > 3) - { - for (int i = 3; i < params.length; i++) - { + if (params.length > 3) { + for (int i = 3; i < params.length; i++) { message.append(params[i]).append(" "); } } @@ -74,10 +62,10 @@ public class GiftCommand extends Command HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); - Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer)Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); + Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t"+ finalMessage +"\t0\t0"; + extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; Emulator.getGameEnvironment().getItemManager().createGift(username, giftItem, extraData, 0, 0); @@ -85,8 +73,7 @@ public class GiftCommand extends Command Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboInfo.getId()); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new InventoryRefreshComposer()); THashMap keys = new THashMap<>(); 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 11e3a5c3..274368c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/GiveRankCommand.java @@ -8,56 +8,43 @@ import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; import org.apache.commons.lang3.StringUtils; -public class GiveRankCommand extends Command -{ - public GiveRankCommand() - { +public class GiveRankCommand extends Command { + public GiveRankCommand() { super("cmd_give_rank", Emulator.getTexts().getValue("commands.keys.cmd_give_rank").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Rank rank = null; - if (params.length == 1) - { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_give_rank.missing_username") + Emulator.getTexts().getValue("commands.description.cmd_give_rank"), RoomChatMessageBubbles.ALERT); return true; } - if (params.length == 2) - { + if (params.length == 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_give_rank.missing_rank") + Emulator.getTexts().getValue("commands.description.cmd_give_rank"), RoomChatMessageBubbles.ALERT); return true; } - if (params.length == 3) - { - if (StringUtils.isNumeric(params[2])) - { + if (params.length == 3) { + if (StringUtils.isNumeric(params[2])) { int rankId = Integer.valueOf(params[2]); if (Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) - rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId); - } - else - { + rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId); + } else { rank = Emulator.getGameEnvironment().getPermissionsManager().getRankByName(params[2]); } - if (rank != null) - { - if (rank.getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (rank != null) { + if (rank.getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_give_rank.higher").replace("%username%", params[1]).replace("%id%", rank.getName()), RoomChatMessageBubbles.ALERT); return true; } HabboInfo habbo = HabboManager.getOfflineHabboInfo(params[1]); - if (habbo != null) - { - if (habbo.getRank().getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (habbo != null) { + if (habbo.getRank().getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_give_rank.higher.other").replace("%username%", params[1]).replace("%id%", rank.getName()), RoomChatMessageBubbles.ALERT); return true; } @@ -66,9 +53,7 @@ public class GiveRankCommand extends Command 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 - { + } 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; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HabnamCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HabnamCommand.java index cab63622..b1ccb3a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HabnamCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HabnamCommand.java @@ -2,20 +2,15 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class HabnamCommand extends Command -{ - public HabnamCommand() - { - super(null, new String[]{ "habnam", "gangnam" }); +public class HabnamCommand extends Command { + public HabnamCommand() { + super(null, new String[]{"habnam", "gangnam"}); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (gameClient.getHabbo().getHabboStats().hasActiveClub()) - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboStats().hasActiveClub()) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), 140, 30); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HandItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HandItemCommand.java index 2c11fe65..1cef1e9a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HandItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HandItemCommand.java @@ -4,31 +4,24 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserHandItemComposer; -public class HandItemCommand extends Command -{ - public HandItemCommand() - { +public class HandItemCommand extends Command { + public HandItemCommand() { super("cmd_hand_item", Emulator.getTexts().getValue("commands.keys.cmd_hand_item").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - {if(params.length == 2) - { - try - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - int effectId = Integer.parseInt(params[1]); - gameClient.getHabbo().getRoomUnit().setHandItem(effectId); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(gameClient.getHabbo().getRoomUnit()).compose()); + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { + try { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + int effectId = Integer.parseInt(params[1]); + gameClient.getHabbo().getRoomUnit().setHandItem(effectId); + gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(gameClient.getHabbo().getRoomUnit()).compose()); + } + } catch (Exception e) { + //Don't handle incorrect parse exceptions :P } } - catch (Exception e) - { - //Don't handle incorrect parse exceptions :P - } - } return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HappyHourCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HappyHourCommand.java index 8ba8cdc1..845195d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HappyHourCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HappyHourCommand.java @@ -8,20 +8,16 @@ import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import java.util.Map; -public class HappyHourCommand extends Command -{ - public HappyHourCommand() - { +public class HappyHourCommand extends Command { + public HappyHourCommand() { super("cmd_happyhour", Emulator.getTexts().getValue("commands.keys.cmd_happyhour").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new GenericAlertComposer("Happy Hour!")); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { AchievementManager.progressAchievement(set.getValue(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("HappyHour")); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HideWiredCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HideWiredCommand.java index 776fbbef..8141d02c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HideWiredCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HideWiredCommand.java @@ -4,27 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -public class HideWiredCommand extends Command -{ - public HideWiredCommand() - { +public class HideWiredCommand extends Command { + public HideWiredCommand() { super("cmd_hidewired", Emulator.getTexts().getValue("commands.keys.cmd_hidewired").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { - if (room.isOwner(gameClient.getHabbo())) - { + if (room != null) { + if (room.isOwner(gameClient.getHabbo())) { room.setHideWired(!room.isHideWired()); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_hidewired." + (room.isHideWired() ? "hidden" : "shown"))); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.errors.cmd_hidewired.permission")); } } 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 1bbb4d83..6be973a9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java @@ -11,15 +11,13 @@ import java.util.Map; public class HotelAlertCommand extends Command { - public HotelAlertCommand() - { + public HotelAlertCommand() { super("cmd_ha", Emulator.getTexts().getValue("commands.keys.cmd_ha").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) - { - if(params.length > 1) { + public boolean handle(GameClient gameClient, String[] params) { + if (params.length > 1) { StringBuilder message = new StringBuilder(); for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); @@ -27,17 +25,15 @@ public class HotelAlertCommand extends Command { ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if(habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().blockStaffAlerts) continue; habbo.getClient().sendResponse(msg); } - }else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertLinkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertLinkCommand.java index 75f0d1dc..fca733f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertLinkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertLinkCommand.java @@ -4,25 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.generic.alerts.StaffAlertWithLinkComposer; -public class HotelAlertLinkCommand extends Command -{ - public HotelAlertLinkCommand() - { - super("cmd_hal", Emulator.getTexts().getValue("commands.keys.cmd_hal").split(";")); +public class HotelAlertLinkCommand extends Command { + public HotelAlertLinkCommand() { + super("cmd_hal", Emulator.getTexts().getValue("commands.keys.cmd_hal").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length < 3) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 3) { return true; } String url = params[1]; StringBuilder message = new StringBuilder(); - for (int i = 2; i < params.length; i++) - { + for (int i = 2; i < params.length; i++) { message.append(params[i]); message.append(" "); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/IPBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/IPBanCommand.java index 44269ceb..e37bb1e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/IPBanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/IPBanCommand.java @@ -8,74 +8,57 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; -public class IPBanCommand extends Command -{ +public class IPBanCommand extends Command { public final static int TEN_YEARS = 315569260; - public IPBanCommand() - { + + public IPBanCommand() { super("cmd_ip_ban", Emulator.getTexts().getValue("commands.keys.cmd_ip_ban").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { HabboInfo habbo; StringBuilder reason = new StringBuilder(); - if (params.length >= 2) - { + if (params.length >= 2) { Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if (h != null) - { + if (h != null) { habbo = h.getHabboInfo(); - } - else - { + } else { habbo = HabboManager.getOfflineHabboInfo(params[1]); } - } - else - { + } else { return true; } - if (params.length > 2) - { - for (int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { reason.append(params[i]); reason.append(" "); } } int count = 0; - if (habbo != null) - { - if (habbo == gameClient.getHabbo().getHabboInfo()) - { + if (habbo != null) { + if (habbo == gameClient.getHabbo().getHabboInfo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ip_ban.ban_self"), RoomChatMessageBubbles.ALERT); return true; } - if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT); return true; } Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1); count++; - for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(habbo.getIpLogin())) - { - if (h != null) - { + for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(habbo.getIpLogin())) { + if (h != null) { count++; Emulator.getGameEnvironment().getModToolManager().ban(h.getHabboInfo().getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1); } } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT); return true; } 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 876708b5..e4337358 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java @@ -3,10 +3,7 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomLayout; -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 com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; @@ -14,16 +11,13 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; -public class InvisibleCommand extends Command -{ - public InvisibleCommand() - { - super("cmd_invisible", Emulator.getTexts().getValue("commands.keys.cmd_invisible").split(";")); +public class InvisibleCommand extends Command { + public InvisibleCommand() { + super("cmd_invisible", Emulator.getTexts().getValue("commands.keys.cmd_invisible").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit(); if (roomUnit.isInvisible()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java index b6e4ec76..4a186528 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java @@ -7,32 +7,26 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class LayCommand extends Command -{ - public LayCommand() - { - super (null, Emulator.getTexts().getValue("commands.keys.cmd_lay").split(";")); +public class LayCommand extends Command { + public LayCommand() { + super(null, Emulator.getTexts().getValue("commands.keys.cmd_lay").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { gameClient.getHabbo().getRoomUnit().cmdLay = true; gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); gameClient.getHabbo().getRoomUnit().cmdSit = true; gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomUserRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]); RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); - if (tile == null) - { + if (tile == null) { return false; } - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { RoomTile t = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(tile, gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue(), i); - if (t == null || !t.isWalkable()) - { + if (t == null || !t.isWalkable()) { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java index 4402200d..56f5b0fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java @@ -8,52 +8,40 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; -public class MachineBanCommand extends Command -{ - public MachineBanCommand() - { +public class MachineBanCommand extends Command { + public MachineBanCommand() { super("cmd_machine_ban", Emulator.getTexts().getValue("commands.keys.cmd_machine_ban").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { HabboInfo habbo = null; StringBuilder reason = new StringBuilder(); - if (params.length >= 2) - { + if (params.length >= 2) { Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if (h != null) - { + if (h != null) { habbo = h.getHabboInfo(); - } - else - { + } else { habbo = HabboManager.getOfflineHabboInfo(params[1]); } } - if (params.length > 2) - { - for (int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { reason.append(params[i]); reason.append(" "); } } int count; - if (habbo != null) - { - if (habbo == gameClient.getHabbo().getHabboInfo()) - { + if (habbo != null) { + if (habbo == gameClient.getHabbo().getHabboInfo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_machine_ban.ban_self"), RoomChatMessageBubbles.ALERT); return true; } - if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT); return true; } @@ -61,15 +49,7 @@ public class MachineBanCommand extends Command count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size(); - - - - - - - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT); return 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 e2e4b207..b584ee61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java @@ -14,42 +14,33 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class MassBadgeCommand extends Command -{ - public MassBadgeCommand() - { +public class MassBadgeCommand extends Command { + public MassBadgeCommand() { super("cmd_massbadge", Emulator.getTexts().getValue("commands.keys.cmd_massbadge").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { String badge; badge = params[1]; - if(!badge.isEmpty()) - { + if (!badge.isEmpty()) { THashMap keys = new THashMap<>(); 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 BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if(habbo.isOnline()) - { - if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) - { + if (habbo.isOnline()) { + if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { HabboBadge b = BadgesComponent.createBadge(badge, habbo); - if (b != null) - { + if (b != null) { habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); habbo.getClient().sendResponse(message); 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 ce8217db..6c7d279a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassCreditsCommand.java @@ -8,40 +8,31 @@ import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import java.util.Map; -public class MassCreditsCommand extends Command -{ - public MassCreditsCommand() - { +public class MassCreditsCommand extends Command { + public MassCreditsCommand() { super("cmd_masscredits", Emulator.getTexts().getValue("commands.keys.cmd_masscredits").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { int amount; - try - { + try { amount = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masscredits.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + if (amount != 0) { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); habbo.giveCredits(amount); habbo.getClient().sendResponse(new UserCreditsComposer(habbo)); - if(habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getHabboInfo().getCurrentRoom() != null) habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + ""), RoomChatMessageBubbles.ALERT); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java index 6096b59e..6855b6b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java @@ -14,50 +14,39 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class MassGiftCommand extends Command -{ - public MassGiftCommand() - { +public class MassGiftCommand extends Command { + public MassGiftCommand() { super("cmd_massgift", Emulator.getTexts().getValue("commands.keys.cmd_massgift").split(";")); } @Override - public boolean handle(final GameClient gameClient, String[] params) throws Exception - { - if(params.length >= 2) - { + public boolean handle(final GameClient gameClient, String[] params) throws Exception { + if (params.length >= 2) { int itemId; - try - { + try { itemId = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } - if(itemId <= 0) - { + if (itemId <= 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } final Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(itemId); - if(baseItem == null) - { + if (baseItem == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT); return true; } StringBuilder message = new StringBuilder(); - if(params.length > 2) - { - for (int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { message.append(params[i]).append(" "); } } @@ -70,13 +59,10 @@ public class MassGiftCommand extends Command keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous")); ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + public void run() { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); @@ -84,7 +70,7 @@ public class MassGiftCommand extends Command Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t"+ finalMessage +"\t0\t0"; + extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); 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 237eecba..7d4fd95b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassPixelsCommand.java @@ -7,39 +7,30 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.Map; -public class MassPixelsCommand extends Command -{ - public MassPixelsCommand() - { +public class MassPixelsCommand extends Command { + public MassPixelsCommand() { super("cmd_massduckets", Emulator.getTexts().getValue("commands.keys.cmd_massduckets").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { int amount; - try - { + try { amount = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_massduckets.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + if (amount != 0) { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); habbo.givePixels(amount); - if(habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getHabboInfo().getCurrentRoom() != null) habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", amount + ""), RoomChatMessageBubbles.ALERT); } } 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 fb4608f1..79103ea8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java @@ -4,83 +4,64 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; import java.util.Map; -public class MassPointsCommand extends Command -{ - public MassPointsCommand() - { +public class MassPointsCommand extends Command { + public MassPointsCommand() { super("cmd_masspoints", Emulator.getTexts().getValue("commands.keys.cmd_masspoints").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int type = Emulator.getConfig().getInt("seasonal.primary.type"); String amountString; - if(params.length == 3) - { + if (params.length == 3) { amountString = params[1]; - try - { + try { type = Integer.valueOf(params[2]); - } catch (Exception e) - { + } 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; } - } - else if(params.length == 2) - { + } else if (params.length == 2) { amountString = params[1]; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } boolean found = false; - for(String s : Emulator.getConfig().getValue("seasonal.types").split(";")) - { - if(s.equalsIgnoreCase(type + "")) - { + for (String s : Emulator.getConfig().getValue("seasonal.types").split(";")) { + if (s.equalsIgnoreCase(type + "")) { found = true; break; } } - if(!found) - { + if (!found) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT); return true; } int amount; - try - { + try { amount = Integer.valueOf(amountString); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { + if (amount != 0) { String message = Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); habbo.givePoints(type, amount); - if(habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getHabboInfo().getCurrentRoom() != null) habbo.whisper(message, RoomChatMessageBubbles.ALERT); else habbo.alert(message); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java index dbfa6598..80bef498 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java @@ -9,16 +9,13 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.eu.habbo.util.figure.FigureUtil; -public class MimicCommand extends Command -{ - public MimicCommand() - { +public class MimicCommand extends Command { + public MimicCommand() { super("cmd_mimic", Emulator.getTexts().getValue("commands.keys.cmd_mimic").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { if (params.length == 2) { Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); @@ -44,9 +41,7 @@ public class MimicCommand extends Command gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mimic.copied").replace("%user%", params[1]).replace("%gender_name%", (habbo.getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), RoomChatMessageBubbles.ALERT); return true; } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MoonwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MoonwalkCommand.java index d3d822ba..676871d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MoonwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MoonwalkCommand.java @@ -3,18 +3,14 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class MoonwalkCommand extends Command -{ - public MoonwalkCommand() - { +public class MoonwalkCommand extends Command { + public MoonwalkCommand() { super("cmd_moonwalk", Emulator.getTexts().getValue("commands.keys.cmd_moonwalk").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) { int effect = 136; if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136) effect = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MultiCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MultiCommand.java index bcffa8d5..04009bf6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MultiCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MultiCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.rooms.items.PostItStickyPoleOpenComposer; -public class MultiCommand extends Command -{ - public MultiCommand() - { +public class MultiCommand extends Command { + public MultiCommand() { super("cmd_multi", Emulator.getTexts().getValue("commands.keys.cmd_multi").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { gameClient.sendResponse(new PostItStickyPoleOpenComposer(null)); 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 2f0cd6c2..768a42e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteBotsCommand.java @@ -4,18 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class MuteBotsCommand extends Command -{ - public MuteBotsCommand() - { +public class MuteBotsCommand extends Command { + public MuteBotsCommand() { super(null, Emulator.getTexts().getValue("commands.keys.cmd_mute_bots").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + 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().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_bots." + (gameClient.getHabbo().getHabboStats().ignoreBots ? "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 7d703c5f..919c43a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java @@ -6,50 +6,38 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserIgnoredComposer; -public class MuteCommand extends Command -{ - public MuteCommand() - { +public class MuteCommand extends Command { + public MuteCommand() { super("cmd_mute", Emulator.getTexts().getValue("commands.keys.cmd_mute").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.not_specified"), RoomChatMessageBubbles.ALERT); return true; } Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else - { - if(habbo == gameClient.getHabbo()) - { + } else { + if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.self"), RoomChatMessageBubbles.ALERT); return true; } int duration = Integer.MAX_VALUE; - if(params.length == 3) - { - try - { + if (params.length == 3) { + try { duration = Integer.valueOf(params[2]); - if(duration <= 0) + if (duration <= 0) throw new Exception(""); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.time"), RoomChatMessageBubbles.ALERT); return true; } @@ -57,8 +45,7 @@ public class MuteCommand extends Command habbo.mute(duration); - if(habbo.getHabboInfo().getCurrentRoom() != null) - { + if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED } 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 0a527221..6dcb6972 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MutePetsCommand.java @@ -4,18 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class MutePetsCommand extends Command -{ - public MutePetsCommand() - { +public class MutePetsCommand extends Command { + public MutePetsCommand() { super(null, Emulator.getTexts().getValue("commands.keys.cmd_mute_pets").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + 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().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute_pets." + (gameClient.getHabbo().getHabboStats().ignorePets ? "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 61cc764d..00a81642 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PetInfoCommand.java @@ -5,33 +5,25 @@ 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 com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import gnu.trove.procedure.TIntObjectProcedure; -public class PetInfoCommand extends Command -{ - public PetInfoCommand() - { +public class PetInfoCommand extends Command { + public PetInfoCommand() { super("cmd_pet_info", Emulator.getTexts().getValue("commands.keys.cmd_pet_info").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length > 1) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length > 1) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) return false; String name = params[1]; - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry(new TIntObjectProcedure() - { + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry(new TIntObjectProcedure() { @Override - public boolean execute(int a, Pet pet) - { - if(pet.getName().equalsIgnoreCase(name)) - { + 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" + @@ -45,7 +37,7 @@ public class PetInfoCommand extends Command 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.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")) + "" ); } @@ -53,9 +45,7 @@ public class PetInfoCommand extends Command return true; } }); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pet_info.pet_not_found"), RoomChatMessageBubbles.ALERT); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PickallCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PickallCommand.java index 38073315..2e7b8d75 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PickallCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PickallCommand.java @@ -4,22 +4,17 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -public class PickallCommand extends Command -{ - public PickallCommand() - { +public class PickallCommand extends Command { + public PickallCommand() { super("cmd_pickall", Emulator.getTexts().getValue("commands.keys.cmd_pickall").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.isOwner(gameClient.getHabbo())) - { + if (room != null) { + if (room.isOwner(gameClient.getHabbo())) { room.ejectAll(); return true; } 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 be3f303b..327dc4e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PixelCommand.java @@ -4,53 +4,38 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; -public class PixelCommand extends Command -{ - public PixelCommand() - { +public class PixelCommand extends Command { + public PixelCommand() { super("cmd_duckets", Emulator.getTexts().getValue("commands.keys.cmd_duckets").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 3) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 3) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]); - if(habbo != null) - { - try - { - if (Integer.parseInt(params[2]) != 0) - { + if (habbo != null) { + try { + if (Integer.parseInt(params[2]) != 0) { habbo.givePixels(Integer.parseInt(params[2])); - if(habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getHabboInfo().getCurrentRoom() != null) habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""), RoomChatMessageBubbles.ALERT); else habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(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); - } else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.invalid_amount"), RoomChatMessageBubbles.ALERT); } - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.invalid_amount"), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.user_offline").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.invalid_amount"), RoomChatMessageBubbles.ALERT); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java index cb129f1f..75c978a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java @@ -7,29 +7,23 @@ import com.eu.habbo.plugin.HabboPlugin; import java.util.Collections; -public class PluginsCommand extends Command -{ - public PluginsCommand() - { +public class PluginsCommand extends Command { + public PluginsCommand() { super("cmd_plugins", Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { StringBuilder message = new StringBuilder("Plugins (" + Emulator.getPluginManager().getPlugins().size() + ")\r"); - for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins()) - { + for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins()) { message.append("\r").append(plugin.configuration.name).append(" By ").append(plugin.configuration.author); } - if (Emulator.getConfig().getBoolean("commands.plugins.oldstyle")) - { + if (Emulator.getConfig().getBoolean("commands.plugins.oldstyle")) { gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(message.toString()))); - } else - { + } else { gameClient.getHabbo().alert(message.toString()); } 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 e131bbc3..0580188f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java @@ -4,37 +4,25 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; -import com.eu.habbo.messages.outgoing.users.UserPointsComposer; -public class PointsCommand extends Command -{ - public PointsCommand() - { +public class PointsCommand extends Command { + public PointsCommand() { super("cmd_points", Emulator.getTexts().getValue("commands.keys.cmd_points").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length >= 3) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length >= 3) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]); - if(habbo != null) - { - try - { + if (habbo != null) { + try { int type = Emulator.getConfig().getInt("seasonal.primary.type"); - if(params.length == 4) - { - try - { + if (params.length == 4) { + try { type = Integer.valueOf(params[3]); - } - catch (Exception e) - { + } 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; } @@ -42,46 +30,35 @@ public class PointsCommand extends Command int amount; - try - { + try { amount = Integer.valueOf(params[2]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if (amount != 0) - { + if (amount != 0) { habbo.givePoints(type, amount); - if(habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getHabboInfo().getCurrentRoom() != null) habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT); else habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type))); - // habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(type), amount, type)); + // habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(type), amount, type)); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_points.send").replace("%amount%", amount + "").replace("%user%", params[1]).replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT); - } else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT); } - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.user_offline").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { 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 17028a91..0ffe541a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PromoteTargetOfferCommand.java @@ -4,85 +4,65 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; import gnu.trove.map.hash.THashMap; import java.util.ArrayList; import java.util.List; -public class PromoteTargetOfferCommand extends Command -{ +public class PromoteTargetOfferCommand extends Command { - public PromoteTargetOfferCommand() - { + public PromoteTargetOfferCommand() { super("cmd_promote_offer", Emulator.getTexts().getValue("commands.keys.cmd_promote_offer").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length <= 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length <= 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_promote_offer.not_found")); return true; } String offerKey = params[1]; - if (offerKey.equalsIgnoreCase(Emulator.getTexts().getValue("commands.cmd_promote_offer.info"))) - { + if (offerKey.equalsIgnoreCase(Emulator.getTexts().getValue("commands.cmd_promote_offer.info"))) { THashMap targetOffers = Emulator.getGameEnvironment().getCatalogManager().targetOffers; String[] textConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list").replace("%amount%", targetOffers.size() + "").split("
"); String entryConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list.entry"); List message = new ArrayList<>(); - for (String pair : textConfig) - { - if (pair.contains("%list%")) - { - for (TargetOffer offer : targetOffers.values()) - { + for (String pair : textConfig) { + if (pair.contains("%list%")) { + for (TargetOffer offer : targetOffers.values()) { message.add(entryConfig.replace("%id%", offer.getId() + "").replace("%title%", offer.getTitle()).replace("%description%", offer.getDescription().substring(0, 25))); } - } - else - { + } else { message.add(pair); } } gameClient.sendResponse(new MessagesForYouComposer(message)); - } - else - { + } else { int offerId = 0; - try - { + try { offerId = Integer.valueOf(offerKey); - } - catch (Exception e) - { + } catch (Exception e) { } - if (offerId > 0) - { + if (offerId > 0) { TargetOffer offer = Emulator.getGameEnvironment().getCatalogManager().getTargetOffer(offerId); - if (offer != null) - { + if (offer != null) { TargetOffer.ACTIVE_TARGET_OFFER_ID = offer.getId(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_promote_offer").replace("%id%", offerKey).replace("%title%", offer.getTitle())); - for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) - { + for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) { habbo.getClient().sendResponse(new TargetedOfferComposer(habbo, offer)); } } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_promote_offer.not_found")); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PullCommand.java index ca390244..3a45e0aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PullCommand.java @@ -9,48 +9,34 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; -public class PullCommand extends Command -{ - public PullCommand() - { +public class PullCommand extends Command { + public PullCommand() { super("cmd_pull", Emulator.getTexts().getValue("commands.keys.cmd_pull").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else if(habbo == gameClient.getHabbo()) - { + } else if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { int distanceX = habbo.getRoomUnit().getX() - gameClient.getHabbo().getRoomUnit().getX(); int distanceY = habbo.getRoomUnit().getY() - gameClient.getHabbo().getRoomUnit().getY(); - if(distanceX < -2 || distanceX > 2 || distanceY < -2 || distanceY > 2) - { + if (distanceX < -2 || distanceX > 2 || distanceY < -2 || distanceY > 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.cant_reach").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tile != null && tile.isWalkable()) - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tile) - { + if (tile != null && tile.isWalkable()) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tile) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.invalid").replace("%username%", params[1])); return true; } 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 58cee384..d9518c0e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PushCommand.java @@ -9,53 +9,38 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; -public class PushCommand extends Command -{ - public PushCommand() - { +public class PushCommand extends Command { + public PushCommand() { super("cmd_push", Emulator.getTexts().getValue("commands.keys.cmd_push").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else if(habbo == gameClient.getHabbo()) - { + } else if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.push_self"), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { RoomTile tFront = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tFront != null && tFront.isWalkable()) - { - if (tFront.x == habbo.getRoomUnit().getX() && tFront.y == habbo.getRoomUnit().getY()) - { + if (tFront != null && tFront.isWalkable()) { + if (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 (tFrontTarget != null && tFrontTarget.isWalkable()) - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tFrontTarget) - { + 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 RoomUserTalkComposer(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 - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_push.cant_reach").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); 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 1d12e340..b88d5352 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java @@ -13,16 +13,13 @@ import gnu.trove.procedure.TIntIntProcedure; import java.util.ArrayList; -public class RedeemCommand extends Command -{ - public RedeemCommand() - { +public class RedeemCommand extends Command { + public RedeemCommand() { super("cmd_redeem", Emulator.getTexts().getValue("commands.keys.cmd_redeem").split(";")); } @Override - public boolean handle(final GameClient gameClient, String[] params) throws Exception - { + public boolean handle(final GameClient gameClient, String[] params) throws Exception { if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null) return false; ArrayList items = new ArrayList<>(); @@ -32,32 +29,22 @@ public class RedeemCommand extends Command TIntIntMap points = new TIntIntHashMap(); - for(HabboItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) - { - if (item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) - { - if (item.getUserId() == gameClient.getHabbo().getHabboInfo().getId()) - { + for (HabboItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) { + if (item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) { + if (item.getUserId() == gameClient.getHabbo().getHabboInfo().getId()) { items.add(item); - if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) - { - try - { + 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) - { + } catch (Exception e) { } - } else if (item.getBaseItem().getName().startsWith("PF_")) - { - try - { + } else if (item.getBaseItem().getName().startsWith("PF_")) { + try { pixels += Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } catch (Exception e) - { + } catch (Exception e) { } - } else if (item.getBaseItem().getName().startsWith("DF_")) - { + } else if (item.getBaseItem().getName().startsWith("DF_")) { int pointsType; int pointsAmount; @@ -65,14 +52,11 @@ public class RedeemCommand extends Command pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount); - } else if (item.getBaseItem().getName().startsWith("CF_diamond_")) - { - try - { + } else if (item.getBaseItem().getName().startsWith("CF_diamond_")) { + try { int amount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); points.adjustOrPutValue(5, amount, amount); - } catch (Exception e) - { + } catch (Exception e) { } } } @@ -80,8 +64,7 @@ public class RedeemCommand extends Command } TIntObjectHashMap deleted = new TIntObjectHashMap<>(); - for(HabboItem item : items) - { + for (HabboItem item : items) { gameClient.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); deleted.put(item.getId(), item); } @@ -97,19 +80,15 @@ public class RedeemCommand extends Command message[0] += Emulator.getTexts().getValue("generic.credits"); message[0] += ": " + credits; - if(pixels > 0) - { + if (pixels > 0) { message[0] += ", " + Emulator.getTexts().getValue("generic.pixels"); message[0] += ": " + pixels + ""; } - if(!points.isEmpty()) - { - points.forEachEntry(new TIntIntProcedure() - { + if (!points.isEmpty()) { + points.forEachEntry(new TIntIntProcedure() { @Override - public boolean execute(int a, int b) - { + public boolean execute(int a, int 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/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java index 135afe9a..de2768e1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java @@ -10,30 +10,23 @@ import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import java.util.ArrayList; import java.util.Collection; -public class ReloadRoomCommand extends Command -{ - public ReloadRoomCommand() - { +public class ReloadRoomCommand extends Command { + public ReloadRoomCommand() { super("cmd_reload_room", Emulator.getTexts().getValue("commands.keys.cmd_reload_room").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - Emulator.getThreading().run(new Runnable() - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { Collection habbos = new ArrayList<>(room.getHabbos()); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); - for(Habbo habbo : habbos) - { + for (Habbo habbo : habbos) { habbo.getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomAlertCommand.java index 62a31ce6..e71b6abe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomAlertCommand.java @@ -6,35 +6,28 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; -public class RoomAlertCommand extends Command -{ - public RoomAlertCommand() - { +public class RoomAlertCommand extends Command { + public RoomAlertCommand() { super("cmd_roomalert", Emulator.getTexts().getValue("commands.keys.cmd_roomalert").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { StringBuilder message = new StringBuilder(); - if (params.length >= 2) - { - for (int i = 1; i < params.length; i++) - { + if (params.length >= 2) { + for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); } - if (message.length() == 0) - { + if (message.length() == 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomalert.empty"), RoomChatMessageBubbles.ALERT); return true; } Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { room.sendComposer(new ModToolIssueHandledComposer(message.toString()).compose()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java index c2ada3bb..8affbd20 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java @@ -10,29 +10,24 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import java.sql.*; -public class RoomBundleCommand extends Command -{ - public RoomBundleCommand() - { +public class RoomBundleCommand extends Command { + public RoomBundleCommand() { super("cmd_bundle", Emulator.getTexts().getValue("commands.keys.cmd_bundle").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int parentId; int credits; int points; int pointsType; - if(params.length < 5) - { + if (params.length < 5) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_bundle.missing_params"), RoomChatMessageBubbles.ALERT); return true; } - if(Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()) != null) - { + if (Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()) != null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_bundle.duplicate"), RoomChatMessageBubbles.ALERT); return true; } @@ -44,10 +39,8 @@ public class RoomBundleCommand extends Command 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); - if(page instanceof RoomBundleLayout) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type ) VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + if (page instanceof RoomBundleLayout) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type ) VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, page.getId()); statement.setString(2, ""); statement.setString(3, "room_bundle"); @@ -56,29 +49,22 @@ public class RoomBundleCommand extends Command statement.setInt(6, pointsType); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { - try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM catalog_items WHERE id = ?")) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { + try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM catalog_items WHERE id = ?")) { stmt.setInt(1, set.getInt(1)); - try (ResultSet st = stmt.executeQuery()) - { - if (st.next()) - { + try (ResultSet st = stmt.executeQuery()) { + if (st.next()) { page.addItem(new CatalogItem(st)); } } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - ((RoomBundleLayout)page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); + ((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_bundle").replace("%id%", page.getId() + ""), RoomChatMessageBubbles.ALERT); } 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 d16930b5..1c72b7a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomCreditsCommand.java @@ -5,35 +5,26 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class RoomCreditsCommand extends Command -{ - public RoomCreditsCommand() - { +public class RoomCreditsCommand extends Command { + public RoomCreditsCommand() { super("cmd_roomcredits", Emulator.getTexts().getValue("commands.keys.cmd_roomcredits").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { int amount; - try - { + try { amount = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masscredits.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { + if (amount != 0) { final String message = Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + ""); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.giveCredits(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); } 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 57069d0e..0fcfa7bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomDanceCommand.java @@ -7,44 +7,33 @@ import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; -public class RoomDanceCommand extends Command -{ - public RoomDanceCommand() - { +public class RoomDanceCommand extends Command { + public RoomDanceCommand() { super("cmd_danceall", Emulator.getTexts().getValue("commands.keys.cmd_danceall").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { int danceId; - try - { + try { danceId = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_danceall.invalid_dance"), RoomChatMessageBubbles.ALERT); return true; } - if(danceId < 0 || danceId > 4) - { + if (danceId < 0 || danceId > 4) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_danceall.outside_bounds"), RoomChatMessageBubbles.ALERT); return true; } - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.getRoomUnit().setDanceType(DanceType.values()[danceId]); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDanceComposer(habbo.getRoomUnit()).compose()); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_danceall.no_dance"), RoomChatMessageBubbles.ALERT); } 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 0c639deb..111b3887 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomEffectCommand.java @@ -6,44 +6,33 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class RoomEffectCommand extends Command -{ - public RoomEffectCommand() - { +public class RoomEffectCommand extends Command { + public RoomEffectCommand() { super("cmd_roomeffect", Emulator.getTexts().getValue("commands.keys.cmd_roomeffect").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomeffect.no_effect"), RoomChatMessageBubbles.ALERT); return true; } - try - { + try { int effectId = Integer.valueOf(params[1]); - if(effectId >= 0) - { + if (effectId >= 0) { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - for (Habbo habbo : room.getHabbos()) - { + for (Habbo habbo : room.getHabbos()) { room.giveEffect(habbo, effectId, -1); } return true; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT); return true; } - } - catch (Exception e) - { + } 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 6527f20b..f1914b52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java @@ -6,67 +6,55 @@ import com.eu.habbo.habbohotel.items.Item; 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.outgoing.wired.WiredRewardAlertComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; -public class RoomGiftCommand extends Command -{ - public RoomGiftCommand() - { +public class RoomGiftCommand extends Command { + public RoomGiftCommand() { super("cmd_roomgift", Emulator.getTexts().getValue("commands.keys.cmd_roomgift").split(";")); } @Override - public boolean handle(final GameClient gameClient, String[] params) throws Exception - { - if(params.length >= 2) - { + public boolean handle(final GameClient gameClient, String[] params) throws Exception { + if (params.length >= 2) { int itemId; - try - { + try { itemId = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } - if(itemId <= 0) - { + if (itemId <= 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); return true; } final Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(itemId); - if(baseItem == null) - { + if (baseItem == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT); return true; } StringBuilder message = new StringBuilder(); - if(params.length > 2) - { - for (int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { message.append(params[i]).append(" "); } } final String finalMessage = message.toString(); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t"+ finalMessage +"\t0\t0"; + extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); 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 76939b42..d0bfbae2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomItemCommand.java @@ -6,50 +6,38 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserHandItemComposer; -public class RoomItemCommand extends Command -{ - public RoomItemCommand() - { +public class RoomItemCommand extends Command { + public RoomItemCommand() { super("cmd_roomitem", Emulator.getTexts().getValue("commands.keys.cmd_roomitem").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int itemId = 0; - if(params.length >= 2) - { - try - { + if (params.length >= 2) { + try { itemId = Integer.valueOf(params[1]); - if(itemId < 0) - { + if (itemId < 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomitem.positive"), RoomChatMessageBubbles.ALERT); return true; } - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomitem.no_item"), RoomChatMessageBubbles.ALERT); return true; } } - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.getRoomUnit().setHandItem(itemId); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(habbo.getRoomUnit()).compose()); } - if(itemId > 0) - { + if (itemId > 0) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roomitem.given").replace("%item%", itemId + ""), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roomitem.removed"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomKickCommand.java index 85fc19d2..3610e06a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomKickCommand.java @@ -7,33 +7,25 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; -public class RoomKickCommand extends Command -{ - public RoomKickCommand() - { +public class RoomKickCommand extends Command { + public RoomKickCommand() { super("cmd_kickall", Emulator.getTexts().getValue("commands.keys.cmd_kickall").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(params.length > 1) - { + if (room != null) { + if (params.length > 1) { StringBuilder message = new StringBuilder(); - for (int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); } - room.sendComposer(new GenericAlertComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose()); + room.sendComposer(new GenericAlertComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose()); } - for (Habbo habbo : room.getHabbos()) - { - if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) - { + for (Habbo habbo : room.getHabbos()) { + if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { room.kickHabbo(habbo, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomMuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomMuteCommand.java index 0b6d50b7..5ee1bd4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomMuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomMuteCommand.java @@ -5,20 +5,16 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class RoomMuteCommand extends Command -{ - public RoomMuteCommand() - { +public class RoomMuteCommand extends Command { + public RoomMuteCommand() { super("cmd_roommute", Emulator.getTexts().getValue("commands.keys.cmd_roommute").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { room.setMuted(!room.isMuted()); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roommute." + (room.isMuted() ? "muted" : "unmuted")), RoomChatMessageBubbles.ALERT); } 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 dfbec1c1..567400f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPixelsCommand.java @@ -5,35 +5,26 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class RoomPixelsCommand extends Command -{ - public RoomPixelsCommand() - { +public class RoomPixelsCommand extends Command { + public RoomPixelsCommand() { super("cmd_roompixels", Emulator.getTexts().getValue("commands.keys.cmd_roompixels").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { int amount; - try - { + try { amount = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_massduckets.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { + if (amount != 0) { final String message = Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", amount + ""); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.givePixels(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); } 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 bdab3f33..32ebe50d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java @@ -5,75 +5,57 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class RoomPointsCommand extends Command -{ - public RoomPointsCommand() - { +public class RoomPointsCommand extends Command { + public RoomPointsCommand() { super("cmd_roompoints", Emulator.getTexts().getValue("commands.keys.cmd_roompoints").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int type = Emulator.getConfig().getInt("seasonal.primary.type"); String amountString; - if(params.length == 3) - { - try - { + if (params.length == 3) { + try { amountString = params[1]; type = Integer.valueOf(params[2]); - } catch (Exception e) - { + } 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; } - } - else if(params.length == 2) - { + } else if (params.length == 2) { amountString = params[1]; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } boolean found = false; - for(String s : Emulator.getConfig().getValue("seasonal.types").split(";")) - { - if(s.equalsIgnoreCase(type + "")) - { + for (String s : Emulator.getConfig().getValue("seasonal.types").split(";")) { + if (s.equalsIgnoreCase(type + "")) { found = true; break; } } - if(!found) - { + if (!found) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT); return true; } int amount; - try - { + try { amount = Integer.valueOf(amountString); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_masspoints.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(amount != 0) - { + if (amount != 0) { final String message = Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.givePoints(type, amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SayAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SayAllCommand.java index 7ecc311a..17cf15a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SayAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SayAllCommand.java @@ -5,30 +5,24 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class SayAllCommand extends Command -{ - public SayAllCommand() - { +public class SayAllCommand extends Command { + public SayAllCommand() { super("cmd_say_all", Emulator.getTexts().getValue("commands.keys.cmd_say_all").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_say_all.forgot_message"), RoomChatMessageBubbles.ALERT); return true; } StringBuilder message = new StringBuilder(); - for(int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); } - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.talk(message.toString()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SayCommand.java index 5ac5763e..64addc34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SayCommand.java @@ -7,43 +7,33 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; -public class SayCommand extends Command -{ - public SayCommand() - { +public class SayCommand extends Command { + public SayCommand() { super("cmd_say", Emulator.getTexts().getValue("commands.keys.cmd_say").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_say.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(target == null) - { + if (target == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_say.user_not_found"), RoomChatMessageBubbles.ALERT); return true; - } - else - { - if(target.getHabboInfo().getCurrentRoom() == null) - { + } else { + if (target.getHabboInfo().getCurrentRoom() == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_say.hotel_view").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } } StringBuilder message = new StringBuilder(); - if(params.length > 2) - { - for(int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { message.append(params[i]).append(" "); } } 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 a87e636e..b6bdfd87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java @@ -4,42 +4,30 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class SetMaxCommand extends Command -{ - public SetMaxCommand() - { +public class SetMaxCommand extends Command { + public SetMaxCommand() { super("cmd_setmax", Emulator.getTexts().getValue("commands.keys.cmd_setmax").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length >= 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length >= 2) { int max; - try - { + try { max = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { return false; } - if (max > 0 && max < 9999) - { + 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 - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setmax.invalid_number"), RoomChatMessageBubbles.ALERT); return true; } - } - else - { + } 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 47c9e544..b9c0072f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetPollCommand.java @@ -4,50 +4,34 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class SetPollCommand extends Command -{ - public SetPollCommand() - { +public class SetPollCommand extends Command { + public SetPollCommand() { super("cmd_set_poll", Emulator.getTexts().getValue("commands.keys.cmd_set_poll").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length >= 2) - { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length >= 2) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { int pollId = -1; - try - { + try { pollId = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { } - if (pollId >= 0) - { - if (Emulator.getGameEnvironment().getPollManager().getPoll(pollId) != null) - { + if (pollId >= 0) { + if (Emulator.getGameEnvironment().getPollManager().getPoll(pollId) != null) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPollId(pollId); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_set_poll"), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_set_poll.not_found"), RoomChatMessageBubbles.ALERT); } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_set_poll.invalid_number"), RoomChatMessageBubbles.ALERT); } } - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_set_poll.missing_arg"), RoomChatMessageBubbles.ALERT); } 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 dcd68916..bdce54d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetSpeedCommand.java @@ -5,37 +5,28 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class SetSpeedCommand extends Command -{ - public SetSpeedCommand() - { +public class SetSpeedCommand extends Command { + public SetSpeedCommand() { super("cmd_setspeed", Emulator.getTexts().getValue("commands.keys.cmd_setspeed").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); int oldSpeed = room.getRollerSpeed(); int newSpeed; - try - { + try { newSpeed = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setspeed.invalid_amount"), RoomChatMessageBubbles.ALERT); return true; } - if(newSpeed < -1 || newSpeed > Emulator.getConfig().getInt("hotel.rollers.speed.maximum")) - { + if (newSpeed < -1 || newSpeed > Emulator.getConfig().getInt("hotel.rollers.speed.maximum")) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setspeed.bounds"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ShoutAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ShoutAllCommand.java index 80c2729e..156a4dac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ShoutAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ShoutAllCommand.java @@ -5,30 +5,24 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class ShoutAllCommand extends Command -{ - public ShoutAllCommand() - { +public class ShoutAllCommand extends Command { + public ShoutAllCommand() { super("cmd_shout_all", Emulator.getTexts().getValue("commands.keys.cmd_shout_all").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_shout_all.forgot_message"), RoomChatMessageBubbles.ALERT); return true; } StringBuilder message = new StringBuilder(); - for(int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); } - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { habbo.shout(message.toString()); } 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 3b442c9d..bb121583 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ShoutCommand.java @@ -7,45 +7,35 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserShoutComposer; -public class ShoutCommand extends Command -{ +public class ShoutCommand extends Command { private static String idea = "Kudo's To Droppy for this idea!"; - public ShoutCommand() - { + public ShoutCommand() { super("cmd_shout", Emulator.getTexts().getValue("commands.keys.cmd_shout").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_shout.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(target == null) - { + if (target == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_shout.user_not_found"), RoomChatMessageBubbles.ALERT); return true; - } - else - { - if(target.getHabboInfo().getCurrentRoom() == null) - { + } else { + if (target.getHabboInfo().getCurrentRoom() == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_shout.hotel_view").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } } StringBuilder message = new StringBuilder(); - if(params.length > 2) - { - for(int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { message.append(params[i]).append(" "); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ShutdownCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ShutdownCommand.java index 4a9eed5e..7abeea65 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ShutdownCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ShutdownCommand.java @@ -8,52 +8,38 @@ import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; import com.eu.habbo.threading.runnables.ShutdownEmulator; -public class ShutdownCommand extends Command -{ - public ShutdownCommand() - { +public class ShutdownCommand extends Command { + public ShutdownCommand() { super("cmd_shutdown", Emulator.getTexts().getValue("commands.keys.cmd_shutdown").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { StringBuilder reason = new StringBuilder("-"); int minutes = 0; - if(params.length > 2) - { + if (params.length > 2) { reason = new StringBuilder(); - for(int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { reason.append(params[i]).append(" "); } - } - else - { - if (params.length == 2) - { - try - { + } else { + if (params.length == 2) { + try { minutes = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { reason = new StringBuilder(params[1]); } } } ServerMessage message; - if (!reason.toString().equals("-")) - { + if (!reason.toString().equals("-")) { message = new GenericAlertComposer("" + Emulator.getTexts().getValue("generic.warning") + " \r\n" + Emulator.getTexts().getValue("generic.shutdown").replace("%minutes%", minutes + "") + "\r\n" + Emulator.getTexts().getValue("generic.reason.specified") + ": " + reason + "\r" + "\r" + "- " + gameClient.getHabbo().getHabboInfo().getUsername()).compose(); - } - else - { + } else { message = new HotelWillCloseInMinutesComposer(minutes).compose(); } RoomTrade.TRADING_ENABLED = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SitCommand.java index 216c3eff..dd8199ce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SitCommand.java @@ -3,18 +3,15 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class SitCommand extends Command -{ - public SitCommand() - { +public class SitCommand extends Command { + public SitCommand() { super(null, Emulator.getTexts().getValue("commands.keys.cmd_sit").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled - gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(gameClient.getHabbo()); + gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(gameClient.getHabbo()); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SitDownCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SitDownCommand.java index f4fdcc11..afb37a38 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SitDownCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SitDownCommand.java @@ -5,29 +5,23 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class SitDownCommand extends Command -{ - public SitDownCommand() - { +public class SitDownCommand extends Command { + public SitDownCommand() { super("cmd_sitdown", Emulator.getTexts().getValue("commands.keys.cmd_sitdown").split(";")); } + @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { - if(habbo.getRoomUnit().isWalking()) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { + if (habbo.getRoomUnit().isWalking()) { habbo.getRoomUnit().stopWalking(); - } - else if(habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) - { + } else if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { continue; } gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(habbo); } - + return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java index 2a415a67..d6e9487a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java @@ -6,29 +6,22 @@ import com.eu.habbo.habbohotel.messenger.Message; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer; -public class StaffAlertCommand extends Command -{ - public StaffAlertCommand() - { +public class StaffAlertCommand extends Command { + public StaffAlertCommand() { super("cmd_staffalert", Emulator.getTexts().getValue("commands.keys.cmd_staffalert").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length > 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length > 1) { StringBuilder message = new StringBuilder(); - for (int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { message.append(params[i]).append(" "); } Emulator.getGameEnvironment().getHabboManager().staffAlert(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new FriendChatMessageComposer(new Message(gameClient.getHabbo().getHabboInfo().getId(), -1, message.toString())).compose(), "acc_staff_chat", gameClient); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffalert.forgot_message"), RoomChatMessageBubbles.ALERT); } 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 d6aca0cc..19eabcab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StaffOnlineCommand.java @@ -4,65 +4,48 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Map; -public class StaffOnlineCommand extends Command -{ - public StaffOnlineCommand() - { +public class StaffOnlineCommand extends Command { + public StaffOnlineCommand() { super("cmd_staffonline", Emulator.getTexts().getValue("commands.keys.cmd_staffonline").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int minRank = Emulator.getConfig().getInt("commands.cmd_staffonline.min_rank"); - if(params.length >= 2) - { - try - { + if (params.length >= 2) { + try { int i = Integer.valueOf(params[1]); - if(i < 1) - { + if (i < 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffonline.positive_only"), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { minRank = i; } - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffonline.numbers_only"), RoomChatMessageBubbles.ALERT); return true; } } - synchronized (Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos()) - { + synchronized (Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos()) { ArrayList staffs = new ArrayList<>(); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { - if(set.getValue().getHabboInfo().getRank().getId() >= minRank) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + if (set.getValue().getHabboInfo().getRank().getId() >= minRank) { staffs.add(set.getValue()); } } - staffs.sort(new Comparator() - { + staffs.sort(new Comparator() { @Override - public int compare(Habbo o1, Habbo o2) - { + public int compare(Habbo o1, Habbo o2) { return o1.getHabboInfo().getId() - o2.getHabboInfo().getId(); } }); @@ -70,8 +53,7 @@ public class StaffOnlineCommand extends Command StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_staffonline.staffs")); message.append("\r\n"); - for(Habbo habbo : staffs) - { + for (Habbo habbo : staffs) { message.append(habbo.getHabboInfo().getUsername()); message.append(": "); message.append(habbo.getHabboInfo().getRank().getName()); 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 d1e1ed5a..31312dd7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java @@ -6,43 +6,35 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; -public class StalkCommand extends Command -{ - public StalkCommand() - { +public class StalkCommand extends Command { + public StalkCommand() { super("cmd_stalk", Emulator.getTexts().getValue("commands.keys.cmd_stalk").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) return true; - if(params.length >= 2) - { + if (params.length >= 2) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(habbo.getHabboInfo().getCurrentRoom() == null) - { + if (habbo.getHabboInfo().getCurrentRoom() == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(gameClient.getHabbo().getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) - { + if (gameClient.getHabbo().getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_stalk.self").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) - { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_stalk.same_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -50,9 +42,7 @@ public class StalkCommand extends Command gameClient.sendResponse(new RoomDataComposer(habbo.getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false)); //gameClient.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId())); return true; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), 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 75b6c27e..727d3fe2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java @@ -5,41 +5,33 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.rooms.HideDoorbellComposer; -public class SummonCommand extends Command -{ - public SummonCommand() - { +public class SummonCommand extends Command { + public SummonCommand() { super("cmd_summon", Emulator.getTexts().getValue("commands.keys.cmd_summon").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) return true; - if(params.length >= 2) - { + if (params.length >= 2) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(gameClient.getHabbo().getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) - { + if (gameClient.getHabbo().getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.self").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) - { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.same_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -56,17 +48,14 @@ public class SummonCommand extends Command RoomTile t = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if(t != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().tileWalkable(t)) - { + if (t != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().tileWalkable(t)) { habbo.getRoomUnit().setGoalLocation(t); } habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername())); return true; - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java index ac516aa0..8dd8a070 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java @@ -8,35 +8,26 @@ import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import java.util.Map; -public class SummonRankCommand extends Command -{ - public SummonRankCommand() - { +public class SummonRankCommand extends Command { + public SummonRankCommand() { super("cmd_summonrank", Emulator.getTexts().getValue("commands.keys.cmd_summonrank").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { int minRank; - if(params.length >= 2) - { - try - { + if (params.length >= 2) { + try { minRank = Integer.valueOf(params[1]); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summonrank.error"), RoomChatMessageBubbles.ALERT); return true; } - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { - if(set.getValue().getHabboInfo().getRank().getId() >= minRank) - { - if(set.getValue() == gameClient.getHabbo()) + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + if (set.getValue().getHabboInfo().getRank().getId() >= minRank) { + if (set.getValue() == gameClient.getHabbo()) continue; if (set.getValue().getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom()) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SuperPullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SuperPullCommand.java index dc719820..edb29eae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SuperPullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SuperPullCommand.java @@ -9,38 +9,27 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; -public class SuperPullCommand extends Command -{ - public SuperPullCommand() - { +public class SuperPullCommand extends Command { + public SuperPullCommand() { super("cmd_superpull", Emulator.getTexts().getValue("commands.keys.cmd_superpull").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else if(habbo == gameClient.getHabbo()) - { + } else if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT); return true; - } - else - { + } else { RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tile != null && tile.isWalkable()) - { - if (tile == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile()) - { + if (tile != null && tile.isWalkable()) { + if (tile == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_pull.invalid").replace("%username%", params[1]), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java index 1d1a0411..8f9d8968 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java @@ -8,60 +8,46 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; -public class SuperbanCommand extends Command -{ - public SuperbanCommand() - { +public class SuperbanCommand extends Command { + public SuperbanCommand() { super("cmd_super_ban", Emulator.getTexts().getValue("commands.keys.cmd_super_ban").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { HabboInfo habbo = null; StringBuilder reason = new StringBuilder(); - if (params.length >= 2) - { + if (params.length >= 2) { Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if (h != null) - { + if (h != null) { habbo = h.getHabboInfo(); - } - else - { + } else { habbo = HabboManager.getOfflineHabboInfo(params[1]); } } - if (params.length > 2) - { - for (int i = 2; i < params.length; i++) - { + if (params.length > 2) { + for (int i = 2; i < params.length; i++) { reason.append(params[i]); reason.append(" "); } } - + int count; - if (habbo != null) - { - if (habbo == gameClient.getHabbo().getHabboInfo()) - { + if (habbo != null) { + if (habbo == gameClient.getHabbo().getHabboInfo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_super_ban.ban_self"), RoomChatMessageBubbles.ALERT); return true; } - if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) - { + if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT); return true; } count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.SUPER, -1).size(); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/TakeBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/TakeBadgeCommand.java index 4990075f..8241d517 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TakeBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TakeBadgeCommand.java @@ -9,47 +9,37 @@ import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer; import com.eu.habbo.messages.outgoing.users.UserBadgesComposer; -public class TakeBadgeCommand extends Command -{ - public TakeBadgeCommand() - { +public class TakeBadgeCommand extends Command { + public TakeBadgeCommand() { super("cmd_take_badge", Emulator.getTexts().getValue("commands.keys.cmd_take_badge").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length == 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.forgot_badge"), RoomChatMessageBubbles.ALERT); return true; - } - else if ( params.length == 1) - { + } else if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } - if (params.length == 3) - { + if (params.length == 3) { String username = params[1]; String badge = params[2]; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if (habbo != null) - { + if (habbo != null) { HabboBadge b = habbo.getInventory().getBadgesComponent().removeBadge(badge); - if (b == null) - { + if (b == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.no_badge").replace("%username%", username).replace("%badge%", badge), RoomChatMessageBubbles.ALERT); return true; } habbo.getClient().sendResponse(new InventoryBadgesComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) - { + if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/TeleportCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/TeleportCommand.java index 8fa7e7e0..4a79e88c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TeleportCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TeleportCommand.java @@ -4,29 +4,23 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class TeleportCommand extends Command -{ - public TeleportCommand() - { +public class TeleportCommand extends Command { + public TeleportCommand() { super("cmd_teleport", Emulator.getTexts().getValue("commands.keys.cmd_teleport").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled - if(gameClient.getHabbo().getRoomUnit().cmdTeleport) - { - gameClient.getHabbo().getRoomUnit().cmdTeleport = false; - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.disabled"), RoomChatMessageBubbles.ALERT); - return true; - } - else - { - gameClient.getHabbo().getRoomUnit().cmdTeleport = true; - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.enabled"), RoomChatMessageBubbles.ALERT); - return true; - } + if (gameClient.getHabbo().getRoomUnit().cmdTeleport) { + gameClient.getHabbo().getRoomUnit().cmdTeleport = false; + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.disabled"), RoomChatMessageBubbles.ALERT); + return true; + } else { + gameClient.getHabbo().getRoomUnit().cmdTeleport = true; + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.enabled"), 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 5f3ffe0b..16e15769 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java @@ -44,44 +44,36 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -public class TestCommand extends Command -{ +public class TestCommand extends Command { public static boolean stopThreads = true; - public TestCommand() - { - super("acc_debug", new String[]{ "test" }); + public TestCommand() { + super("acc_debug", new String[]{"test"}); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { if (true) return true; - if (params[1].equalsIgnoreCase("ut")) - { + if (params[1].equalsIgnoreCase("ut")) { RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); return true; } - if (params[1].equalsIgnoreCase("clients")) - { + if (params[1].equalsIgnoreCase("clients")) { System.out.println(Emulator.getGameServer().getGameClientManager().getSessions().size()); } - if (params[1].equalsIgnoreCase("queue")) - { + if (params[1].equalsIgnoreCase("queue")) { gameClient.sendResponse(new RoomQueueStatusMessage()); return true; } - if (params[1].equalsIgnoreCase("public")) - { + if (params[1].equalsIgnoreCase("public")) { gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPublicRoom(true); return true; } - if (params[1].equalsIgnoreCase("randtel")) - { + if (params[1].equalsIgnoreCase("randtel")) { RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getRandomWalkableTile(); gameClient.getHabbo().getRoomUnit().setCurrentLocation(tile); gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); @@ -89,55 +81,46 @@ public class TestCommand extends Command return true; } - if (params[1].equals("ach")) - { + if (params[1].equals("ach")) { AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Jogger"), 1000); return true; } - if (params[1].equals("asddsa")) - { + if (params[1].equals("asddsa")) { gameClient.getHabbo().getHabboStats().addAchievementScore(1000); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(gameClient.getHabbo()).compose()); return true; } - if (params[1].equals("gc")) - { + if (params[1].equals("gc")) { Emulator.getGameServer().getPacketManager().registerHandler(Incoming.GameCenterRequestGamesEvent, GameCenterRequestGamesEvent.class); Emulator.getGameServer().getPacketManager().registerHandler(Incoming.GameCenterRequestAccountStatusEvent, GameCenterRequestAccountStatusEvent.class); return true; } - if (params[1].equals("namechange")) - { + if (params[1].equals("namechange")) { gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo())); return true; } //Emulator.getGameEnvironment().getRoomManager().clearInactiveRooms(); //gameClient.sendResponse(new RoomDataComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false)); - if (params[1].equals("uach")) - { + if (params[1].equals("uach")) { Emulator.getGameEnvironment().getAchievementManager().reload(); } - if(params[1].equals("units")) - { + if (params[1].equals("units")) { StringBuilder s = new StringBuilder(); - for(Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) - { + for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { s.append("Habbo ID: ").append(habbo.getHabboInfo().getId()).append(", RoomUnit ID: ").append(habbo.getRoomUnit().getId()).append("\r"); } - for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) - { + for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) { s.append("Pet ID: ").append(pet.getId()).append(", RoomUnit ID: ").append(pet.getRoomUnit().getId()).append(", Name: ").append(pet.getName()); - if (pet instanceof MonsterplantPet) - { + if (pet instanceof MonsterplantPet) { s.append(", B:").append(((MonsterplantPet) pet).canBreed() ? "Y" : "N").append(", PB: ").append(((MonsterplantPet) pet).isPubliclyBreedable() ? "Y" : "N").append(", D: ").append(((MonsterplantPet) pet).isDead() ? "Y" : "N"); } @@ -148,12 +131,9 @@ public class TestCommand extends Command return true; } - if (params[1].equalsIgnoreCase("rebr")) - { - for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) - { - if (pet instanceof MonsterplantPet) - { + if (params[1].equalsIgnoreCase("rebr")) { + for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) { + if (pet instanceof MonsterplantPet) { ((MonsterplantPet) pet).setPubliclyBreedable(false); ((MonsterplantPet) pet).setCanBreed(true); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); @@ -164,12 +144,10 @@ public class TestCommand extends Command return true; } - if (params[1].equalsIgnoreCase("bots")) - { + if (params[1].equalsIgnoreCase("bots")) { StringBuilder message = new StringBuilder(); - for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) - { + for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) { message.append("Name: ").append(bot.getName()).append(", ID: ").append(bot.getId()).append(", RID: ").append(bot.getRoomUnit().getId()).append(", Rot: ").append(bot.getRoomUnit().getBodyRotation()).append("\r"); } @@ -177,88 +155,66 @@ public class TestCommand extends Command return true; } - if (params[1].equalsIgnoreCase("packu")) - { + if (params[1].equalsIgnoreCase("packu")) { Emulator.getGameServer().getPacketManager().registerHandler(Incoming.MovePetEvent, MovePetEvent.class); return true; } - if(params[1].equals("a")) - { + if (params[1].equals("a")) { int count = Integer.valueOf(params[2]); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { gameClient.getHabbo().whisper("" + i, RoomChatMessageBubbles.getBubble(i)); } return true; - } - else if(params[1].equals("b")) - { - try - { + } else if (params[1].equals("b")) { + try { int itemId = Integer.valueOf(params[2]); HabboItem item = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item != null) - { + if (item != null) { item.setExtradata(params[3]); gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); } - } - catch (Exception e) - { + } catch (Exception e) { } return true; - } - else if(params[1].equalsIgnoreCase("pet")) - { + } else if (params[1].equalsIgnoreCase("pet")) { Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2])); - if(pet != null) - { + if (pet != null) { String a; String b = ""; String c = ""; - if(params[3] != null) - { + if (params[3] != null) { a = params[3]; - if(params.length > 4) - { + if (params.length > 4) { b = params[4]; } - if(params.length > 5) - { + if (params.length > 5) { c = params[5]; } pet.getRoomUnit().setStatus(RoomUnitStatus.fromString(a), b + " " + c); gameClient.sendResponse(new RoomUserStatusComposer(pet.getRoomUnit())); } } - } - else if (params[1].equalsIgnoreCase("petc")) - { + } else if (params[1].equalsIgnoreCase("petc")) { Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2])); - if (pet != null) - { + if (pet != null) { pet.getRoomUnit().clearStatus(); gameClient.sendResponse(new RoomUserStatusComposer(pet.getRoomUnit())); } - } - else if (params[1].equalsIgnoreCase("rand")) - { + } else if (params[1].equalsIgnoreCase("rand")) { Map results = new HashMap<>(); - for (int i = 0; i < Integer.valueOf(params[2]); i++) - { + for (int i = 0; i < Integer.valueOf(params[2]); i++) { int random = PetManager.random(0, 12, Double.valueOf(params[3])); - if (!results.containsKey(random)) - { + if (!results.containsKey(random)) { results.put(random, 0); } @@ -267,86 +223,59 @@ public class TestCommand extends Command StringBuilder result = new StringBuilder("Results : " + params[2] + "

"); - for (Map.Entry set : results.entrySet()) - { + for (Map.Entry set : results.entrySet()) { result.append(set.getKey()).append(" -> ").append(set.getValue()).append("
"); } gameClient.sendResponse(new GenericAlertComposer(result.toString())); - } - else if (params[1].equalsIgnoreCase("threads")) - { - if (stopThreads) - { + } else if (params[1].equalsIgnoreCase("threads")) { + if (stopThreads) { stopThreads = false; - for (int i = 0; i < 30; i++) - { + for (int i = 0; i < 30; i++) { final int finalI = i; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - try - { + public void run() { + try { Thread.sleep(500); Emulator.getLogging().logStart("Started " + finalI + " on " + Thread.currentThread().getName()); - if (!TestCommand.stopThreads) - { + if (!TestCommand.stopThreads) { Emulator.getThreading().run(this); } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } }, i * 10); } - } - else - { + } else { stopThreads = true; } - } - else if (params[1].equalsIgnoreCase("pethere")) - { + } else if (params[1].equalsIgnoreCase("pethere")) { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); List tiles = room.getLayout().getTilesAround(gameClient.getHabbo().getRoomUnit().getCurrentLocation()); - room.getCurrentPets().forEachValue(new TObjectProcedure() - { + room.getCurrentPets().forEachValue(new TObjectProcedure() { @Override - public boolean execute(Pet object) - { - Emulator.getThreading().run(new Runnable() - { + public boolean execute(Pet object) { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { object.getRoomUnit().setGoalLocation(tiles.get(Emulator.getRandom().nextInt(tiles.size()))); } }); return true; } }); - } - else if(params[1].equalsIgnoreCase("st")) - { + } else if (params[1].equalsIgnoreCase("st")) { gameClient.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.fromString(params[2]), params[3]); gameClient.sendResponse(new RoomUserStatusComposer(gameClient.getHabbo().getRoomUnit())); - } - else if (params[1].equalsIgnoreCase("filt")) - { + } else if (params[1].equalsIgnoreCase("filt")) { gameClient.sendResponse(new GenericAlertComposer(Normalizer.normalize(params[2], Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").replaceAll("\\p{M}", ""))); - } - else if (params[1].equalsIgnoreCase("nux")) - { - gameClient.sendResponse(new MessageComposer() - { + } else if (params[1].equalsIgnoreCase("nux")) { + gameClient.sendResponse(new MessageComposer() { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewUserGiftComposer); this.response.appendInt(1); //? @@ -395,79 +324,57 @@ public class TestCommand extends Command return this.response; } }); - } - else if (params[1].equals("adv")) - { - } - else if (params[1].equals("datb")) - { - long millis; - long diff = 1; - try(Connection conn = Emulator.getDatabase().getDataSource().getConnection()) - { - millis = System.currentTimeMillis(); - for (long i = 0; i < 1000000; i++) - { - try (PreparedStatement stmt = conn.prepareStatement("SELECT 1")) - { - //PreparedStatement stmt2 = conn.prepareStatement("SELECT 2"); - stmt.close(); - } - //stmt2.close(); - } - diff = System.currentTimeMillis() - millis; + } else if (params[1].equals("adv")) { + } else if (params[1].equals("datb")) { + long millis; + long diff = 1; + try (Connection conn = Emulator.getDatabase().getDataSource().getConnection()) { + millis = System.currentTimeMillis(); + for (long i = 0; i < 1000000; i++) { + try (PreparedStatement stmt = conn.prepareStatement("SELECT 1")) { + //PreparedStatement stmt2 = conn.prepareStatement("SELECT 2"); + stmt.close(); } - catch (Exception e) - { - e.printStackTrace(); - } - System.out.println("Difference " + (diff) + "MS. ops: " + ((long)1000000 / diff) + " ops/MS"); + //stmt2.close(); + } + diff = System.currentTimeMillis() - millis; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Difference " + (diff) + "MS. ops: " + ((long) 1000000 / diff) + " ops/MS"); - } - else - { - try - { + } else { + try { int header = Integer.valueOf(params[1]); ServerMessage message = new ServerMessage(header); - for (int i = 1; i < params.length; i++) - { + for (int i = 1; i < params.length; i++) { String[] data = params[i].split(":"); - if (data[0].equalsIgnoreCase("b")) - { + if (data[0].equalsIgnoreCase("b")) { message.appendBoolean(data[1].equalsIgnoreCase("1")); - } else if (data[0].equalsIgnoreCase("s")) - { - if (data.length > 1) - { + } else if (data[0].equalsIgnoreCase("s")) { + if (data.length > 1) { message.appendString(data[1].replace("%http%", "http://")); - } else - { + } else { message.appendString(""); } - } else if (data[0].equals("i")) - { + } else if (data[0].equals("i")) { message.appendInt(Integer.valueOf(data[1])); - } else if (data[0].equalsIgnoreCase("by")) - { + } else if (data[0].equalsIgnoreCase("by")) { message.appendByte(Integer.valueOf(data[1])); - } else if (data[0].equalsIgnoreCase("sh")) - { + } else if (data[0].equalsIgnoreCase("sh")) { message.appendShort(Integer.valueOf(data[1])); } } Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo("Admin"); - if(habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(message); } - } catch (Exception e) - { + } catch (Exception e) { gameClient.sendResponse(new GenericAlertComposer("Hey, what u doing m8.")); return false; @@ -475,7 +382,6 @@ public class TestCommand extends Command } - //if(params.length >= 2) //{ @@ -499,8 +405,7 @@ public class TestCommand extends Command return true; } - public void testConcurrentClose() throws Exception - { + public void testConcurrentClose() throws Exception { HikariConfig config = new HikariConfig(); config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource"); 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 285dcc96..39feb7c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TransformCommand.java @@ -12,59 +12,46 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import java.util.ArrayList; import java.util.Collections; -public class TransformCommand extends Command -{ - protected TransformCommand() - { +public class TransformCommand extends Command { + protected TransformCommand() { super("cmd_transform", new String[]{"transform"}); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { StringBuilder petNames = new StringBuilder(); petNames.append(Emulator.getTexts().getValue("commands.generic.cmd_transform.title")); petNames.append("\r------------------------------------------------------------------------------\r"); ArrayList petData = new ArrayList<>(Emulator.getGameEnvironment().getPetManager().getPetData()); Collections.sort(petData); String line = Emulator.getTexts().getValue("commands.generic.cmd_transform.line"); - for (PetData p : petData) - { + for (PetData p : petData) { petNames.append(line.replace("%id%", p.getType() + "").replace("%name%", p.getName())).append("\r"); } gameClient.sendResponse(new MessagesForYouComposer(new String[]{petNames.toString()})); return true; - } - else - { + } else { String petName = params[1]; PetData petData = Emulator.getGameEnvironment().getPetManager().getPetData(petName); int race = 0; - if (params.length >= 3) - { - try - { + if (params.length >= 3) { + try { race = Integer.valueOf(params[2]); - } - catch (Exception e) - { + } catch (Exception e) { return true; } } String color = "FFFFFF"; - if (params.length >= 4) - { + if (params.length >= 4) { color = params[3]; } - if (petData != null) - { + if (petData != null) { RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit(); roomUnit.setRoomUnitType(RoomUnitType.PET); gameClient.getHabbo().getHabboStats().cache.put("pet_type", petData); @@ -72,9 +59,7 @@ public class TransformCommand extends Command gameClient.getHabbo().getHabboStats().cache.put("pet_color", color); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRemoveComposer(gameClient.getHabbo().getRoomUnit()).compose()); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose()); - } - else - { + } else { //Pet Not Found return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/TrashCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/TrashCommand.java index 733fa80e..196fecce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TrashCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TrashCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class TrashCommand extends Command -{ - public TrashCommand() - { +public class TrashCommand extends Command { + public TrashCommand() { super("cmd_trash", Emulator.getTexts().getValue("commands.keys.cmd_trash").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { gameClient.getHabbo().whisper("Sorry. Lulz mode removed |"); return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UnbanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UnbanCommand.java index 42b0eb16..dea44bd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UnbanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UnbanCommand.java @@ -4,28 +4,19 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UnbanCommand extends Command -{ - public UnbanCommand() - { +public class UnbanCommand extends Command { + public UnbanCommand() { super("cmd_unban", Emulator.getTexts().getValue("commands.keys.cmd_unban").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unban.not_specified"), RoomChatMessageBubbles.ALERT); - } - else - { - if(Emulator.getGameEnvironment().getModToolManager().unban(params[1])) - { + } else { + if (Emulator.getGameEnvironment().getModToolManager().unban(params[1])) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unban.success").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unban.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UnloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UnloadRoomCommand.java index 3d6cd9b7..8082401c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UnloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UnloadRoomCommand.java @@ -6,16 +6,13 @@ import com.eu.habbo.habbohotel.rooms.Room; public class UnloadRoomCommand extends Command { - public UnloadRoomCommand() - { + public UnloadRoomCommand() { super("cmd_unload", Emulator.getTexts().getValue("commands.keys.cmd_unload").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() == gameClient.getHabbo().getHabboInfo().getId() || gameClient.getHabbo().getHabboInfo().getRank().getId() > 4) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() == gameClient.getHabbo().getHabboInfo().getId() || gameClient.getHabbo().getHabboInfo().getRank().getId() > 4) { Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); room.dispose(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java index 7be27bfa..9e88bd8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java @@ -5,47 +5,35 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -public class UnmuteCommand extends Command -{ - public UnmuteCommand() - { +public class UnmuteCommand extends Command { + public UnmuteCommand() { super("cmd_unmute", Emulator.getTexts().getValue("commands.keys.cmd_unmute").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length == 1) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length == 1) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_specified"), RoomChatMessageBubbles.ALERT); return true; } Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; - } - else - { - if (!habbo.getHabboStats().allowTalk() || habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) - { - if (!habbo.getHabboStats().allowTalk()) - { + } else { + if (!habbo.getHabboStats().allowTalk() || habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { + if (!habbo.getHabboStats().allowTalk()) { habbo.unMute(); } - if (habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) - { + if (habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1); } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_unmute").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - } - else - { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_muted").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateAchievements.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateAchievements.java index 37294f80..70dc56fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateAchievements.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateAchievements.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdateAchievements extends Command -{ - public UpdateAchievements() - { +public class UpdateAchievements extends Command { + public UpdateAchievements() { super("cmd_update_achievements", Emulator.getTexts().getValue("commands.keys.cmd_update_achievements").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getAchievementManager().reload(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_achievements.updated"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateBotsCommand.java index 5d6d74f0..eaf57e94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateBotsCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class UpdateBotsCommand extends Command -{ - public UpdateBotsCommand() - { +public class UpdateBotsCommand extends Command { + public UpdateBotsCommand() { super("cmd_update_bots", Emulator.getTexts().getValue("commands.keys.cmd_update_bots").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { return Emulator.getGameEnvironment().getBotManager().reload(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCatalogCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCatalogCommand.java index 87209c75..730fd4a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCatalogCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCatalogCommand.java @@ -8,13 +8,12 @@ import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigCompo public class UpdateCatalogCommand extends Command { - public UpdateCatalogCommand() - { + public UpdateCatalogCommand() { super("cmd_update_catalogue", Emulator.getTexts().getValue("commands.keys.cmd_update_catalogue").split(";")); } + @Override - public boolean handle(GameClient gameClient, String[] params) - { + public boolean handle(GameClient gameClient, String[] params) { Emulator.getGameEnvironment().getCatalogManager().initialize(); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new CatalogUpdatedComposer()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new CatalogModeComposer(0)); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateConfigCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateConfigCommand.java index f46e901d..7b859cd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateConfigCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateConfigCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdateConfigCommand extends Command -{ - public UpdateConfigCommand() - { +public class UpdateConfigCommand extends Command { + public UpdateConfigCommand() { super("cmd_update_config", Emulator.getTexts().getValue("commands.keys.cmd_update_config").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getConfig().reload(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_config"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateGuildPartsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateGuildPartsCommand.java index 4aedbfe1..b7b47a91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateGuildPartsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateGuildPartsCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class UpdateGuildPartsCommand extends Command -{ - public UpdateGuildPartsCommand() - { +public class UpdateGuildPartsCommand extends Command { + public UpdateGuildPartsCommand() { super("cmd_update_guildparts", Emulator.getTexts().getValue("commands.keys.cmd_update_guildparts").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getGuildManager().loadGuildParts(); Emulator.getBadgeImager().reload(); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateHotelViewCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateHotelViewCommand.java index a9a5aae5..88f9c606 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateHotelViewCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateHotelViewCommand.java @@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class UpdateHotelViewCommand extends Command -{ - protected UpdateHotelViewCommand() - { +public class UpdateHotelViewCommand extends Command { + protected UpdateHotelViewCommand() { super("cmd_update_hotel_view", Emulator.getTexts().getValue("commands.keys.cmd_update_hotel_view").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getHotelViewManager().getNewsList().reload(); Emulator.getGameEnvironment().getHotelViewManager().getHallOfFame().reload(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java index fdbb35b6..a827507d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java @@ -6,31 +6,25 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.messages.outgoing.rooms.RoomRelativeMapComposer; -public class UpdateItemsCommand extends Command -{ - public UpdateItemsCommand() - { +public class UpdateItemsCommand extends Command { + public UpdateItemsCommand() { super("cmd_update_items", Emulator.getTexts().getValue("commands.keys.cmd_update_items").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getItemManager().loadItems(); Emulator.getGameEnvironment().getItemManager().loadCrackable(); Emulator.getGameEnvironment().getItemManager().loadSoundTracks(); - synchronized (Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) - { - for (Room room : Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) - { - if (room.isLoaded() && room.getUserCount() > 0) - { + synchronized (Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) { + for (Room room : Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) { + if (room.isLoaded() && room.getUserCount() > 0) { room.sendComposer(new RoomRelativeMapComposer(room).compose()); } } } - + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_items"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java index 14678f03..ee3b5f9a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdateNavigatorCommand extends Command -{ - public UpdateNavigatorCommand() - { +public class UpdateNavigatorCommand extends Command { + public UpdateNavigatorCommand() { super("cmd_update_navigator", Emulator.getTexts().getValue("commands.keys.cmd_update_navigator").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getNavigatorManager().loadNavigator(); Emulator.getGameEnvironment().getRoomManager().loadRoomModels(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePermissionsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePermissionsCommand.java index e8016a32..9f257bdd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePermissionsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePermissionsCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdatePermissionsCommand extends Command -{ - public UpdatePermissionsCommand() - { +public class UpdatePermissionsCommand extends Command { + public UpdatePermissionsCommand() { super("cmd_update_permissions", Emulator.getTexts().getValue("commands.keys.cmd_update_permissions").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getPermissionsManager().reload(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_permissions"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePetDataCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePetDataCommand.java index 13d9ec67..5d07e2d1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePetDataCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePetDataCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdatePetDataCommand extends Command -{ - public UpdatePetDataCommand() - { +public class UpdatePetDataCommand extends Command { + public UpdatePetDataCommand() { super("cmd_update_pet_data", Emulator.getTexts().getValue("commands.keys.cmd_update_pet_data").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getPetManager().reloadPetData(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_pet_data"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePluginsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePluginsCommand.java index ce41aea9..285d98d9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePluginsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePluginsCommand.java @@ -4,15 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdatePluginsCommand extends Command -{ - public UpdatePluginsCommand() - { +public class UpdatePluginsCommand extends Command { + public UpdatePluginsCommand() { super("cmd_update_plugins", Emulator.getTexts().getValue("commands.keys.cmd_update_plugins").split(";")); } + @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getPluginManager().reload(); gameClient.getHabbo().whisper("This is an unsafe command and could possibly lead to memory leaks.\rIt is recommended to restart the emulator in order to reload plugins."); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePollsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePollsCommand.java index 9ca727b9..c82e2d5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePollsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdatePollsCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdatePollsCommand extends Command -{ - public UpdatePollsCommand() - { +public class UpdatePollsCommand extends Command { + public UpdatePollsCommand() { super("cmd_update_polls", Emulator.getTexts().getValue("commands.keys.cmd_update_polls").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getPollManager().loadPolls(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_polls"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateTextsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateTextsCommand.java index ebd11a97..a8a68b9a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateTextsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateTextsCommand.java @@ -4,24 +4,18 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdateTextsCommand extends Command -{ - public UpdateTextsCommand() - { +public class UpdateTextsCommand extends Command { + public UpdateTextsCommand() { super("cmd_update_texts", Emulator.getTexts().getValue("commands.keys.cmd_update_texts").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - try - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + try { Emulator.getTexts().reload(); Emulator.getGameEnvironment().getCommandHandler().reloadCommands(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_texts"), RoomChatMessageBubbles.ALERT); - } - catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_update_texts.failed"), RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateWordFilterCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateWordFilterCommand.java index b978415c..ad70f802 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateWordFilterCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateWordFilterCommand.java @@ -4,16 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -public class UpdateWordFilterCommand extends Command -{ - public UpdateWordFilterCommand() - { +public class UpdateWordFilterCommand extends Command { + public UpdateWordFilterCommand() { super("cmd_update_wordfilter", Emulator.getTexts().getValue("commands.keys.update_wordfilter").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { Emulator.getGameEnvironment().getWordFilter().reload(); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_wordfilter"), RoomChatMessageBubbles.ALERT); 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 e13c8538..88d25872 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java @@ -7,24 +7,19 @@ 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.messages.outgoing.generic.alerts.GenericAlertComposer; import gnu.trove.iterator.TIntIntIterator; import java.text.SimpleDateFormat; import java.util.*; -public class UserInfoCommand extends Command -{ - public UserInfoCommand() - { +public class UserInfoCommand extends Command { + public UserInfoCommand() { super("cmd_userinfo", Emulator.getTexts().getValue("commands.keys.cmd_userinfo").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if(params.length < 2) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 2) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_userinfo.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } @@ -32,13 +27,11 @@ public class UserInfoCommand extends Command Habbo onlineHabbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); HabboInfo habbo = (onlineHabbo != null ? onlineHabbo.getHabboInfo() : null); - if(habbo == null) - { + if (habbo == null) { habbo = HabboManager.getOfflineHabboInfo(params[1]); } - if(habbo == null) - { + if (habbo == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_userinfo.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -58,8 +51,7 @@ public class UserInfoCommand extends Command message.append(Emulator.getTexts().getValue("command.cmd_userinfo.total_bans")).append(": ").append(Emulator.getGameEnvironment().getModToolManager().totalBans(habbo.getId())).append("\r"); message.append(Emulator.getTexts().getValue("command.cmd_userinfo.banned")).append(": ").append(Emulator.getTexts().getValue(ban != null ? "generic.yes" : "generic.no")).append("\r\r"); - if (ban != null) - { + if (ban != null) { message.append("").append(Emulator.getTexts().getValue("command.cmd_userinfo.ban_info")).append("\r"); message.append(ban.listInfo()).append("\r"); } @@ -68,14 +60,10 @@ public class UserInfoCommand extends Command message.append(Emulator.getTexts().getValue("command.cmd_userinfo.credits")).append(": ").append(habbo.getCredits()).append("\r"); TIntIntIterator iterator = habbo.getCurrencies().iterator(); - for(int i = habbo.getCurrencies().size(); i-- > 0;) - { - try - { + for (int i = habbo.getCurrencies().size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } @@ -85,25 +73,20 @@ public class UserInfoCommand extends Command SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3); - if (!nameChanges.isEmpty()) - { + if (!nameChanges.isEmpty()) { message.append("\rLatest name changes:
"); - for (Map.Entry entry : nameChanges) - { + for (Map.Entry entry : nameChanges) { message.append(format.format(new Date((long) entry.getKey() * 1000L))).append(" : ").append(entry.getValue()).append("
"); } } - if(onlineHabbo != null) - { + if (onlineHabbo != null) { message.append("\r" + "Other accounts ("); ArrayList users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10); - users.sort(new Comparator() - { + users.sort(new Comparator() { @Override - public int compare(HabboInfo o1, HabboInfo o2) - { + public int compare(HabboInfo o1, HabboInfo o2) { return o1.getId() - o2.getId(); } }); @@ -113,12 +96,11 @@ public class UserInfoCommand extends Command message.append("Username,\tID,\tDate register,\tDate last online\r"); - for(HabboInfo info : users) - { + for (HabboInfo info : users) { message.append(info.getUsername()).append(",\t").append(info.getId()).append(",\t").append(format.format(new Date((long) info.getAccountCreated() * 1000L))).append(",\t").append(format.format(new Date((long) info.getLastOnline() * 1000L))).append("\r"); } } - gameClient.getHabbo().alert(message.toString()); + gameClient.getHabbo().alert(message.toString()); return true; } 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 a01f718d..09a6c4dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/WordQuizCommand.java @@ -3,39 +3,28 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -public class WordQuizCommand extends Command -{ - public WordQuizCommand() - { +public class WordQuizCommand extends Command { + public WordQuizCommand() { super("cmd_word_quiz", Emulator.getTexts().getValue("commands.keys.cmd_word_quiz").split(";")); } @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception - { - if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) - { + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) { StringBuilder question = new StringBuilder(); int duration = 60; - if (params.length > 2) - { - for (int i = 1; i < params.length - 1; i++) - { + if (params.length > 2) { + for (int i = 1; i < params.length - 1; i++) { question.append(" ").append(params[i]); } - try - { + try { duration = Integer.valueOf(params[params.length - 1]); - } - catch (Exception e) - { + } catch (Exception e) { question.append(" ").append(params[params.length - 1]); } - } - else - { + } else { question = new StringBuilder(params[1]); } diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingAltar.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingAltar.java index 3dfee1a4..dc7dcda6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingAltar.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingAltar.java @@ -10,61 +10,49 @@ import java.util.Collection; import java.util.List; import java.util.Map; -public class CraftingAltar -{ +public class CraftingAltar { private final Item baseItem; private final THashSet ingredients; private final THashMap recipes; - public CraftingAltar(Item baseItem) - { - this.baseItem = baseItem; + public CraftingAltar(Item baseItem) { + this.baseItem = baseItem; this.ingredients = new THashSet<>(1); - this.recipes = new THashMap<>(1); + this.recipes = new THashMap<>(1); } - public void addIngredient(Item item) - { + public void addIngredient(Item item) { this.ingredients.add(item); } - public boolean hasIngredient(Item item) - { + public boolean hasIngredient(Item item) { return this.ingredients.contains(item); } - public Map matchRecipes(Map amountMap) - { + public Map matchRecipes(Map amountMap) { THashMap foundRecepies = new THashMap<>(Math.max(1, this.recipes.size() / 3)); - for (Map.Entry set : this.recipes.entrySet()) - { + for (Map.Entry set : this.recipes.entrySet()) { boolean contains = true; boolean equals; - if (set.getValue().isLimited() && !set.getValue().canBeCrafted()) - { + if (set.getValue().isLimited() && !set.getValue().canBeCrafted()) { continue; } equals = amountMap.size() == set.getValue().getIngredients().size(); - for (Map.Entry entry : amountMap.entrySet()) - { - if (contains) - { - if (set.getValue().getIngredients().containsKey(entry.getKey())) - { - if (set.getValue().getIngredients().get(entry.getKey()).equals(entry.getValue())) - { + for (Map.Entry entry : amountMap.entrySet()) { + if (contains) { + if (set.getValue().getIngredients().containsKey(entry.getKey())) { + if (set.getValue().getIngredients().get(entry.getKey()).equals(entry.getValue())) { continue; } equals = false; - if (set.getValue().getIngredients().get(entry.getKey()) > entry.getValue()) - { + if (set.getValue().getIngredients().get(entry.getKey()) > entry.getValue()) { continue; } } @@ -73,8 +61,7 @@ public class CraftingAltar } } - if (contains) - { + if (contains) { foundRecepies.put(set.getValue(), equals); } } @@ -83,22 +70,17 @@ public class CraftingAltar } - public void addRecipe(CraftingRecipe recipe) - { + public void addRecipe(CraftingRecipe recipe) { this.recipes.put(recipe.getId(), recipe); } - public CraftingRecipe getRecipe(int id) - { + public CraftingRecipe getRecipe(int id) { return this.recipes.get(id); } - public CraftingRecipe getRecipe(String name) - { - for (Map.Entry set : this.recipes.entrySet()) - { - if (set.getValue().getName().equals(name)) - { + public CraftingRecipe getRecipe(String name) { + for (Map.Entry set : this.recipes.entrySet()) { + if (set.getValue().getName().equals(name)) { return set.getValue(); } } @@ -106,23 +88,18 @@ public class CraftingAltar return null; } - public CraftingRecipe getRecipe(Map items) - { - for (Map.Entry set : this.recipes.entrySet()) - { + public CraftingRecipe getRecipe(Map items) { + for (Map.Entry set : this.recipes.entrySet()) { CraftingRecipe recipe = set.getValue(); - for (Map.Entry entry : recipe.getIngredients().entrySet()) - { - if (!(items.containsKey(entry.getKey()) && items.get(entry.getKey()).equals(entry.getValue()))) - { + for (Map.Entry entry : recipe.getIngredients().entrySet()) { + if (!(items.containsKey(entry.getKey()) && items.get(entry.getKey()).equals(entry.getValue()))) { recipe = null; break; } } - if (recipe != null) - { + if (recipe != null) { return recipe; } } @@ -130,14 +107,11 @@ public class CraftingAltar return null; } - public List getRecipesForHabbo(Habbo habbo) - { + public List getRecipesForHabbo(Habbo habbo) { List recipeList = new ArrayList<>(); - for (Map.Entry set : this.recipes.entrySet()) - { - if (!set.getValue().isSecret() || habbo.getHabboStats().hasRecipe(set.getValue().getId())) - { + for (Map.Entry set : this.recipes.entrySet()) { + if (!set.getValue().isSecret() || habbo.getHabboStats().hasRecipe(set.getValue().getId())) { recipeList.add(set.getValue()); } } @@ -145,18 +119,15 @@ public class CraftingAltar return recipeList; } - public Item getBaseItem() - { + public Item getBaseItem() { return this.baseItem; } - public Collection getIngredients() - { + public Collection getIngredients() { return this.ingredients; } - public Collection getRecipes() - { + public Collection getRecipes() { return this.recipes.values(); } } \ No newline at end of file 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 b40eb5a6..cdaded07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java @@ -10,88 +10,68 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class CraftingManager -{ +public class CraftingManager { private final THashMap altars; - public CraftingManager() - { + public CraftingManager() { this.altars = new THashMap<>(); this.reload(); } - public void reload() - { + public void reload() { this.dispose(); - 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")) - { - statement.setString(1, "1"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("altar_id")); + 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")) { + statement.setString(1, "1"); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("altar_id")); - if (item != null) - { - if (!this.altars.containsKey(item)) - { - this.altars.put(item, new CraftingAltar(item)); - } + if (item != null) { + if (!this.altars.containsKey(item)) { + this.altars.put(item, new CraftingAltar(item)); + } - CraftingAltar altar = this.altars.get(item); + CraftingAltar altar = this.altars.get(item); - if (altar != null) - { - CraftingRecipe recipe = altar.getRecipe(set.getInt("crafting_recipes_ingredients.recipe_id")); + if (altar != null) { + CraftingRecipe recipe = altar.getRecipe(set.getInt("crafting_recipes_ingredients.recipe_id")); - if (recipe == null) - { - recipe = new CraftingRecipe(set); - altar.addRecipe(recipe); - } + if (recipe == null) { + recipe = new CraftingRecipe(set); + altar.addRecipe(recipe); + } - Item ingredientItem = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("crafting_recipes_ingredients.item_id")); + Item ingredientItem = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("crafting_recipes_ingredients.item_id")); - if (ingredientItem != null) - { - recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount")); - altar.addIngredient(ingredientItem); - } - else - { - Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); - } - } - } - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } + if (ingredientItem != null) { + recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount")); + altar.addIngredient(ingredientItem); + } else { + Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); + } + } + } + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } } - public int getRecipesWithItemCount(final Item item) - { + public int getRecipesWithItemCount(final Item item) { final int[] i = {0}; - synchronized (this.altars) - { - this.altars.forEachValue(new TObjectProcedure() - { + synchronized (this.altars) { + this.altars.forEachValue(new TObjectProcedure() { @Override - public boolean execute(CraftingAltar altar) - { - if (altar.hasIngredient(item)) - { + public boolean execute(CraftingAltar altar) { + if (altar.hasIngredient(item)) { i[0]++; } @@ -103,50 +83,39 @@ public class CraftingManager return i[0]; } - public CraftingRecipe getRecipe(String recipeName) - { - CraftingRecipe recipe; - for (CraftingAltar altar : this.altars.values()) - { - recipe = altar.getRecipe(recipeName); + public CraftingRecipe getRecipe(String recipeName) { + CraftingRecipe recipe; + for (CraftingAltar altar : this.altars.values()) { + recipe = altar.getRecipe(recipeName); - if (recipe != null) - { - return recipe; - } - } + if (recipe != null) { + return recipe; + } + } return null; } - public CraftingAltar getAltar(Item item) - { + public CraftingAltar getAltar(Item item) { return this.altars.get(item); } - public void dispose() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE crafting_recipes SET remaining = ? WHERE id = ? LIMIT 1")) - { - for (CraftingAltar altar : this.altars.values()) - { - for (CraftingRecipe recipe : altar.getRecipes()) - { - if (recipe.isLimited()) - { - statement.setInt(1, recipe.getRemaining()); - statement.setInt(2, recipe.getId()); + public void dispose() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE crafting_recipes SET remaining = ? WHERE id = ? LIMIT 1")) { + for (CraftingAltar altar : this.altars.values()) { + for (CraftingRecipe recipe : altar.getRecipes()) { + if (recipe.isLimited()) { + statement.setInt(1, recipe.getRemaining()); + statement.setInt(2, recipe.getId()); - statement.addBatch(); - } - } - } - statement.executeBatch(); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } + statement.addBatch(); + } + } + } + statement.executeBatch(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(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 d2c66209..286dfb62 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java @@ -7,20 +7,17 @@ import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class CraftingRecipe -{ +public class CraftingRecipe { private final int id; private final String name; private final Item reward; private final boolean secret; private final String achievement; private final boolean limited; + private final THashMap ingredients; private int remaining; - private final THashMap ingredients; - - public CraftingRecipe(ResultSet set) throws SQLException - { + public CraftingRecipe(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("product_name"); this.reward = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("reward")); @@ -32,15 +29,12 @@ public class CraftingRecipe this.ingredients = new THashMap<>(); } - public boolean canBeCrafted() - { + public boolean canBeCrafted() { return !this.limited || this.remaining > 0; } - public synchronized boolean decrease() - { - if (this.remaining > 0) - { + public synchronized boolean decrease() { + if (this.remaining > 0) { this.remaining--; return true; } @@ -48,58 +42,47 @@ public class CraftingRecipe return false; } - public void addIngredient(Item item, int amount) - { + public void addIngredient(Item item, int amount) { this.ingredients.put(item, amount); } - public int getAmountNeeded(Item item) - { + public int getAmountNeeded(Item item) { return this.ingredients.get(item); } - public boolean hasIngredient(Item item) - { + public boolean hasIngredient(Item item) { return this.ingredients.containsKey(item); } - public int getId() - { + public int getId() { return this.id; } - public String getName() - { + public String getName() { return this.name; } - public Item getReward() - { + public Item getReward() { return this.reward; } - public boolean isSecret() - { + public boolean isSecret() { return this.secret; } - public String getAchievement() - { + public String getAchievement() { return this.achievement; } - public boolean isLimited() - { + public boolean isLimited() { return this.limited; } - public THashMap getIngredients() - { + public THashMap getIngredients() { return this.ingredients; } - public int getRemaining() - { + 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 6186ea4b..376f910c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -16,48 +16,34 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -public class GameClient -{ - - private final Channel channel; - - - private Habbo habbo; - - - private String machineId = ""; +public class GameClient { public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); + private final Channel channel; public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); + private Habbo habbo; + private String machineId = ""; - public GameClient(Channel channel) - { + public GameClient(Channel channel) { this.channel = channel; } - public void sendResponse(MessageComposer composer) - { - if(this.channel.isOpen()) - { - try - { + public void sendResponse(MessageComposer composer) { + if (this.channel.isOpen()) { + try { ServerMessage msg = composer.compose(); this.sendResponse(msg); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logPacketError(e); } } } - public void sendResponse(ServerMessage response) - { - if(this.channel.isOpen()) - { - if (response == null || response.getHeader() <= 0) - { + public void sendResponse(ServerMessage response) { + if (this.channel.isOpen()) { + if (response == null || response.getHeader() <= 0) { return; } @@ -70,16 +56,12 @@ public class GameClient } - public void sendResponses(ArrayList responses) - { + public void sendResponses(ArrayList responses) { ByteBuf buffer = Unpooled.buffer(); - if(this.channel.isOpen()) - { - for(ServerMessage response : responses) - { - if (response == null || response.getHeader() <= 0) - { + if (this.channel.isOpen()) { + for (ServerMessage response : responses) { + if (response == null || response.getHeader() <= 0) { return; } @@ -95,67 +77,51 @@ public class GameClient } - public void dispose() - { - try - { + public void dispose() { + try { this.channel.close(); - if(this.habbo != null) - { - if(this.habbo.isOnline()) - { + if (this.habbo != null) { + if (this.habbo.isOnline()) { this.habbo.getHabboInfo().setOnline(false); this.habbo.disconnect(); } this.habbo = null; } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - public Channel getChannel() - { + public Channel getChannel() { return this.channel; } - public Habbo getHabbo() - { + public Habbo getHabbo() { return this.habbo; } - public void setHabbo(Habbo habbo) - { + public void setHabbo(Habbo habbo) { this.habbo = habbo; } - public String getMachineId() - { + public String getMachineId() { return this.machineId; } - public void setMachineId(String machineId) - { - if (machineId == null) - { + public void setMachineId(String machineId) { + if (machineId == null) { throw new RuntimeException("Cannot set machineID to NULL"); } this.machineId = machineId; - if (this.habbo != null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) - { + if (this.habbo != null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) { statement.setString(1, this.machineId); statement.setInt(2, this.habbo.getHabboInfo().getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } 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 c6b9f49e..4d1198f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java @@ -11,32 +11,25 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -public class GameClientManager -{ +public class GameClientManager { + public static final AttributeKey CLIENT = AttributeKey.valueOf("GameClient"); private final ConcurrentMap clients; - public static final AttributeKey CLIENT = AttributeKey.valueOf("GameClient"); - - public GameClientManager() - { + public GameClientManager() { this.clients = new ConcurrentHashMap<>(); } - public ConcurrentMap getSessions() - { + public ConcurrentMap getSessions() { return this.clients; } - public boolean addClient(ChannelHandlerContext ctx) - { + public boolean addClient(ChannelHandlerContext ctx) { GameClient client = new GameClient(ctx.channel()); - ctx.channel().closeFuture().addListener(new ChannelFutureListener() - { + ctx.channel().closeFuture().addListener(new ChannelFutureListener() { @Override - public void operationComplete(ChannelFuture channelFuture) throws Exception - { + public void operationComplete(ChannelFuture channelFuture) throws Exception { GameClientManager.this.disposeClient(ctx.channel()); } }); @@ -48,17 +41,14 @@ public class GameClientManager } - public void disposeClient(GameClient client) - { + public void disposeClient(GameClient client) { this.disposeClient(client.getChannel()); } - private void disposeClient(Channel channel) - { + private void disposeClient(Channel channel) { GameClient client = channel.attr(CLIENT).get(); - if (client != null) - { + if (client != null) { client.dispose(); } channel.deregister(); @@ -69,16 +59,11 @@ public class GameClientManager } - public boolean containsHabbo(Integer id) - { - if (!this.clients.isEmpty()) - { - for (GameClient client : this.clients.values()) - { - if (client.getHabbo() != null) - { - if (client.getHabbo().getHabboInfo() != null) - { + public boolean containsHabbo(Integer id) { + if (!this.clients.isEmpty()) { + for (GameClient client : this.clients.values()) { + if (client.getHabbo() != null) { + if (client.getHabbo().getHabboInfo() != null) { if (client.getHabbo().getHabboInfo().getId() == id) return true; } @@ -89,14 +74,12 @@ public class GameClientManager } - public Habbo getHabbo(int id) - { - for(GameClient client : this.clients.values()) - { - if(client.getHabbo() == null) + public Habbo getHabbo(int id) { + for (GameClient client : this.clients.values()) { + if (client.getHabbo() == null) continue; - if(client.getHabbo().getHabboInfo().getId() == id) + if (client.getHabbo().getHabboInfo().getId() == id) return client.getHabbo(); } @@ -104,14 +87,12 @@ public class GameClientManager } - public Habbo getHabbo(String username) - { - for(GameClient client : this.clients.values()) - { - if(client.getHabbo() == null) + public Habbo getHabbo(String username) { + for (GameClient client : this.clients.values()) { + if (client.getHabbo() == null) continue; - if(client.getHabbo().getHabboInfo().getUsername().equalsIgnoreCase(username)) + if (client.getHabbo().getHabboInfo().getUsername().equalsIgnoreCase(username)) return client.getHabbo(); } @@ -119,16 +100,12 @@ public class GameClientManager } - public List getHabbosWithIP(String ip) - { + public List getHabbosWithIP(String ip) { List habbos = new ArrayList<>(); - for (GameClient client : this.clients.values()) - { - if (client.getHabbo() != null && client.getHabbo().getHabboInfo() != null) - { - if (client.getHabbo().getHabboInfo().getIpLogin().equalsIgnoreCase(ip)) - { + for (GameClient client : this.clients.values()) { + if (client.getHabbo() != null && client.getHabbo().getHabboInfo() != null) { + if (client.getHabbo().getHabboInfo().getIpLogin().equalsIgnoreCase(ip)) { habbos.add(client.getHabbo()); } } @@ -138,14 +115,11 @@ public class GameClientManager } - public List getHabbosWithMachineId(String machineId) - { + public List getHabbosWithMachineId(String machineId) { List habbos = new ArrayList<>(); - for (GameClient client : this.clients.values()) - { - if (client.getHabbo() != null && client.getHabbo().getHabboInfo() != null && client.getMachineId().equalsIgnoreCase(machineId)) - { + for (GameClient client : this.clients.values()) { + if (client.getHabbo() != null && client.getHabbo().getHabboInfo() != null && client.getMachineId().equalsIgnoreCase(machineId)) { habbos.add(client.getHabbo()); } } @@ -154,26 +128,21 @@ public class GameClientManager } - public void sendBroadcastResponse(MessageComposer composer) - { + public void sendBroadcastResponse(MessageComposer composer) { this.sendBroadcastResponse(composer.compose()); } - public void sendBroadcastResponse(ServerMessage message) - { - for (GameClient client : this.clients.values()) - { + public void sendBroadcastResponse(ServerMessage message) { + for (GameClient client : this.clients.values()) { client.sendResponse(message); } } - public void sendBroadcastResponse(ServerMessage message, GameClient exclude) - { - for (GameClient client : this.clients.values()) - { - if(client.equals(exclude)) + public void sendBroadcastResponse(ServerMessage message, GameClient exclude) { + for (GameClient client : this.clients.values()) { + if (client.equals(exclude)) continue; client.sendResponse(message); @@ -181,18 +150,13 @@ public class GameClientManager } - - public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) - { - for (GameClient client : this.clients.values()) - { - if(client.equals(exclude)) + public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) { + for (GameClient client : this.clients.values()) { + if (client.equals(exclude)) continue; - if(client.getHabbo() != null) - { - if (client.getHabbo().hasPermission(minPermission)) - { + if (client.getHabbo() != null) { + if (client.getHabbo().hasPermission(minPermission)) { client.sendResponse(message); } } 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 4e13453f..1b22ff67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -22,30 +22,19 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public abstract class Game implements Runnable -{ - - private final Class gameTeamClazz; - - private final Class gamePlayerClazz; +public abstract class Game implements Runnable { protected final THashMap teams = new THashMap<>(); - protected final Room room; - + private final Class gameTeamClazz; + private final Class gamePlayerClazz; private final boolean countsAchievements; - + public boolean isRunning; + public GameState state = GameState.IDLE; private int startTime; - private int endTime; - public boolean isRunning; - - - public GameState state = GameState.IDLE; - - public Game(Class gameTeamClazz, Class gamePlayerClazz, Room room, boolean countsAchievements) - { + public Game(Class gameTeamClazz, Class gamePlayerClazz, Room room, boolean countsAchievements) { this.gameTeamClazz = gameTeamClazz; this.gamePlayerClazz = gamePlayerClazz; this.room = room; @@ -56,25 +45,19 @@ public abstract class Game implements Runnable public abstract void initialise(); - public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) - { - try - { - if (habbo != null) - { - if(Emulator.getPluginManager().isRegistered(GameHabboJoinEvent.class, true)) - { + public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { + try { + if (habbo != null) { + if (Emulator.getPluginManager().isRegistered(GameHabboJoinEvent.class, true)) { Event gameHabboJoinEvent = new GameHabboJoinEvent(this, habbo); Emulator.getPluginManager().fireEvent(gameHabboJoinEvent); - if(gameHabboJoinEvent.isCancelled()) + if (gameHabboJoinEvent.isCancelled()) return false; } - synchronized (this.teams) - { + synchronized (this.teams) { GameTeam team = this.getTeam(teamColor); - if (team == null) - { + if (team == null) { team = this.gameTeamClazz.getDeclaredConstructor(GameTeamColors.class).newInstance(teamColor); this.addTeam(team); } @@ -87,9 +70,7 @@ public abstract class Game implements Runnable return true; } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -97,28 +78,23 @@ public abstract class Game implements Runnable } - public void removeHabbo(Habbo habbo) - { - if (habbo != null) - { - if(Emulator.getPluginManager().isRegistered(GameHabboLeaveEvent.class, true)) - { + public void removeHabbo(Habbo habbo) { + if (habbo != null) { + if (Emulator.getPluginManager().isRegistered(GameHabboLeaveEvent.class, true)) { Event gameHabboLeaveEvent = new GameHabboLeaveEvent(this, habbo); Emulator.getPluginManager().fireEvent(gameHabboLeaveEvent); - if(gameHabboLeaveEvent.isCancelled()) + if (gameHabboLeaveEvent.isCancelled()) return; } GameTeam team = this.getTeamForHabbo(habbo); - if (team != null && team.isMember(habbo)) - { + if (team != null && team.isMember(habbo)) { team.removeMember(habbo.getHabboInfo().getGamePlayer()); habbo.getHabboInfo().getGamePlayer().reset(); habbo.getHabboInfo().setCurrentGame(null); habbo.getHabboInfo().setGamePlayer(null); - if(this.countsAchievements && this.endTime > this.startTime) - { + if (this.countsAchievements && this.endTime > this.startTime) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GamePlayed")); } } @@ -143,22 +119,19 @@ public abstract class Game implements Runnable } - public void start() - { + public void start() { this.isRunning = false; this.state = GameState.RUNNING; this.startTime = Emulator.getIntUnixTimestamp(); - if(Emulator.getPluginManager().isRegistered(GameStartedEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(GameStartedEvent.class, true)) { Event gameStartedEvent = new GameStartedEvent(this); Emulator.getPluginManager().fireEvent(gameStartedEvent); } WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, new Object[]{this}); - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { item.setExtradata("0"); this.room.updateItem(item); } @@ -170,103 +143,82 @@ public abstract class Game implements Runnable this.saveScores(); GameTeam winningTeam = null; - for (GameTeam team : this.teams.values()) - { - if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) - { + for (GameTeam team : this.teams.values()) { + if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) { winningTeam = team; } } - if (winningTeam != null) - { - for (GamePlayer player : winningTeam.getMembers()) - { + if (winningTeam != null) { + for (GamePlayer player : winningTeam.getMembers()) { WiredHandler.handleCustomTrigger(WiredTriggerTeamWins.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this}); } - for (GameTeam team : this.teams.values()) - { + for (GameTeam team : this.teams.values()) { if (team == winningTeam) continue; - for (GamePlayer player : winningTeam.getMembers()) - { + for (GamePlayer player : winningTeam.getMembers()) { WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this}); } } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { this.room.updateItem(item); } } public abstract void run(); - public void pause() - { - if (this.state.equals(GameState.RUNNING)) - { + public void pause() { + if (this.state.equals(GameState.RUNNING)) { this.state = GameState.PAUSED; } } - public void unpause() - { - if (this.state.equals(GameState.PAUSED)) - { + public void unpause() { + if (this.state.equals(GameState.PAUSED)) { this.state = GameState.RUNNING; } } - public void stop() - { + public void stop() { this.state = GameState.IDLE; boolean gamesActive = false; - for(HabboItem timer : room.getFloorItems()) - { - if(timer instanceof InteractionGameTimer) { - if(((InteractionGameTimer) timer).isRunning()) + for (HabboItem timer : room.getFloorItems()) { + if (timer instanceof InteractionGameTimer) { + if (((InteractionGameTimer) timer).isRunning()) gamesActive = true; } } - if(gamesActive) { + if (gamesActive) { return; } - if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true)) { Event gameStoppedEvent = new GameStoppedEvent(this); Emulator.getPluginManager().fireEvent(gameStoppedEvent); } } - private void saveScores() - { - if(this.room == null) + private void saveScores() { + if (this.room == null) return; - for(Map.Entry teamEntry : this.teams.entrySet()) - { + for (Map.Entry teamEntry : this.teams.entrySet()) { Emulator.getThreading().run(new SaveScoreForTeam(teamEntry.getValue(), this)); } } - public GameTeam getTeamForHabbo(Habbo habbo) - { - if(habbo != null) - { - synchronized (this.teams) - { - for (GameTeam team : this.teams.values()) - { - if (team.isMember(habbo)) - { + public GameTeam getTeamForHabbo(Habbo habbo) { + if (habbo != null) { + synchronized (this.teams) { + for (GameTeam team : this.teams.values()) { + if (team.isMember(habbo)) { return team; } } @@ -277,30 +229,24 @@ public abstract class Game implements Runnable } - public GameTeam getTeam(GameTeamColors teamColor) - { - synchronized (this.teams) - { + public GameTeam getTeam(GameTeamColors teamColor) { + synchronized (this.teams) { return this.teams.get(teamColor); } } - public void addTeam(GameTeam team) - { - synchronized (this.teams) - { + public void addTeam(GameTeam team) { + synchronized (this.teams) { this.teams.put(team.teamColor, team); } } - public Room getRoom() - { + public Room getRoom() { return this.room; } - public int getStartTime() - { + public int getStartTime() { return this.startTime; } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index b1e65111..8aabcf90 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -public class GamePlayer -{ +public class GamePlayer { private final Habbo habbo; @@ -16,42 +15,37 @@ public class GamePlayer private int score; - public GamePlayer(Habbo habbo, GameTeamColors teamColor) - { + public GamePlayer(Habbo habbo, GameTeamColors teamColor) { this.habbo = habbo; this.teamColor = teamColor; } - public void reset() - { + public void reset() { this.score = 0; } - public synchronized void addScore(int amount) - { - if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null){ + public synchronized void addScore(int amount) { + if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { this.score += amount; - WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});} + WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); + } } } - public Habbo getHabbo() - { + public Habbo getHabbo() { return this.habbo; } - public GameTeamColors getTeamColor() - { + public GameTeamColors getTeamColor() { return this.teamColor; } - public int getScore() - { + public int getScore() { return this.score; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameState.java b/src/main/java/com/eu/habbo/habbohotel/games/GameState.java index 58c05c4d..2aa71581 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameState.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameState.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.games; -public enum GameState -{ +public enum GameState { IDLE, RUNNING, PAUSED 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 033077db..38748c8e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -3,30 +3,22 @@ package com.eu.habbo.habbohotel.games; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; -public class GameTeam -{ - - private final THashSet members; - +public class GameTeam { public final GameTeamColors teamColor; - - + private final THashSet members; private int teamScore; - public GameTeam(GameTeamColors teamColor) - { + public GameTeam(GameTeamColors teamColor) { this.teamColor = teamColor; this.members = new THashSet<>(); } - public void initialise() - { - for(GamePlayer player : this.members) - { + public void initialise() { + for (GamePlayer player : this.members) { player.reset(); } @@ -34,30 +26,25 @@ public class GameTeam } - public void reset() - { + public void reset() { this.members.clear(); } - public void addTeamScore(int teamScore) - { + public void addTeamScore(int teamScore) { this.teamScore += teamScore; } - public int getTeamScore() - { + public int getTeamScore() { return this.teamScore; } - public synchronized int getTotalScore() - { + public synchronized int getTotalScore() { int score = this.teamScore; - for(GamePlayer player : this.members) - { + for (GamePlayer player : this.members) { score += player.getScore(); } @@ -65,36 +52,28 @@ public class GameTeam } - public void addMember(GamePlayer gamePlayer) - { - synchronized (this.members) - { + public void addMember(GamePlayer gamePlayer) { + synchronized (this.members) { this.members.add(gamePlayer); } } - public void removeMember(GamePlayer gamePlayer) - { - synchronized (this.members) - { + public void removeMember(GamePlayer gamePlayer) { + synchronized (this.members) { this.members.remove(gamePlayer); } } - public THashSet getMembers() - { + public THashSet getMembers() { return this.members; } - public boolean isMember(Habbo habbo) - { - for(GamePlayer p : this.members) - { - if(p.getHabbo().equals(habbo)) - { + public boolean isMember(Habbo habbo) { + for (GamePlayer p : this.members) { + if (p.getHabbo().equals(habbo)) { return true; } } @@ -104,12 +83,9 @@ public class GameTeam @Deprecated - public GamePlayer getPlayerForHabbo(Habbo habbo) - { - for(GamePlayer p : this.members) - { - if(p.getHabbo().equals(habbo)) - { + public GamePlayer getPlayerForHabbo(Habbo habbo) { + for (GamePlayer p : this.members) { + if (p.getHabbo().equals(habbo)) { return p; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java index 2b41d8af..0a573e3c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.games; -public enum GameTeamColors -{ +public enum GameTeamColors { RED(0), @@ -31,17 +30,13 @@ public enum GameTeamColors public final int type; - GameTeamColors(int type) - { + GameTeamColors(int type) { this.type = type; } - public static GameTeamColors fromType(int type) - { - for (GameTeamColors teamColors : values()) - { - if (teamColors.type == type) - { + public static GameTeamColors fromType(int type) { + for (GameTeamColors teamColors : values()) { + if (teamColors.type == type) { return teamColors; } } 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 4d4c57e5..92cc9bf0 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 @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; -import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGate; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards.InteractionBattleBanzaiScoreboard; import com.eu.habbo.habbohotel.rooms.Room; @@ -14,11 +13,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; 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.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker; -import gnu.trove.impl.hash.THash; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; @@ -26,8 +22,7 @@ import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; -public class BattleBanzaiGame extends Game -{ +public class BattleBanzaiGame extends Game { public static final int effectId = 33; @@ -41,18 +36,12 @@ public class BattleBanzaiGame extends Game 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)); - + private final THashMap> lockedTiles; + private final THashMap gameTiles; private int tileCount; - private int countDown; - - private final THashMap> lockedTiles; - - private final THashMap gameTiles; - - public BattleBanzaiGame(Room room) - { + public BattleBanzaiGame(Room room) { super(BattleBanzaiGameTeam.class, BattleBanzaiGamePlayer.class, room, true); this.lockedTiles = new THashMap<>(); @@ -62,25 +51,21 @@ public class BattleBanzaiGame extends Game } @Override - public void initialise() - { - if(!this.state.equals(GameState.IDLE)) + public void initialise() { + if (!this.state.equals(GameState.IDLE)) return; this.countDown = 3; this.resetMap(); - synchronized (this.teams) - { - for (GameTeam t : this.teams.values()) - { + synchronized (this.teams) { + for (GameTeam t : this.teams.values()) { t.initialise(); } } - for(HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("1"); this.room.updateItemState(item); } @@ -89,15 +74,13 @@ public class BattleBanzaiGame extends Game } @Override - public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) - { + public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { return super.addHabbo(habbo, teamColor); } @Override - public void start() - { - if(!this.state.equals(GameState.IDLE)) + public void start() { + if (!this.state.equals(GameState.IDLE)) return; super.start(); @@ -108,28 +91,22 @@ public class BattleBanzaiGame extends Game } @Override - public void run() - { - try - { + public void run() { + try { if (this.state.equals(GameState.IDLE)) return; - if(this.countDown > 0) - { + if (this.countDown > 0) { this.countDown--; - if(this.countDown == 0) - { - for(HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) - { + if (this.countDown == 0) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("2"); this.room.updateItemState(item); } } - if(this.countDown > 1) - { + if (this.countDown > 1) { Emulator.getThreading().run(this, 500); return; @@ -141,49 +118,38 @@ public class BattleBanzaiGame extends Game if (this.state.equals(GameState.PAUSED)) return; int total = 0; - synchronized (this.lockedTiles) - { - for (Map.Entry> set : this.lockedTiles.entrySet()) - { + synchronized (this.lockedTiles) { + for (Map.Entry> set : this.lockedTiles.entrySet()) { total += set.getValue().size(); } } GameTeam highestScore = null; - synchronized (this.teams) - { - for (Map.Entry set : this.teams.entrySet()) - { - if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore()) - { + synchronized (this.teams) { + for (Map.Entry set : this.teams.entrySet()) { + if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore()) { highestScore = set.getValue(); } } } - if(highestScore != null) - { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) - { + if (highestScore != null) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata((highestScore.teamColor.type + 3) + ""); this.room.updateItemState(item); } } - if(total >= this.tileCount && this.tileCount != 0) - { - for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) - { - if(timer.isRunning()) + if (total >= this.tileCount && this.tileCount != 0) { + for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { + if (timer.isRunning()) timer.setRunning(false); } InteractionGameTimer.endGames(room, true); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -192,36 +158,28 @@ public class BattleBanzaiGame extends Game public void onEnd() { GameTeam winningTeam = null; - for (GameTeam team : this.teams.values()) - { - for(GamePlayer player : team.getMembers()) - { - if (player.getScore() > 0) - { + for (GameTeam team : this.teams.values()) { + for (GamePlayer player : team.getMembers()) { + if (player.getScore() > 0) { AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer")); AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted")); } } - if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) - { + if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) { winningTeam = team; } } - if (winningTeam != null) - { - for (GamePlayer player : winningTeam.getMembers()) - { - if (player.getScore() > 0) - { + if (winningTeam != null) { + for (GamePlayer player : winningTeam.getMembers()) { + if (player.getScore() > 0) { this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose()); AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner")); } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata((7 + winningTeam.teamColor.type) + ""); this.room.updateItemState(item); } @@ -233,16 +191,13 @@ public class BattleBanzaiGame extends Game } @Override - public void stop() - { + public void stop() { super.stop(); this.refreshGates(); - for (HabboItem tile : this.gameTiles.values()) - { - if (tile.getExtradata().equals("1")) - { + for (HabboItem tile : this.gameTiles.values()) { + if (tile.getExtradata().equals("1")) { tile.setExtradata("0"); this.room.updateItem(tile); } @@ -251,21 +206,17 @@ public class BattleBanzaiGame extends Game } - private synchronized void resetMap() - { + private synchronized void resetMap() { this.tileCount = 0; - for (HabboItem item : this.room.getFloorItems()) - { - if (item instanceof InteractionBattleBanzaiTile) - { + for (HabboItem item : this.room.getFloorItems()) { + if (item instanceof InteractionBattleBanzaiTile) { item.setExtradata("1"); this.room.updateItemState(item); this.tileCount++; this.gameTiles.put(item.getId(), item); } - if (item instanceof InteractionBattleBanzaiScoreboard) - { + if (item instanceof InteractionBattleBanzaiScoreboard) { item.setExtradata("0"); this.room.updateItemState(item); } @@ -273,25 +224,20 @@ public class BattleBanzaiGame extends Game } - public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) - { + public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) { this.tileLocked(teamColor, item, habbo, false); } - public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) - { - if(item instanceof InteractionBattleBanzaiTile) - { - if(!this.lockedTiles.containsKey(teamColor)) - { + public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) { + if (item instanceof InteractionBattleBanzaiTile) { + if (!this.lockedTiles.containsKey(teamColor)) { this.lockedTiles.put(teamColor, new THashSet<>()); } this.lockedTiles.get(teamColor).add(item); } - if(habbo != null) - { + if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked")); } @@ -300,7 +246,7 @@ public class BattleBanzaiGame extends Game final int x = item.getX(); final int y = item.getY(); - final List> filledAreas = new ArrayList<>(); + final List> filledAreas = new ArrayList<>(); final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); executor.execute(() -> { @@ -311,10 +257,8 @@ public class BattleBanzaiGame extends Game Optional> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size)); - if (largestAreaOfAll.isPresent()) - { - for (RoomTile tile: largestAreaOfAll.get()) - { + 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(); tileItem.ifPresent(habboItem -> { @@ -326,19 +270,17 @@ public class BattleBanzaiGame extends Game } this.refreshCounters(teamColor); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size()); } } }); } - private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) - { + private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) { if (this.isOutOfBounds(x, y) || this.isForeignLockedTile(x, y, color)) return null; - RoomTile tile = this.room.getLayout().getTile((short)x, (short)y); + RoomTile tile = this.room.getLayout().getTile((short) x, (short) y); if (this.hasLockedTileAtCoordinates(x, y, lockedTiles) || stack.contains(tile)) return stack; @@ -358,28 +300,23 @@ public class BattleBanzaiGame extends Game } - private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) - { - for (HabboItem item : lockedTiles) - { + private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) { + for (HabboItem item : lockedTiles) { if (item.getX() == x && item.getY() == y) return true; } return false; } - private boolean isOutOfBounds(int x, int y) - { - for (HabboItem item : this.gameTiles.values()) - { + private boolean isOutOfBounds(int x, int y) { + for (HabboItem item : this.gameTiles.values()) { if (item.getX() == x && item.getY() == y) return false; } return true; } - private boolean isForeignLockedTile(int x, int y, GameTeamColors color) - { + private boolean isForeignLockedTile(int x, int y, GameTeamColors color) { for (HashMap.Entry> lockedTilesForColor : this.lockedTiles.entrySet()) { if (lockedTilesForColor.getKey() == color) continue; @@ -391,11 +328,9 @@ public class BattleBanzaiGame extends Game return false; } - public void refreshCounters() - { - for(GameTeam team : this.teams.values()) - { - if(team.getMembers().isEmpty()) + public void refreshCounters() { + for (GameTeam team : this.teams.values()) { + if (team.getMembers().isEmpty()) continue; this.refreshCounters(team.teamColor); @@ -403,24 +338,21 @@ public class BattleBanzaiGame extends Game } - public void refreshCounters(GameTeamColors teamColors) - { + public void refreshCounters(GameTeamColors teamColors) { if (!this.teams.containsKey(teamColors)) return; int totalScore = this.teams.get(teamColors).getTotalScore(); THashMap scoreBoards = this.room.getRoomSpecialTypes().getBattleBanzaiScoreboards(teamColors); - for (InteractionBattleBanzaiScoreboard scoreboard : scoreBoards.values()) - { - if(scoreboard.getExtradata().isEmpty()) - { + for (InteractionBattleBanzaiScoreboard scoreboard : scoreBoards.values()) { + if (scoreboard.getExtradata().isEmpty()) { scoreboard.setExtradata("0"); } int oldScore = Integer.valueOf(scoreboard.getExtradata()); - if(oldScore == totalScore) + if (oldScore == totalScore) continue; scoreboard.setExtradata(totalScore + ""); @@ -428,39 +360,30 @@ public class BattleBanzaiGame extends Game } } - private void refreshGates() - { + private void refreshGates() { Collection gates = this.room.getRoomSpecialTypes().getBattleBanzaiGates().values(); THashSet tilesToUpdate = new THashSet<>(gates.size()); - for (HabboItem item : gates) - { + for (HabboItem item : gates) { tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); } this.room.updateTiles(tilesToUpdate); } - public void markTile(Habbo habbo, InteractionBattleBanzaiTile tile, int state) - { + public void markTile(Habbo habbo, InteractionBattleBanzaiTile tile, int state) { if (!this.gameTiles.contains(tile.getId())) return; int check = state - (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3); - if(check == 3 || check == 4) - { + if (check == 3 || check == 4) { state++; - if(state % 3 == 2) - { + if (state % 3 == 2) { habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE); this.tileLocked(habbo.getHabboInfo().getGamePlayer().getTeamColor(), tile, habbo); - } - else - { + } else { habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_FILL_TILE); } - } - else - { + } else { state = (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3) + 3; habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_HIJACK_TILE); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGamePlayer.java index 60d5f170..05dc9798 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGamePlayer.java @@ -4,10 +4,8 @@ import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.users.Habbo; -public class BattleBanzaiGamePlayer extends GamePlayer -{ - public BattleBanzaiGamePlayer(Habbo habbo, GameTeamColors teamColor) - { +public class BattleBanzaiGamePlayer extends GamePlayer { + public BattleBanzaiGamePlayer(Habbo habbo, GameTeamColors teamColor) { super(habbo, teamColor); } } 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 9894169d..bc3aed4e 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 @@ -7,24 +7,20 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -public class BattleBanzaiGameTeam extends GameTeam -{ - public BattleBanzaiGameTeam(GameTeamColors teamColor) - { +public class BattleBanzaiGameTeam extends GameTeam { + public BattleBanzaiGameTeam(GameTeamColors teamColor) { super(teamColor); } @Override - public void addMember(GamePlayer gamePlayer) - { + public void addMember(GamePlayer gamePlayer) { super.addMember(gamePlayer); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1); } @Override - public void removeMember(GamePlayer gamePlayer) - { + public void removeMember(GamePlayer gamePlayer) { Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame()); Room room = gamePlayer.getHabbo().getRoomUnit().getRoom(); @@ -33,7 +29,7 @@ public class BattleBanzaiGameTeam extends GameTeam super.removeMember(gamePlayer); - if(room != null && room.getRoomSpecialTypes() != null) { + if (room != null && room.getRoomSpecialTypes() != null) { for (InteractionGameGate gate : room.getRoomSpecialTypes().getBattleBanzaiGates().values()) { gate.updateState(game, 5); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java index 48fe15ea..addadf8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java @@ -14,47 +14,39 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import java.util.Map; -public class FootballGame extends Game -{ +public class FootballGame extends Game { private Room room; - public FootballGame(Room room) - { + public FootballGame(Room room) { super(null, null, room, true); this.room = room; } @Override - public void initialise() - { + public void initialise() { } @Override - public void run() - { + public void run() { } - public void onScore(RoomUnit kicker, GameTeamColors team) - { - if(this.room == null || !this.room.isLoaded()) + public void onScore(RoomUnit kicker, GameTeamColors team) { + if (this.room == null || !this.room.isLoaded()) return; Habbo habbo = this.room.getHabbo(kicker); - if(habbo != null) - { + if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored")); - if (habbo.getHabboInfo().getId() != this.room.getOwnerId()) - { + if (habbo.getHabboInfo().getId() != this.room.getOwnerId()) { AchievementManager.progressAchievement(this.room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom")); } } this.room.sendComposer(new RoomUserActionComposer(kicker, RoomUserAction.WAVE).compose()); - for (Map.Entry scoreBoard : this.room.getRoomSpecialTypes().getFootballScoreboards(team).entrySet()) - { - scoreBoard.getValue().changeScore(1); + for (Map.Entry scoreBoard : this.room.getRoomSpecialTypes().getFootballScoreboards(team).entrySet()) { + scoreBoard.getValue().changeScore(1); } } } \ No newline at end of file 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 616242a2..8fc3f9c7 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 @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; -import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate; import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTeleport; @@ -16,8 +15,6 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; 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.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; @@ -30,8 +27,7 @@ import gnu.trove.set.hash.THashSet; import java.util.HashMap; import java.util.Map; -public class FreezeGame extends Game -{ +public class FreezeGame extends Game { public static final int effectId = 40; public static int POWER_UP_POINTS; @@ -46,71 +42,74 @@ public class FreezeGame extends Game public static int FREEZE_LOOSE_POINTS; public static boolean POWERUP_STACK; - public FreezeGame(Room room) - { + public FreezeGame(Room room) { super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true); room.setAllowEffects(true); } + @EventHandler + public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) { + POWER_UP_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.effect"); + POWER_UP_CHANCE = Emulator.getConfig().getInt("hotel.freeze.powerup.chance"); + POWER_UP_PROTECT_TIME = Emulator.getConfig().getInt("hotel.freeze.powerup.protection.time"); + DESTROY_BLOCK_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.block"); + FREEZE_TIME = Emulator.getConfig().getInt("hotel.freeze.onfreeze.time.frozen"); + FREEZE_LOOSE_SNOWBALL = Emulator.getConfig().getInt("hotel.freeze.onfreeze.loose.snowballs"); + FREEZE_LOOSE_BOOST = Emulator.getConfig().getInt("hotel.freeze.onfreeze.loose.explosionboost"); + MAX_LIVES = Emulator.getConfig().getInt("hotel.freeze.powerup.max.lives"); + MAX_SNOWBALLS = Emulator.getConfig().getInt("hotel.freeze.powerup.max.snowballs"); + FREEZE_LOOSE_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.freeze"); + POWERUP_STACK = Emulator.getConfig().getBoolean("hotel.freeze.powerup.protection.stack"); + } + @Override - public synchronized void initialise() - { - if(this.state == GameState.RUNNING) + public synchronized void initialise() { + if (this.state == GameState.RUNNING) return; this.resetMap(); - for (GameTeam t : this.teams.values()) - { + for (GameTeam t : this.teams.values()) { t.initialise(); } this.start(); } - synchronized void resetMap() - { - for (HabboItem item : this.room.getFloorItems()) - { - if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) - { + synchronized void resetMap() { + for (HabboItem item : this.room.getFloorItems()) { + if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) { item.setExtradata("0"); this.room.updateItemState(item); } } } - public void throwBall(Habbo habbo, InteractionFreezeTile item) - { + public void throwBall(Habbo habbo, InteractionFreezeTile item) { if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass()) return; if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty()) return; - if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), this.room.getLayout().getTile(item.getX(), item.getY()))) - { - if(((FreezeGamePlayer)habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) - { + if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), this.room.getLayout().getTile(item.getX(), item.getY()))) { + if (((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) { Emulator.getThreading().run(new FreezeThrowSnowball(habbo, item, this.room)); } } } - public THashSet affectedTilesByExplosion(short x, short y, int radius) - { + public THashSet affectedTilesByExplosion(short x, short y, int radius) { THashSet tiles = new THashSet<>(); RoomTile t = this.room.getLayout().getTile(x, y); tiles.add(t); - for(int rotatation = 0; rotatation < 8; rotatation += 2) - { - for(int j = 0; j < radius; j++) - { + for (int rotatation = 0; rotatation < 8; rotatation += 2) { + 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.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY()) continue; tiles.add(t); @@ -120,20 +119,16 @@ public class FreezeGame extends Game return tiles; } - public THashSetaffectedTilesByExplosionDiagonal(short x, short y, int radius) - { + public THashSet affectedTilesByExplosionDiagonal(short x, short y, int radius) { THashSet tiles = new THashSet<>(); - for(int rotation = 1; rotation < 9; rotation += 2) - { + for (int rotation = 1; rotation < 9; rotation += 2) { RoomTile t = this.room.getLayout().getTile(x, y); - for(int j = 0; j < radius; j++) - { + 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 != null) { if (t.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY()) continue; @@ -145,11 +140,9 @@ public class FreezeGame extends Game return tiles; } - public synchronized void explodeBox(InteractionFreezeBlock block, int delay) - { + public synchronized void explodeBox(InteractionFreezeBlock block, int delay) { int powerUp = 0; - if(Emulator.getRandom().nextInt(100) + 1 <= FreezeGame.POWER_UP_CHANCE) - { + if (Emulator.getRandom().nextInt(100) + 1 <= FreezeGame.POWER_UP_CHANCE) { powerUp += Emulator.getRandom().nextInt(6) + 1; } @@ -158,57 +151,47 @@ public class FreezeGame extends Game this.room.updateItemState(block); } - public synchronized void givePowerUp(FreezeGamePlayer player, int powerUpId) - { + public synchronized void givePowerUp(FreezeGamePlayer player, int powerUpId) { player.addScore(FreezeGame.POWER_UP_POINTS); - switch(powerUpId) - { - case 2: - { + switch (powerUpId) { + case 2: { player.increaseExplosion(); break; } - case 3: - { + case 3: { player.addSnowball(); break; } - case 4: - { + case 4: { player.nextDiagonal = true; break; } - case 5: - { + case 5: { player.nextHorizontal = true; player.nextDiagonal = true; player.tempMassiveExplosion = true; break; } - case 6: - { + case 6: { player.addLife(); break; } - case 7: - { + case 7: { player.addProtection(); break; } } } - public synchronized void playerDies(GamePlayer player) - { + public synchronized void playerDies(GamePlayer player) { Emulator.getThreading().run(new FreezeClearEffects(player.getHabbo()), 1000); - if(this.room.getRoomSpecialTypes().hasFreezeExitTile()) - { + if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { InteractionFreezeExitTile tile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); tile.setExtradata("1"); this.room.updateItemState(tile); @@ -218,25 +201,18 @@ public class FreezeGame extends Game } @Override - public void start() - { - if (this.state != GameState.IDLE) - { + public void start() { + if (this.state != GameState.IDLE) { return; } super.start(); - if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) - { - for (Habbo habbo : this.room.getHabbos()) - { - if (this.getTeamForHabbo(habbo) == null) - { - for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation())) - { - if (item instanceof InteractionFreezeTile) - { + if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { + for (Habbo habbo : this.room.getHabbos()) { + if (this.getTeamForHabbo(habbo) == null) { + for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation())) { + if (item instanceof InteractionFreezeTile) { HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY())); } @@ -252,10 +228,8 @@ public class FreezeGame extends Game } @Override - public synchronized void run() - { - try - { + public synchronized void run() { + try { if (this.state.equals(GameState.IDLE)) return; @@ -263,67 +237,54 @@ public class FreezeGame extends Game if (this.state.equals(GameState.PAUSED)) return; - for (GameTeam team : this.teams.values()) - { - for (GamePlayer player : team.getMembers()) - { - ((FreezeGamePlayer)player).cycle(); + for (GameTeam team : this.teams.values()) { + for (GamePlayer player : team.getMembers()) { + ((FreezeGamePlayer) player).cycle(); } int totalScore = team.getTotalScore(); THashMap scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor); - for (InteractionFreezeScoreboard scoreboard : scoreBoards.values()) - { - if(scoreboard.getExtradata().isEmpty()) - { + for (InteractionFreezeScoreboard scoreboard : scoreBoards.values()) { + if (scoreboard.getExtradata().isEmpty()) { scoreboard.setExtradata("0"); } int oldScore = Integer.valueOf(scoreboard.getExtradata()); - if(oldScore == totalScore) + if (oldScore == totalScore) continue; scoreboard.setExtradata(totalScore + ""); this.room.updateItemState(scoreboard); } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @Override - public void stop() - { + public void stop() { super.stop(); GameTeam winningTeam = null; - for(GameTeam team : this.teams.values()) - { - if(winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) - { + for (GameTeam team : this.teams.values()) { + if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) { winningTeam = team; } } - for (GameTeam team : this.teams.values()) - { + for (GameTeam team : this.teams.values()) { THashSet players = new THashSet<>(); players.addAll(team.getMembers()); - for(GamePlayer p : players) - { - if (p.getScore() > 0) - { - if (team.equals(winningTeam)) - { + for (GamePlayer p : players) { + if (p.getScore() > 0) { + if (team.equals(winningTeam)) { AchievementManager.progressAchievement(p.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezeWinner"), p.getScore()); this.room.sendComposer(new RoomUserActionComposer(p.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose()); } @@ -334,15 +295,12 @@ public class FreezeGame extends Game } Map teamMemberCount = new HashMap<>(); - for (Map.Entry teamEntry : this.teams.entrySet()) - { + for (Map.Entry teamEntry : this.teams.entrySet()) { teamMemberCount.put(teamEntry.getKey(), teamEntry.getValue().getMembers().size()); } - for (Map.Entry set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet()) - { - if (teamMemberCount.containsKey(set.getValue().teamColor)) - { + for (Map.Entry set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet()) { + if (teamMemberCount.containsKey(set.getValue().teamColor)) { int amount = Math.min(teamMemberCount.get(set.getValue().teamColor), 5); set.getValue().setExtradata(amount + ""); teamMemberCount.put(set.getValue().teamColor, teamMemberCount.get(set.getValue().teamColor) - amount); @@ -355,13 +313,10 @@ public class FreezeGame extends Game this.setFreezeTileState("0"); } - public void setFreezeTileState(String state) - { - this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(new TObjectProcedure() - { + public void setFreezeTileState(String state) { + this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(new TObjectProcedure() { @Override - public boolean execute(InteractionFreezeExitTile object) - { + public boolean execute(InteractionFreezeExitTile object) { object.setExtradata(state); FreezeGame.this.room.updateItemState(object); return true; @@ -370,28 +325,9 @@ public class FreezeGame extends Game } - @EventHandler - public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) - { - POWER_UP_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.effect"); - POWER_UP_CHANCE = Emulator.getConfig().getInt("hotel.freeze.powerup.chance"); - POWER_UP_PROTECT_TIME = Emulator.getConfig().getInt("hotel.freeze.powerup.protection.time"); - DESTROY_BLOCK_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.block"); - FREEZE_TIME = Emulator.getConfig().getInt("hotel.freeze.onfreeze.time.frozen"); - FREEZE_LOOSE_SNOWBALL = Emulator.getConfig().getInt("hotel.freeze.onfreeze.loose.snowballs"); - FREEZE_LOOSE_BOOST = Emulator.getConfig().getInt("hotel.freeze.onfreeze.loose.explosionboost"); - MAX_LIVES = Emulator.getConfig().getInt("hotel.freeze.powerup.max.lives"); - MAX_SNOWBALLS = Emulator.getConfig().getInt("hotel.freeze.powerup.max.snowballs"); - FREEZE_LOOSE_POINTS = Emulator.getConfig().getInt("hotel.freeze.points.freeze"); - POWERUP_STACK = Emulator.getConfig().getBoolean("hotel.freeze.powerup.protection.stack"); - } - - - private void refreshGates() - { + private void refreshGates() { THashSet tilesToUpdate = new THashSet<>(); - for (HabboItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) { tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); } 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 be651e3b..4f7ea528 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 @@ -7,26 +7,23 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.FreezeLivesComposer; -public class FreezeGamePlayer extends GamePlayer -{ +public class FreezeGamePlayer extends GamePlayer { + public boolean nextDiagonal; + public boolean nextHorizontal; + public boolean tempMassiveExplosion; + public boolean dead; private int lives; private int snowBalls; private int explosionBoost; private int protectionTime; private int frozenTime; - public boolean nextDiagonal; - public boolean nextHorizontal; - public boolean tempMassiveExplosion; - public boolean dead; - public FreezeGamePlayer(Habbo habbo, GameTeamColors teamColor) - { + public FreezeGamePlayer(Habbo habbo, GameTeamColors teamColor) { super(habbo, teamColor); } @Override - public void reset() - { + public void reset() { this.lives = 3; this.snowBalls = 1; this.explosionBoost = 0; @@ -41,84 +38,68 @@ public class FreezeGamePlayer extends GamePlayer } @Override - public void addScore(int amount) - { + public void addScore(int amount) { super.addScore(amount); - if(amount > 0) - { + if (amount > 0) { AchievementManager.progressAchievement(this.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezePlayer"), amount); } } - public void addLife() - { - if(this.lives < FreezeGame.MAX_LIVES) - { + public void addLife() { + if (this.lives < FreezeGame.MAX_LIVES) { this.lives++; super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new FreezeLivesComposer(this).compose()); } } - public void takeLife() - { + public void takeLife() { this.lives--; - if(this.lives == 0) - { + if (this.lives == 0) { this.dead = true; FreezeGame game = (FreezeGame) super.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); - if(game != null) - { + if (game != null) { game.playerDies(this); } - } - else - { + } else { super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new FreezeLivesComposer(this).compose()); } } - public int getLives() - { + public int getLives() { return this.lives; } - public boolean canPickupLife() - { + public boolean canPickupLife() { return this.lives < 3; } - public void addSnowball() - { - if(this.snowBalls < FreezeGame.MAX_SNOWBALLS) + public void addSnowball() { + if (this.snowBalls < FreezeGame.MAX_SNOWBALLS) this.snowBalls++; } - public void addSnowball(int amount) - { + public void addSnowball(int amount) { this.snowBalls += amount; - if(this.snowBalls < 1) + if (this.snowBalls < 1) this.snowBalls = 1; } - public void takeSnowball() - { - if(this.snowBalls > 0) + public void takeSnowball() { + if (this.snowBalls > 0) this.snowBalls--; } - public boolean canThrowSnowball() - { + public boolean canThrowSnowball() { return this.snowBalls > 0 && !this.isFrozen(); } - public void freeze() - { - if(this.protectionTime > 0 || this.frozenTime > 0) + public void freeze() { + if (this.protectionTime > 0 || this.frozenTime > 0) return; this.takeLife(); @@ -130,45 +111,38 @@ public class FreezeGamePlayer extends GamePlayer this.updateEffect(); } - public void unfreeze() - { + public void unfreeze() { super.getHabbo().getRoomUnit().setCanWalk(true); this.frozenTime = 0; this.addProtection(); } - public boolean isFrozen() - { + public boolean isFrozen() { return this.frozenTime > 0; } - public boolean canGetFrozen() - { - if(this.isFrozen() || this.isProtected()) + public boolean canGetFrozen() { + if (this.isFrozen() || this.isProtected()) return false; return true; } - public void addProtection() - { + public void addProtection() { this.updateEffect(); - if(this.isProtected() && !FreezeGame.POWERUP_STACK) + if (this.isProtected() && !FreezeGame.POWERUP_STACK) return; this.protectionTime += FreezeGame.POWER_UP_PROTECT_TIME; } - public boolean isProtected() - { + public boolean isProtected() { return this.protectionTime > 0; } - public int getExplosionBoost() - { - if(this.tempMassiveExplosion) - { + public int getExplosionBoost() { + if (this.tempMassiveExplosion) { this.tempMassiveExplosion = false; return 5; } @@ -176,81 +150,67 @@ public class FreezeGamePlayer extends GamePlayer return this.explosionBoost; } - public void increaseExplosion() - { - if(this.explosionBoost < 5) + public void increaseExplosion() { + if (this.explosionBoost < 5) this.explosionBoost++; } - public void addExplosion(int radius) - { + public void addExplosion(int radius) { this.explosionBoost += radius; - if(this.explosionBoost < 0) - { + if (this.explosionBoost < 0) { this.explosionBoost = 0; } - if(this.explosionBoost > 5) - { + if (this.explosionBoost > 5) { this.explosionBoost = 5; } } - public void cycle() - { + public void cycle() { boolean needsEffectUpdate = false; - if(this.isProtected()) - { + if (this.isProtected()) { this.protectionTime--; - if(!this.isProtected()) + if (!this.isProtected()) needsEffectUpdate = true; } - if(this.frozenTime > 0) - { + if (this.frozenTime > 0) { this.frozenTime--; - if(this.frozenTime <= 0) - { + if (this.frozenTime <= 0) { super.getHabbo().getRoomUnit().setCanWalk(true); needsEffectUpdate = true; } } - if(needsEffectUpdate) + if (needsEffectUpdate) this.updateEffect(); } - public int correctEffectId() - { - if(this.dead) + public int correctEffectId() { + if (this.dead) return 0; - if(!this.isFrozen()) - { + if (!this.isFrozen()) { int effectId = 40; effectId += super.getTeamColor().type; - if (this.isProtected()) - { + if (this.isProtected()) { effectId += 9; } return effectId; - } - else - { + } else { return 12; } } - public void updateEffect() - { - if(this.dead) + public void updateEffect() { + if (this.dead) return; super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1); 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 49831106..133cf431 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 @@ -7,16 +7,13 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -public class FreezeGameTeam extends GameTeam -{ - public FreezeGameTeam(GameTeamColors teamColor) - { +public class FreezeGameTeam extends GameTeam { + public FreezeGameTeam(GameTeamColors teamColor) { super(teamColor); } @Override - public void removeMember(GamePlayer gamePlayer) - { + public void removeMember(GamePlayer gamePlayer) { Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); Room room = gamePlayer.getHabbo().getRoomUnit().getRoom(); @@ -25,7 +22,7 @@ public class FreezeGameTeam extends GameTeam super.removeMember(gamePlayer); - if(room != null && room.getRoomSpecialTypes() != null) { + if (room != null && room.getRoomSpecialTypes() != null) { for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) { gate.updateState(game, 5); } @@ -33,8 +30,7 @@ public class FreezeGameTeam extends GameTeam } @Override - public void addMember(GamePlayer gamePlayer) - { + public void addMember(GamePlayer gamePlayer) { super.addMember(gamePlayer); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/BunnyrunGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/BunnyrunGame.java index d9c5eb65..3b74413a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/BunnyrunGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/BunnyrunGame.java @@ -5,40 +5,33 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.InteractionBunnyrunPole; import com.eu.habbo.habbohotel.rooms.Room; -public class BunnyrunGame extends TagGame -{ - public BunnyrunGame(Room room) - { +public class BunnyrunGame extends TagGame { + public BunnyrunGame(Room room) { super(GameTeam.class, TagGamePlayer.class, room); } @Override - public Class getTagPole() - { + public Class getTagPole() { return InteractionBunnyrunPole.class; } @Override - public int getMaleEffect() - { + public int getMaleEffect() { return 0; } @Override - public int getMaleTaggerEffect() - { + public int getMaleTaggerEffect() { return 68; } @Override - public int getFemaleEffect() - { + public int getFemaleEffect() { return 0; } @Override - public int getFemaleTaggerEffect() - { + public int getFemaleTaggerEffect() { return 68; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/IceTagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/IceTagGame.java index 065fc706..397f5961 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/IceTagGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/IceTagGame.java @@ -6,44 +6,36 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIc import com.eu.habbo.habbohotel.rooms.Room; - -public class IceTagGame extends TagGame -{ +public class IceTagGame extends TagGame { private static final int MALE_SKATES = 38; private static final int FEMALE_SKATES = 39; - public IceTagGame(Room room) - { + public IceTagGame(Room room) { super(GameTeam.class, TagGamePlayer.class, room); } @Override - public Class getTagPole() - { + public Class getTagPole() { return InteractionIceTagPole.class; } @Override - public int getMaleEffect() - { + public int getMaleEffect() { return MALE_SKATES; } @Override - public int getMaleTaggerEffect() - { + public int getMaleTaggerEffect() { return MALE_SKATES + 7; } @Override - public int getFemaleEffect() - { + public int getFemaleEffect() { return FEMALE_SKATES; } @Override - public int getFemaleTaggerEffect() - { + public int getFemaleTaggerEffect() { return FEMALE_SKATES + 7; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/RollerskateGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/RollerskateGame.java index 29b96791..d277aa5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/RollerskateGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/RollerskateGame.java @@ -4,40 +4,33 @@ import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.rooms.Room; -public class RollerskateGame extends TagGame -{ - public RollerskateGame(Room room) - { +public class RollerskateGame extends TagGame { + public RollerskateGame(Room room) { super(GameTeam.class, TagGamePlayer.class, room); } @Override - public Class getTagPole() - { + public Class getTagPole() { return null; } @Override - public int getMaleEffect() - { + public int getMaleEffect() { return 55; } @Override - public int getMaleTaggerEffect() - { + public int getMaleTaggerEffect() { return 57; } @Override - public int getFemaleEffect() - { + public int getFemaleEffect() { return 56; } @Override - public int getFemaleTaggerEffect() - { + public int getFemaleTaggerEffect() { return 58; } } \ No newline at end of file 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 3865b745..fe6afd9d 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 @@ -22,177 +22,27 @@ import gnu.trove.set.hash.THashSet; import java.util.Map; -public abstract class TagGame extends Game -{ +public abstract class TagGame extends Game { public THashMap taggers = new THashMap<>(); - public TagGame(Class gameTeamClazz, Class gamePlayerClazz, Room room) - { + public TagGame(Class gameTeamClazz, Class gamePlayerClazz, Room room) { super(gameTeamClazz, gamePlayerClazz, room, false); } - public abstract Class getTagPole(); - - public abstract int getMaleEffect(); - - public abstract int getMaleTaggerEffect(); - - public abstract int getFemaleEffect(); - - public abstract int getFemaleTaggerEffect(); - - public void tagged(Room room, Habbo tagger, Habbo tagged) - { - if (this.taggers.containsKey(tagged)) - { - return; - } - - THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole()); - InteractionTagPole pole = this.taggers.get(tagger); - room.giveEffect(tagged, this.getTaggedEffect(tagged), -1); - - if (poles.size() > this.taggers.size()) - { - for (Map.Entry set : this.taggers.entrySet()) - { - poles.remove(set.getValue()); - } - - for (HabboItem item : poles) - { - tagged.getHabboInfo().getCurrentRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1); - this.taggers.put(tagged, (InteractionTagPole) item); - } - } - else - { - if (tagger != null) - { - room.giveEffect(tagger, this.getEffect(tagger), -1); - this.taggers.remove(tagger); - } - - this.taggers.put(tagged, pole); - } - - if (pole != null) - { - pole.setExtradata("1"); - room.updateItemState(pole); - Emulator.getThreading().run(new HabboItemNewState(pole, room, "0"), 1000); - } - } - - @Override - public synchronized boolean addHabbo(Habbo habbo, GameTeamColors teamColor) - { - super.addHabbo(habbo, GameTeamColors.RED); - - if (this.getTagPole() != null) - { - THashSet poles = habbo.getHabboInfo().getCurrentRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole()); - - if (poles.size() > this.taggers.size()) - { - for (Map.Entry set : this.taggers.entrySet()) - { - poles.remove(set.getValue()); - } - - TObjectHashIterator iterator = poles.iterator(); - if ((iterator.hasNext())) - { - HabboItem item = iterator.next(); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); - this.taggers.put(habbo, (InteractionTagPole) item); - return true; - } - } - } - else - { - if (this.taggers.isEmpty()) - { - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); - this.taggers.put(habbo, null); - return true; - } - } - - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1); - - return true; - } - - @Override - public synchronized void removeHabbo(Habbo habbo) - { - super.removeHabbo(habbo); - this.taggers.remove(habbo); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, 0, -1); - } - - @Override - public void initialise() - { - - } - - @Override - public void run() - { - - } - - public int getEffect(Habbo habbo) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) - { - return this.getMaleEffect(); - } - - return this.getFemaleEffect(); - } - - public int getTaggedEffect(Habbo habbo) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) - { - return this.getMaleTaggerEffect(); - } - - return this.getFemaleTaggerEffect(); - } - - public boolean isTagger(Habbo habbo) - { - return this.taggers.containsKey(habbo); - } - @EventHandler - public static void onUserLookAtPoint(RoomUnitLookAtPointEvent event) - { - if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentLocation(), event.location)) - { + public static void onUserLookAtPoint(RoomUnitLookAtPointEvent event) { + if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentLocation(), event.location)) { Habbo habbo = event.room.getHabbo(event.roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getCurrentGame() != null) - { - if (TagGame.class.isAssignableFrom(habbo.getHabboInfo().getCurrentGame())) - { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentGame() != null) { + if (TagGame.class.isAssignableFrom(habbo.getHabboInfo().getCurrentGame())) { TagGame game = (TagGame) event.room.getGame(habbo.getHabboInfo().getCurrentGame()); - if (game != null) - { - if (game.isTagger(habbo)) - { - for (Habbo tagged : event.room.getHabbosAt(event.location)) - { - if (tagged == habbo || tagged.getHabboInfo().getCurrentGame() == null || tagged.getHabboInfo().getCurrentGame() != habbo.getHabboInfo().getCurrentGame()) - { + if (game != null) { + if (game.isTagger(habbo)) { + for (Habbo tagged : event.room.getHabbosAt(event.location)) { + if (tagged == habbo || tagged.getHabboInfo().getCurrentGame() == null || tagged.getHabboInfo().getCurrentGame() != habbo.getHabboInfo().getCurrentGame()) { continue; } @@ -208,22 +58,16 @@ public abstract class TagGame extends Game } @EventHandler - public static void onUserWalkEvent(UserTakeStepEvent event) - { - if(event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) - { + public static void onUserWalkEvent(UserTakeStepEvent event) { + if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) { THashSet items = event.habbo.getHabboInfo().getCurrentRoom().getItemsAt(event.toLocation); TagGame game = (TagGame) event.habbo.getHabboInfo().getCurrentRoom().getGame(event.habbo.getHabboInfo().getCurrentGame()); - if (game != null) - { - for (HabboItem item : items) - { - if (item instanceof InteractionTagField && ((InteractionTagField) item).gameClazz == event.habbo.getHabboInfo().getCurrentGame()) - { - if (game.taggers.isEmpty()) - { + if (game != null) { + for (HabboItem item : items) { + if (item instanceof InteractionTagField && ((InteractionTagField) item).gameClazz == event.habbo.getHabboInfo().getCurrentGame()) { + if (game.taggers.isEmpty()) { game.tagged(event.habbo.getHabboInfo().getCurrentRoom(), null, event.habbo); } return; @@ -234,4 +78,118 @@ public abstract class TagGame extends Game } } } + + public abstract Class getTagPole(); + + public abstract int getMaleEffect(); + + public abstract int getMaleTaggerEffect(); + + public abstract int getFemaleEffect(); + + public abstract int getFemaleTaggerEffect(); + + public void tagged(Room room, Habbo tagger, Habbo tagged) { + if (this.taggers.containsKey(tagged)) { + return; + } + + THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole()); + InteractionTagPole pole = this.taggers.get(tagger); + room.giveEffect(tagged, this.getTaggedEffect(tagged), -1); + + if (poles.size() > this.taggers.size()) { + for (Map.Entry set : this.taggers.entrySet()) { + poles.remove(set.getValue()); + } + + for (HabboItem item : poles) { + tagged.getHabboInfo().getCurrentRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1); + this.taggers.put(tagged, (InteractionTagPole) item); + } + } else { + if (tagger != null) { + room.giveEffect(tagger, this.getEffect(tagger), -1); + this.taggers.remove(tagger); + } + + this.taggers.put(tagged, pole); + } + + if (pole != null) { + pole.setExtradata("1"); + room.updateItemState(pole); + Emulator.getThreading().run(new HabboItemNewState(pole, room, "0"), 1000); + } + } + + @Override + public synchronized boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { + super.addHabbo(habbo, GameTeamColors.RED); + + if (this.getTagPole() != null) { + THashSet poles = habbo.getHabboInfo().getCurrentRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole()); + + if (poles.size() > this.taggers.size()) { + for (Map.Entry set : this.taggers.entrySet()) { + poles.remove(set.getValue()); + } + + TObjectHashIterator iterator = poles.iterator(); + if ((iterator.hasNext())) { + HabboItem item = iterator.next(); + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); + this.taggers.put(habbo, (InteractionTagPole) item); + return true; + } + } + } else { + if (this.taggers.isEmpty()) { + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); + this.taggers.put(habbo, null); + return true; + } + } + + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1); + + return true; + } + + @Override + public synchronized void removeHabbo(Habbo habbo) { + super.removeHabbo(habbo); + this.taggers.remove(habbo); + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, 0, -1); + } + + @Override + public void initialise() { + + } + + @Override + public void run() { + + } + + public int getEffect(Habbo habbo) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { + return this.getMaleEffect(); + } + + return this.getFemaleEffect(); + } + + public int getTaggedEffect(Habbo habbo) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { + return this.getMaleTaggerEffect(); + } + + return this.getFemaleTaggerEffect(); + } + + public boolean isTagger(Habbo habbo) { + return this.taggers.containsKey(habbo); + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGamePlayer.java index 74011325..27513968 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGamePlayer.java @@ -4,11 +4,9 @@ import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.users.Habbo; -public class TagGamePlayer extends GamePlayer -{ +public class TagGamePlayer extends GamePlayer { - public TagGamePlayer(Habbo habbo, GameTeamColors teamColor) - { + public TagGamePlayer(Habbo habbo, GameTeamColors teamColor) { super(habbo, teamColor); } } \ No newline at end of file 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 602a4571..24511b32 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 @@ -1,22 +1,16 @@ package com.eu.habbo.habbohotel.games.wired; -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 com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; -import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -import java.util.Map; - -public class WiredGame extends Game -{ - public WiredGame(Room room) - { - super(GameTeam.class, GamePlayer.class, room , false); +public class WiredGame extends Game { + public WiredGame(Room room) { + super(GameTeam.class, GamePlayer.class, room, false); } @Override @@ -30,15 +24,13 @@ public class WiredGame extends Game } @Override - public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) - { + public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1); return super.addHabbo(habbo, teamColor); } @Override - public void removeHabbo(Habbo habbo) - { + public void removeHabbo(Habbo habbo) { super.removeHabbo(habbo); this.room.giveEffect(habbo, 0, -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 ed9cec54..75d4cc53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java @@ -17,22 +17,19 @@ import java.util.Collections; import java.util.Date; import java.util.Map; -public class GuardianTicket -{ +public class GuardianTicket { + private final THashMap votes = new THashMap<>(); + private final Habbo reporter; + private final Habbo reported; + private final Date date; private ArrayList chatLogs; - private final THashMap votes = new THashMap<>(); private GuardianVoteType verdict; private int timeLeft = 120; private int resendCount = 0; private int checkSum = 0; - private final Habbo reporter; - private final Habbo reported; - private final Date date; - private int guardianCount = 0; //TODO: Figure out what this was supposed to do. - public GuardianTicket(Habbo reporter, Habbo reported, ArrayList chatLogs) - { + public GuardianTicket(Habbo reporter, Habbo reported, ArrayList chatLogs) { this.chatLogs = chatLogs; Collections.sort(chatLogs); Emulator.getThreading().run(new GuardianVotingFinish(this), 120000); @@ -43,8 +40,7 @@ public class GuardianTicket } - public void requestToVote(Habbo guardian) - { + public void requestToVote(Habbo guardian) { guardian.getClient().sendResponse(new GuardianNewReportReceivedComposer()); this.votes.put(guardian, new GuardianVote(this.guardianCount, guardian)); @@ -53,12 +49,10 @@ public class GuardianTicket } - public void addGuardian(Habbo guardian) - { + public void addGuardian(Habbo guardian) { GuardianVote vote = this.votes.get(guardian); - if(vote != null && vote.type == GuardianVoteType.SEARCHING) - { + if (vote != null && vote.type == GuardianVoteType.SEARCHING) { guardian.getClient().sendResponse(new GuardianVotingRequestedComposer(this)); vote.type = GuardianVoteType.WAITING; this.updateVotes(); @@ -66,15 +60,13 @@ public class GuardianTicket } - public void removeGuardian(Habbo guardian) - { + public void removeGuardian(Habbo guardian) { GuardianVote vote = this.getVoteForGuardian(guardian); - if(vote == null) + if (vote == null) return; - if(vote.type == GuardianVoteType.SEARCHING || vote.type == GuardianVoteType.WAITING) - { + if (vote.type == GuardianVoteType.SEARCHING || vote.type == GuardianVoteType.WAITING) { this.getVoteForGuardian(guardian).type = GuardianVoteType.NOT_VOTED; } @@ -86,8 +78,7 @@ public class GuardianTicket } - public void vote(Habbo guardian, GuardianVoteType vote) - { + public void vote(Habbo guardian, GuardianVoteType vote) { this.votes.get(guardian).type = vote; this.updateVotes(); @@ -98,13 +89,10 @@ public class GuardianTicket } - public void updateVotes() - { - synchronized (this.votes) - { - for(Map.Entry set : this.votes.entrySet()) - { - if(set.getValue().type == GuardianVoteType.WAITING || set.getValue().type == GuardianVoteType.NOT_VOTED || set.getValue().ignore || set.getValue().type == GuardianVoteType.SEARCHING) + public void updateVotes() { + synchronized (this.votes) { + for (Map.Entry set : this.votes.entrySet()) { + if (set.getValue().type == GuardianVoteType.WAITING || set.getValue().type == GuardianVoteType.NOT_VOTED || set.getValue().ignore || set.getValue().type == GuardianVoteType.SEARCHING) continue; set.getKey().getClient().sendResponse(new GuardianVotingVotesComposer(this, set.getKey())); @@ -113,13 +101,10 @@ public class GuardianTicket } - public void finish() - { + public void finish() { int votedCount = this.getVotedCount(); - if(votedCount < Emulator.getConfig().getInt("guardians.minimum.votes")) - { - if(this.votes.size() >= Emulator.getConfig().getInt("guardians.maximum.guardians.total") || this.resendCount == Emulator.getConfig().getInt("guardians.maximum.resends")) - { + if (votedCount < Emulator.getConfig().getInt("guardians.minimum.votes")) { + if (this.votes.size() >= Emulator.getConfig().getInt("guardians.maximum.guardians.total") || this.resendCount == Emulator.getConfig().getInt("guardians.maximum.resends")) { this.verdict = GuardianVoteType.FORWARDED; Emulator.getGameEnvironment().getGuideManager().closeTicket(this); @@ -136,33 +121,27 @@ public class GuardianTicket Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); this.reporter.getClient().sendResponse(new BullyReportClosedComposer(BullyReportClosedComposer.CLOSED)); - } - else - { + } else { this.timeLeft = 30; Emulator.getThreading().run(new GuardianVotingFinish(this), 10000); this.resendCount++; Emulator.getGameEnvironment().getGuideManager().findGuardians(this); } - } - else - { + } else { this.verdict = this.calculateVerdict(); - for(Map.Entry set : this.votes.entrySet()) - { - if(set.getValue().type == GuardianVoteType.ACCEPTABLY || + for (Map.Entry set : this.votes.entrySet()) { + if (set.getValue().type == GuardianVoteType.ACCEPTABLY || set.getValue().type == GuardianVoteType.BADLY || - set.getValue().type == GuardianVoteType.AWFULLY) - { + set.getValue().type == GuardianVoteType.AWFULLY) { set.getKey().getClient().sendResponse(new GuardianVotingResultComposer(this, set.getValue())); } } Emulator.getGameEnvironment().getGuideManager().closeTicket(this); - if(this.verdict == GuardianVoteType.ACCEPTABLY) + if (this.verdict == GuardianVoteType.ACCEPTABLY) this.reporter.getClient().sendResponse(new BullyReportClosedComposer(BullyReportClosedComposer.MISUSE)); else this.reporter.getClient().sendResponse(new BullyReportClosedComposer(BullyReportClosedComposer.CLOSED)); @@ -170,35 +149,26 @@ public class GuardianTicket } - public boolean inProgress() - { + public boolean inProgress() { return this.verdict == null; } - public GuardianVoteType calculateVerdict() - { + public GuardianVoteType calculateVerdict() { int countAcceptably = 0; int countBadly = 0; int countAwfully = 0; int total = 0; - synchronized (this.votes) - { - for(Map.Entry set : this.votes.entrySet()) - { + synchronized (this.votes) { + for (Map.Entry set : this.votes.entrySet()) { GuardianVote vote = set.getValue(); - if(vote.type == GuardianVoteType.ACCEPTABLY) - { + if (vote.type == GuardianVoteType.ACCEPTABLY) { countAcceptably++; - } - else if(vote.type == GuardianVoteType.BADLY) - { + } else if (vote.type == GuardianVoteType.BADLY) { countBadly++; - } - else if(vote.type == GuardianVoteType.AWFULLY) - { + } else if (vote.type == GuardianVoteType.AWFULLY) { countAwfully++; } } @@ -208,81 +178,62 @@ public class GuardianTicket total += countBadly; - - - - return GuardianVoteType.BADLY; } - public GuardianVote getVoteForGuardian(Habbo guardian) - { + public GuardianVote getVoteForGuardian(Habbo guardian) { return this.votes.get(guardian); } - public THashMap getVotes() - { + public THashMap getVotes() { return this.votes; } - public int getTimeLeft() - { + public int getTimeLeft() { return this.timeLeft; } - public GuardianVoteType getVerdict() - { + public GuardianVoteType getVerdict() { return this.verdict; } - public ArrayList getChatLogs() - { + public ArrayList getChatLogs() { return this.chatLogs; } - public int getResendCount() - { + public int getResendCount() { return this.resendCount; } - public int getCheckSum() - { + public int getCheckSum() { return this.checkSum; } - public Habbo getReporter() - { + public Habbo getReporter() { return this.reporter; } - public Habbo getReported() - { + public Habbo getReported() { return this.reported; } - public Date getDate() - { + public Date getDate() { return this.date; } - public int getGuardianCount() - { + public int getGuardianCount() { return this.guardianCount; } - public ArrayList getSortedVotes(Habbo guardian) - { - synchronized (this.votes) - { + public ArrayList getSortedVotes(Habbo guardian) { + synchronized (this.votes) { ArrayList votes = new ArrayList<>(this.votes.values()); Collections.sort(votes); GuardianVote v = null; - for(GuardianVote vote : votes) - { - if(vote.guardian == guardian) - { + for (GuardianVote vote : votes) { + if (vote.guardian == guardian) { v = vote; break; } @@ -294,14 +245,11 @@ public class GuardianTicket } - public int getVotedCount() - { + public int getVotedCount() { int count = 0; - synchronized (this.votes) - { - for(Map.Entry set : this.votes.entrySet()) - { - if(set.getValue().type == GuardianVoteType.ACCEPTABLY || + synchronized (this.votes) { + for (Map.Entry set : this.votes.entrySet()) { + if (set.getValue().type == GuardianVoteType.ACCEPTABLY || set.getValue().type == GuardianVoteType.BADLY || set.getValue().type == GuardianVoteType.AWFULLY) count++; diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java index 5e5bb9ca..0066bc33 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java @@ -2,15 +2,13 @@ package com.eu.habbo.habbohotel.guides; import com.eu.habbo.habbohotel.users.Habbo; -public class GuardianVote implements Comparable -{ +public class GuardianVote implements Comparable { public final int id; final Habbo guardian; public GuardianVoteType type; boolean ignore; - public GuardianVote(int id, Habbo guardian) - { + public GuardianVote(int id, Habbo guardian) { this.id = id; this.guardian = guardian; this.type = GuardianVoteType.SEARCHING; @@ -18,24 +16,20 @@ public class GuardianVote implements Comparable } @Override - public int compareTo(GuardianVote o) - { + public int compareTo(GuardianVote o) { return this.id - o.id; } @Override - public boolean equals(Object o) - { - if(o instanceof GuardianVote) - { - return ((GuardianVote)o).id == this.id && ((GuardianVote) o).guardian == this.guardian && ((GuardianVote) o).type == this.type; + public boolean equals(Object o) { + if (o instanceof GuardianVote) { + return ((GuardianVote) o).id == this.id && ((GuardianVote) o).guardian == this.guardian && ((GuardianVote) o).type == this.type; } return false; } - public void ignore() - { + public void ignore() { this.ignore = true; } } 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 e23c9ed1..68d93ae3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVoteType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.guides; -public enum GuardianVoteType -{ +public enum GuardianVoteType { FORWARDED(-1), WAITING(0), ACCEPTABLY(1), @@ -12,13 +11,11 @@ public enum GuardianVoteType private final int type; - GuardianVoteType(int type) - { + GuardianVoteType(int type) { this.type = type; } - public int getType() - { + 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 df1b3fb5..8011fdca 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,11 @@ package com.eu.habbo.habbohotel.guides; -public class GuideChatMessage -{ +public class GuideChatMessage { public final int userId; public final String message; public final int timestamp; - public GuideChatMessage(int userId, String message, int timestamp) - { + public GuideChatMessage(int userId, String message, int timestamp) { this.userId = userId; this.message = message; this.timestamp = timestamp; diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuideManager.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuideManager.java index fd39073b..4407f81b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuideManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuideManager.java @@ -12,8 +12,7 @@ import gnu.trove.set.hash.THashSet; import java.util.Map; -public class GuideManager -{ +public class GuideManager { private final THashSet activeTours; private final THashSet activeTickets; private final THashSet closedTickets; @@ -21,8 +20,7 @@ public class GuideManager private final THashMap activeGuardians; private final THashMap tourRequestTiming; - public GuideManager() - { + public GuideManager() { this.activeTours = new THashSet<>(); this.activeTickets = new THashSet<>(); this.closedTickets = new THashSet<>(); @@ -31,12 +29,10 @@ public class GuideManager this.tourRequestTiming = new THashMap<>(); } - public void userLogsOut(Habbo habbo) - { + public void userLogsOut(Habbo habbo) { GuideTour tour = this.getGuideTourByHabbo(habbo); - if(tour != null) - { + if (tour != null) { this.endSession(tour); } @@ -44,8 +40,7 @@ public class GuideManager GuardianTicket ticket = this.getTicketForGuardian(habbo); - if(ticket != null) - { + if (ticket != null) { ticket.removeGuardian(habbo); } @@ -53,18 +48,13 @@ public class GuideManager } - - public void setOnGuide(Habbo habbo, boolean onDuty) - { - if(onDuty) - { + public void setOnGuide(Habbo habbo, boolean onDuty) { + if (onDuty) { this.activeHelpers.put(habbo, false); - } - else - { + } else { GuideTour tour = this.getGuideTourByHabbo(habbo); - if(tour != null) + if (tour != null) return; this.activeHelpers.remove(habbo); @@ -72,16 +62,11 @@ public class GuideManager } - public boolean findHelper(GuideTour tour) - { - synchronized (this.activeHelpers) - { - for(Map.Entry set : this.activeHelpers.entrySet()) - { - if(!set.getValue()) - { - if(!tour.hasDeclined(set.getKey().getHabboInfo().getId())) - { + public boolean findHelper(GuideTour tour) { + synchronized (this.activeHelpers) { + for (Map.Entry set : this.activeHelpers.entrySet()) { + if (!set.getValue()) { + if (!tour.hasDeclined(set.getKey().getHabboInfo().getId())) { tour.checkSum++; tour.setHelper(set.getKey()); set.getKey().getClient().sendResponse(new GuideSessionAttachedComposer(tour, true)); @@ -100,27 +85,22 @@ public class GuideManager } - public void declineTour(GuideTour tour) - { + public void declineTour(GuideTour tour) { Habbo helper = tour.getHelper(); tour.addDeclinedHelper(tour.getHelper().getHabboInfo().getId()); tour.setHelper(null); helper.getClient().sendResponse(new GuideSessionEndedComposer(GuideSessionEndedComposer.HELP_CASE_CLOSED)); helper.getClient().sendResponse(new GuideSessionDetachedComposer()); - if(!this.findHelper(tour)) - { + if (!this.findHelper(tour)) { this.endSession(tour); tour.getNoob().getClient().sendResponse(new GuideSessionErrorComposer(GuideSessionErrorComposer.NO_HELPERS_AVAILABLE)); } } - public void startSession(GuideTour tour, Habbo helper) - { - synchronized (this.activeTours) - { - synchronized (this.activeHelpers) - { + public void startSession(GuideTour tour, Habbo helper) { + synchronized (this.activeTours) { + synchronized (this.activeHelpers) { this.activeHelpers.put(helper, true); ServerMessage message = new GuideSessionStartedComposer(tour).compose(); @@ -133,17 +113,13 @@ public class GuideManager } - public void endSession(GuideTour tour) - { - synchronized (this.activeTours) - { - synchronized (this.activeHelpers) - { + public void endSession(GuideTour tour) { + synchronized (this.activeTours) { + synchronized (this.activeHelpers) { tour.getNoob().getClient().sendResponse(new GuideSessionEndedComposer(GuideSessionEndedComposer.HELP_CASE_CLOSED)); tour.end(); - if(tour.getHelper() != null) - { + if (tour.getHelper() != null) { this.activeHelpers.put(tour.getHelper(), false); tour.getHelper().getClient().sendResponse(new GuideSessionEndedComposer(GuideSessionEndedComposer.HELP_CASE_CLOSED)); tour.getHelper().getClient().sendResponse(new GuideSessionDetachedComposer()); @@ -154,10 +130,8 @@ public class GuideManager } - public void recommend(GuideTour tour, boolean recommend) - { - synchronized (this.activeTours) - { + public void recommend(GuideTour tour, boolean recommend) { + synchronized (this.activeTours) { tour.setWouldRecommend(recommend ? GuideRecommendStatus.YES : GuideRecommendStatus.NO); tour.getNoob().getClient().sendResponse(new GuideSessionDetachedComposer()); AchievementManager.progressAchievement(tour.getNoob(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GuideFeedbackGiver")); @@ -167,14 +141,10 @@ public class GuideManager } - public GuideTour getGuideTourByHelper(Habbo helper) - { - synchronized (this.activeTours) - { - for(GuideTour tour : this.activeTours) - { - if(!tour.isEnded() && tour.getHelper() == helper) - { + public GuideTour getGuideTourByHelper(Habbo helper) { + synchronized (this.activeTours) { + for (GuideTour tour : this.activeTours) { + if (!tour.isEnded() && tour.getHelper() == helper) { return tour; } } @@ -184,14 +154,10 @@ public class GuideManager } - public GuideTour getGuideTourByNoob(Habbo noob) - { - synchronized (this.activeTours) - { - for(GuideTour tour : this.activeTours) - { - if(tour.getNoob() == noob) - { + public GuideTour getGuideTourByNoob(Habbo noob) { + synchronized (this.activeTours) { + for (GuideTour tour : this.activeTours) { + if (tour.getNoob() == noob) { return tour; } } @@ -201,14 +167,10 @@ public class GuideManager } - public GuideTour getGuideTourByHabbo(Habbo habbo) - { - synchronized (this.activeTours) - { - for(GuideTour tour : this.activeTours) - { - if(tour.getHelper() == habbo || tour.getNoob() == habbo) - { + public GuideTour getGuideTourByHabbo(Habbo habbo) { + synchronized (this.activeTours) { + for (GuideTour tour : this.activeTours) { + if (tour.getHelper() == habbo || tour.getNoob() == habbo) { return tour; } } @@ -218,35 +180,29 @@ public class GuideManager } - public int getGuidesCount() - { + public int getGuidesCount() { return this.activeHelpers.size(); } - public int getGuardiansCount() - { + public int getGuardiansCount() { return this.activeGuardians.size(); } - public boolean activeGuardians() - { + public boolean activeGuardians() { return this.activeGuardians.size() > 0; } - public int getAverageWaitingTime() - { - synchronized (this.tourRequestTiming) - { + public int getAverageWaitingTime() { + synchronized (this.tourRequestTiming) { int total = 0; - if(this.tourRequestTiming.isEmpty()) + if (this.tourRequestTiming.isEmpty()) return 5; - for(Map.Entry set : this.tourRequestTiming.entrySet()) - { + for (Map.Entry set : this.tourRequestTiming.entrySet()) { total += (set.getValue() - set.getKey()); } @@ -255,12 +211,8 @@ public class GuideManager } - - - public void addGuardianTicket(GuardianTicket ticket) - { - synchronized (this.activeTickets) - { + public void addGuardianTicket(GuardianTicket ticket) { + synchronized (this.activeTickets) { this.activeTickets.add(ticket); this.findGuardians(ticket); @@ -268,27 +220,22 @@ public class GuideManager } - public void findGuardians(GuardianTicket ticket) - { - synchronized (this.activeGuardians) - { + public void findGuardians(GuardianTicket ticket) { + synchronized (this.activeGuardians) { int count = ticket.getVotedCount(); THashSet selectedGuardians = new THashSet<>(); - for(Map.Entry set : this.activeGuardians.entrySet()) - { - if(count == 5) + for (Map.Entry set : this.activeGuardians.entrySet()) { + if (count == 5) break; - if(set.getKey() == ticket.getReporter() || + if (set.getKey() == ticket.getReporter() || set.getKey() == ticket.getReported()) continue; - if(set.getValue() == null) - { - if(ticket.getVoteForGuardian(set.getKey()) == null) - { + if (set.getValue() == null) { + if (ticket.getVoteForGuardian(set.getKey()) == null) { ticket.requestToVote(set.getKey()); selectedGuardians.add(set.getKey()); @@ -298,33 +245,26 @@ public class GuideManager count++; } - for(Habbo habbo : selectedGuardians) - { + for (Habbo habbo : selectedGuardians) { this.activeGuardians.put(habbo, ticket); } - if(count < 5) - { + if (count < 5) { Emulator.getThreading().run(new GuardianTicketFindMoreSlaves(ticket), 3000); } } } - public void acceptTicket(Habbo guardian, boolean accepted) - { + public void acceptTicket(Habbo guardian, boolean accepted) { GuardianTicket ticket = this.getTicketForGuardian(guardian); - if(ticket != null) - { - if(!accepted) - { + if (ticket != null) { + if (!accepted) { ticket.removeGuardian(guardian); this.findGuardians(ticket); this.activeGuardians.put(guardian, null); - } - else - { + } else { ticket.addGuardian(guardian); this.activeGuardians.put(guardian, ticket); } @@ -332,39 +272,30 @@ public class GuideManager } - public GuardianTicket getTicketForGuardian(Habbo guardian) - { - synchronized (this.activeGuardians) - { + public GuardianTicket getTicketForGuardian(Habbo guardian) { + synchronized (this.activeGuardians) { return this.activeGuardians.get(guardian); } } - public GuardianTicket getRecentTicket(Habbo reporter) - { + public GuardianTicket getRecentTicket(Habbo reporter) { GuardianTicket ticket = null; - synchronized (this.activeTickets) - { - for(GuardianTicket t : this.activeTickets) - { - if(t.getReporter() == reporter) - { + synchronized (this.activeTickets) { + for (GuardianTicket t : this.activeTickets) { + if (t.getReporter() == reporter) { return t; } } } - synchronized (this.closedTickets) - { - for(GuardianTicket t : this.closedTickets) - { - if(t.getReporter() != reporter) + synchronized (this.closedTickets) { + for (GuardianTicket t : this.closedTickets) { + if (t.getReporter() != reporter) continue; - if(ticket == null || Emulator.getIntUnixTimestamp() - (t.getDate().getTime() / 1000) < Emulator.getIntUnixTimestamp() - (ticket.getDate().getTime() / 1000)) - { + if (ticket == null || Emulator.getIntUnixTimestamp() - (t.getDate().getTime() / 1000) < Emulator.getIntUnixTimestamp() - (ticket.getDate().getTime() / 1000)) { ticket = t; } } @@ -373,14 +304,10 @@ public class GuideManager return ticket; } - public GuardianTicket getOpenReportedHabboTicket(Habbo reported) - { - synchronized (this.activeTickets) - { - for(GuardianTicket t : this.activeTickets) - { - if(t.getReported() == reported) - { + public GuardianTicket getOpenReportedHabboTicket(Habbo reported) { + synchronized (this.activeTickets) { + for (GuardianTicket t : this.activeTickets) { + if (t.getReported() == reported) { return t; } } @@ -390,50 +317,38 @@ public class GuideManager } - public void closeTicket(GuardianTicket ticket) - { - synchronized (this.activeTickets) - { + public void closeTicket(GuardianTicket ticket) { + synchronized (this.activeTickets) { this.activeTickets.remove(ticket); } - synchronized (this.closedTickets) - { + synchronized (this.closedTickets) { this.closedTickets.add(ticket); } THashSet toUpdate = new THashSet<>(); - synchronized (this.activeGuardians) - { - for (Map.Entry set : this.activeGuardians.entrySet()) - { - if (set.getValue() == ticket) - { + synchronized (this.activeGuardians) { + for (Map.Entry set : this.activeGuardians.entrySet()) { + if (set.getValue() == ticket) { toUpdate.add(set.getKey()); } } - for (Habbo habbo : toUpdate) - { + for (Habbo habbo : toUpdate) { this.activeGuardians.put(habbo, null); } } } - public void setOnGuardian(Habbo habbo, boolean onDuty) - { - if(onDuty) - { + public void setOnGuardian(Habbo habbo, boolean onDuty) { + if (onDuty) { this.activeGuardians.put(habbo, null); - } - else - { + } else { GuardianTicket ticket = this.getTicketForGuardian(habbo); - if(ticket != null) - { + if (ticket != null) { ticket.removeGuardian(habbo); } @@ -442,39 +357,30 @@ public class GuideManager } - public void cleanup() - { - synchronized (this.activeTours) - { + public void cleanup() { + synchronized (this.activeTours) { THashSet tours = new THashSet<>(); - for(GuideTour tour : this.activeTours) - { - if(tour.isEnded() && (Emulator.getIntUnixTimestamp() - tour.getEndTime() > 300)) - { + for (GuideTour tour : this.activeTours) { + if (tour.isEnded() && (Emulator.getIntUnixTimestamp() - tour.getEndTime() > 300)) { tours.add(tour); } } - for(GuideTour tour : tours) - { + for (GuideTour tour : tours) { this.activeTours.remove(tour); } } - synchronized (this.activeTickets) - { + synchronized (this.activeTickets) { THashSet tickets = new THashSet<>(); - for(GuardianTicket ticket : this.closedTickets) - { - if(Emulator.getIntUnixTimestamp() - (ticket.getDate().getTime() / 1000) > 15 * 60) - { + for (GuardianTicket ticket : this.closedTickets) { + if (Emulator.getIntUnixTimestamp() - (ticket.getDate().getTime() / 1000) > 15 * 60) { tickets.add(ticket); } } - for(GuardianTicket ticket : tickets) - { + for (GuardianTicket ticket : tickets) { this.closedTickets.remove(ticket); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuideRecommendStatus.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuideRecommendStatus.java index efa6341c..169dfeec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuideRecommendStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuideRecommendStatus.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.guides; -public enum GuideRecommendStatus -{ +public enum GuideRecommendStatus { UNKNOWN, YES, NO 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 9aa21ab1..8e52be22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuideTour.java @@ -5,87 +5,71 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; -public class GuideTour -{ +public class GuideTour { + private final Habbo noob; + private final String helpRequest; + private final THashSet sendMessages = new THashSet<>(); + private final THashSet declinedHelpers = new THashSet<>(); public int checkSum = 0; - private Habbo helper; private int startTime; private int endTime; private boolean ended; private GuideRecommendStatus wouldRecommend = GuideRecommendStatus.UNKNOWN; - private final Habbo noob; - private final String helpRequest; - private final THashSet sendMessages = new THashSet<>(); - private final THashSet declinedHelpers = new THashSet<>(); - - public GuideTour(Habbo noob, String helpRequest) - { + public GuideTour(Habbo noob, String helpRequest) { this.noob = noob; this.helpRequest = helpRequest; AchievementManager.progressAchievement(this.noob, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GuideAdvertisementReader")); } - public void finish() - { + public void finish() { //TODO Insert recommendation. //TODO Query messages. } - public Habbo getNoob() - { + public Habbo getNoob() { return this.noob; } - public String getHelpRequest() - { + public String getHelpRequest() { return this.helpRequest; } - public Habbo getHelper() - { + public Habbo getHelper() { return this.helper; } - public void setHelper(Habbo helper) - { + public void setHelper(Habbo helper) { this.helper = helper; } - public void addMessage(GuideChatMessage message) - { + public void addMessage(GuideChatMessage message) { this.sendMessages.add(message); } - public GuideRecommendStatus getWouldRecommend() - { + public GuideRecommendStatus getWouldRecommend() { return this.wouldRecommend; } - public void setWouldRecommend(GuideRecommendStatus wouldRecommend) - { + public void setWouldRecommend(GuideRecommendStatus wouldRecommend) { this.wouldRecommend = wouldRecommend; - if(this.wouldRecommend == GuideRecommendStatus.YES) - { + if (this.wouldRecommend == GuideRecommendStatus.YES) { AchievementManager.progressAchievement(this.getHelper(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GuideRecommendation")); } } - public void addDeclinedHelper(int userId) - { + public void addDeclinedHelper(int userId) { this.declinedHelpers.add(userId); } - public boolean hasDeclined(int userId) - { + public boolean hasDeclined(int userId) { return this.declinedHelpers.contains(userId); } - public void end() - { + public void end() { this.ended = true; this.endTime = Emulator.getIntUnixTimestamp(); @@ -94,23 +78,19 @@ public class GuideTour AchievementManager.progressAchievement(this.noob, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GuideRequester")); } - public boolean isEnded() - { + public boolean isEnded() { return this.ended; } - public int getStartTime() - { + public int getStartTime() { return this.startTime; } - public void setStartTime(int startTime) - { + public void setStartTime(int startTime) { this.startTime = startTime; } - public int getEndTime() - { + 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 7c47bc3f..075b31a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java @@ -7,8 +7,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class Guild implements Runnable -{ +public class Guild implements Runnable { + public boolean needsUpdate; + public int lastRequested = Emulator.getIntUnixTimestamp(); private int id; private int ownerId; private String ownerName; @@ -30,11 +31,7 @@ public class Guild implements Runnable private SettingsState postThreads = SettingsState.ADMINS; private SettingsState modForum = SettingsState.ADMINS; - public boolean needsUpdate; - public int lastRequested = Emulator.getIntUnixTimestamp(); - - public Guild(ResultSet set) throws SQLException - { + public Guild(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.ownerId = set.getInt("user_id"); this.ownerName = set.getString("username"); @@ -57,8 +54,7 @@ public class Guild implements Runnable this.requestCount = 0; } - public Guild(int ownerId, String ownerName, int roomId, String roomName, String name, String description, int colorOne, int colorTwo, String badge) - { + public Guild(int ownerId, String ownerName, int roomId, String roomName, String name, String description, int colorOne, int colorTwo, String badge) { this.id = 0; this.ownerId = ownerId; this.ownerName = ownerName; @@ -75,47 +71,34 @@ public class Guild implements Runnable this.dateCreated = Emulator.getIntUnixTimestamp(); } - public void loadMemberCount() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as count FROM guilds_members WHERE level_id < 3 AND guild_id = ?")) - { + public void loadMemberCount() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as count FROM guilds_members WHERE level_id < 3 AND guild_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { this.memberCount = set.getInt(1); } } } - try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as count FROM guilds_members WHERE level_id = 3 AND guild_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as count FROM guilds_members WHERE level_id = 3 AND guild_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { this.requestCount = set.getInt(1); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @Override - public void run() - { - if(this.needsUpdate) - { - 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 = ?")) - { + public void run() { + if (this.needsUpdate) { + 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); @@ -132,201 +115,161 @@ public class Guild implements Runnable statement.execute(); this.needsUpdate = false; - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public int getId() - { + public int getId() { return this.id; } - public void setId(int id) - { + public void setId(int id) { this.id = id; } - public String getOwnerName() - { + public String getOwnerName() { return this.ownerName; } - public String getName() - { + public String getName() { return this.name; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } - public String getDescription() - { + public String getDescription() { return this.description; } - public void setDescription(String description) - { + public void setDescription(String description) { this.description = description; } - public int getRoomId() - { + public int getRoomId() { return this.roomId; } - public String getRoomName() - { + public String getRoomName() { return this.roomName; } - public void setRoomName(String roomName) - { + public void setRoomName(String roomName) { this.roomName = roomName; } - public GuildState getState() - { + public GuildState getState() { return this.state; } - public void setState(GuildState state) - { + public void setState(GuildState state) { this.state = state; } - public boolean getRights() - { + public boolean getRights() { return this.rights; } - public void setRights(boolean rights) - { + public void setRights(boolean rights) { this.rights = rights; } - public int getColorOne() - { + public int getColorOne() { return this.colorOne; } - public void setColorOne(int colorOne) - { + public void setColorOne(int colorOne) { this.colorOne = colorOne; } - public int getColorTwo() - { + public int getColorTwo() { return this.colorTwo; } - public void setColorTwo(int colorTwo) - { + public void setColorTwo(int colorTwo) { this.colorTwo = colorTwo; } - public String getBadge() - { + public String getBadge() { return this.badge; } - public void setBadge(String badge) - { + public void setBadge(String badge) { this.badge = badge; } - public int getOwnerId() - { + public int getOwnerId() { return this.ownerId; } - public int getDateCreated() - { + public int getDateCreated() { return dateCreated; } - public int getMemberCount() - { + public int getMemberCount() { return this.memberCount; } - public void increaseMemberCount() - { + public void increaseMemberCount() { this.memberCount++; } - public void decreaseMemberCount() - { + public void decreaseMemberCount() { this.memberCount--; } - public int getRequestCount() - { + public int getRequestCount() { return this.requestCount; } - public void increaseRequestCount() - { + public void increaseRequestCount() { this.requestCount++; } - public void decreaseRequestCount() - { + public void decreaseRequestCount() { this.requestCount--; } - public boolean hasForum() - { + public boolean hasForum() { return this.forum; } - public void setForum(boolean forum) - { + public void setForum(boolean forum) { this.forum = forum; } - public SettingsState canReadForum() - { + public SettingsState canReadForum() { return this.readForum; } - public void setReadForum(SettingsState readForum) - { + public void setReadForum(SettingsState readForum) { this.readForum = readForum; } - public SettingsState canPostMessages() - { + public SettingsState canPostMessages() { return this.postMessages; } - public void setPostMessages(SettingsState postMessages) - { + public void setPostMessages(SettingsState postMessages) { this.postMessages = postMessages; } - public SettingsState canPostThreads() - { + public SettingsState canPostThreads() { return this.postThreads; } - public void setPostThreads(SettingsState postThreads) - { + public void setPostThreads(SettingsState postThreads) { this.postThreads = postThreads; } - public SettingsState canModForum() - { + public SettingsState canModForum() { return this.modForum; } - public void setModForum(SettingsState modForum) - { + public void setModForum(SettingsState modForum) { this.modForum = modForum; } } 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 4b0d92c1..87f4cdc7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java @@ -3,16 +3,14 @@ package com.eu.habbo.habbohotel.guilds; import java.sql.ResultSet; import java.sql.SQLException; -public class GuildMember implements Comparable -{ +public class GuildMember implements Comparable { private int userId; private String username; private String look; private int joinDate; private GuildRank rank; - public GuildMember(ResultSet set) throws SQLException - { + public GuildMember(ResultSet set) throws SQLException { this.userId = set.getInt("user_id"); this.username = set.getString("username"); this.look = set.getString("look"); @@ -20,8 +18,7 @@ public class GuildMember implements Comparable this.rank = GuildRank.getRank(set.getInt("level_id")); } - public GuildMember(int user_id, String username, String look, int joinDate, int guildRank) - { + public GuildMember(int user_id, String username, String look, int joinDate, int guildRank) { this.userId = user_id; this.username = username; this.look = look; @@ -29,49 +26,40 @@ public class GuildMember implements Comparable this.rank = GuildRank.values()[guildRank]; } - public int getUserId() - { + public int getUserId() { return userId; } - public String getUsername() - { + public String getUsername() { return username; } - public String getLook() - { + public String getLook() { return look; } - public void setLook(String look) - { + public void setLook(String look) { this.look = look; } - public int getJoinDate() - { + public int getJoinDate() { return joinDate; } - public void setJoinDate(int joinDate) - { + public void setJoinDate(int joinDate) { this.joinDate = joinDate; } - public GuildRank getRank() - { + public GuildRank getRank() { return rank; } - public void setRank(GuildRank rank) - { + public void setRank(GuildRank rank) { this.rank = rank; } @Override - public int compareTo(Object o) - { + public int compareTo(Object o) { return 0; } } 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 40a20e4b..2595c37d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPart.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.guilds; import java.sql.ResultSet; import java.sql.SQLException; -public class GuildPart -{ +public class GuildPart { public final int id; @@ -14,8 +13,7 @@ public class GuildPart public final String valueB; - public GuildPart(ResultSet set) throws SQLException - { + public GuildPart(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.valueA = set.getString("firstvalue"); this.valueB = set.getString("secondvalue"); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPartType.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPartType.java index 6c504bca..5881b536 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPartType.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildPartType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.guilds; -public enum GuildPartType -{ +public enum GuildPartType { BASE, 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 cf45a1e5..e0c5c833 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.guilds; -public enum GuildRank -{ +public enum GuildRank { ADMIN(0), MOD(1), MEMBER(2), @@ -10,19 +9,14 @@ public enum GuildRank public final int type; - GuildRank(int type) - { + GuildRank(int type) { this.type = type; } - public static GuildRank getRank(int type) - { - try - { + public static GuildRank getRank(int type) { + try { return values()[type]; - } - catch (Exception e) - { + } catch (Exception e) { return MEMBER; } } 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 90e5c9ec..e2a8eb60 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java @@ -1,26 +1,20 @@ package com.eu.habbo.habbohotel.guilds; -public enum GuildState -{ +public enum GuildState { OPEN(0), LOCKED(1), CLOSED(2); public final int state; - GuildState(int state) - { + GuildState(int state) { this.state = state; } - public static GuildState valueOf(int state) - { - try - { + public static GuildState valueOf(int state) { + try { return values()[state]; - } - catch (Exception e) - { + } catch (Exception e) { return OPEN; } } 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 ebebf355..146606d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/SettingsState.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.guilds; -public enum SettingsState -{ +public enum SettingsState { EVERYONE(0), MEMBERS(1), ADMINS(2), @@ -9,17 +8,13 @@ public enum SettingsState public final int state; - SettingsState(int state) - { + SettingsState(int state) { this.state = state; } - public static SettingsState fromValue(int state) - { - try - { - switch (state) - { + public static SettingsState fromValue(int state) { + try { + switch (state) { case 0: return EVERYONE; case 1: @@ -29,9 +24,7 @@ public enum SettingsState case 3: return OWNER; } - } - catch (Exception e) - { + } catch (Exception e) { } 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 0a308002..5d432c79 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,17 +9,21 @@ 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 java.sql.*; import java.util.*; public class ForumThread implements Runnable, ISerialize { + private final static THashMap> guildThreadsCache = new THashMap<>(); + private final static THashMap forumThreadsCache = new THashMap<>(); private final int threadId; private final int guildId; private final int openerId; private final String subject; - private int postsCount; private final int createdAt; + private final THashMap comments; + private int postsCount; private int updatedAt; private ForumThreadState state; private boolean pinned; @@ -27,13 +31,9 @@ public class ForumThread implements Runnable, ISerialize { private int adminId; private boolean needsUpdate; private boolean hasCommentsLoaded; - private final THashMap comments; private int commentIndex; private ForumThreadComment lastComment; - private final static THashMap> guildThreadsCache = new THashMap<>(); - private final static THashMap forumThreadsCache = new THashMap<>(); - 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) { this.threadId = threadId; this.guildId = guildId; @@ -69,8 +69,8 @@ public class ForumThread implements Runnable, ISerialize { try { this.lastComment = ForumThreadComment.getById(set.getInt("last_comment_id")); + } catch (Exception e) { } - catch (Exception e) { } this.comments = new THashMap<>(); this.needsUpdate = false; @@ -78,6 +78,164 @@ public class ForumThread implements Runnable, ISerialize { this.commentIndex = 0; } + public static ForumThread create(Guild guild, Habbo opener, String subject, String message) throws Exception { + ForumThread createdThread = null; + + if (Emulator.getPluginManager().fireEvent(new GuildForumThreadBeforeCreated(guild, opener, subject, message)).isCancelled()) + return null; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_threads`(`guild_id`, `opener_id`, `subject`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + int timestamp = Emulator.getIntUnixTimestamp(); + + statement.setInt(1, guild.getId()); + statement.setInt(2, opener.getHabboInfo().getId()); + statement.setString(3, subject); + statement.setInt(4, timestamp); + statement.setInt(5, timestamp); + + if (statement.executeUpdate() < 1) + return null; + + ResultSet set = statement.getGeneratedKeys(); + if (set.next()) { + int threadId = set.getInt(1); + createdThread = new ForumThread(threadId, guild.getId(), opener.getHabboInfo().getId(), subject, 0, timestamp, timestamp, ForumThreadState.OPEN, false, false, 0, null); + cacheThread(createdThread); + + ForumThreadComment comment = ForumThreadComment.create(createdThread, opener, message); + createdThread.addComment(comment); + + Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return createdThread; + } + + public static THashSet getByGuildId(int guildId) { + THashSet threads = null; + + if (guildThreadsCache.containsKey(guildId)) { + guildThreadsCache.get(guildId); + } + + if (threads != null) + return threads; + + threads = new THashSet(); + + guildThreadsCache.put(guildId, threads); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT A.*, B.`id` AS `last_comment_id` " + + "FROM guilds_forums_threads A " + + "JOIN (" + + "SELECT * " + + "FROM `guilds_forums_comments` " + + "WHERE `id` IN (" + + "SELECT MAX(id) " + + "FROM `guilds_forums_comments` B " + + "GROUP BY `thread_id` " + + "ORDER BY B.`id` ASC " + + ") " + + "ORDER BY `id` DESC " + + ") B ON A.`id` = B.`thread_id` " + + "WHERE A.`guild_id` = ? " + + "ORDER BY A.`pinned` DESC, B.`created_at` DESC " + )) { + statement.setInt(1, guildId); + + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + ForumThread thread = new ForumThread(set); + synchronized (threads) { + threads.add(thread); + } + cacheThread(thread); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return threads; + } + + public static ForumThread getById(int threadId) throws SQLException { + ForumThread foundThread = forumThreadsCache.get(threadId); + + if (foundThread != null) + return foundThread; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( + "SELECT A.*, B.`id` AS `last_comment_id` " + + "FROM guilds_forums_threads A " + + "JOIN (" + + "SELECT * " + + "FROM `guilds_forums_comments` " + + "WHERE `id` IN (" + + "SELECT MAX(id) " + + "FROM `guilds_forums_comments` B " + + "GROUP BY `thread_id` " + + "ORDER BY B.`id` ASC " + + ") " + + "ORDER BY `id` DESC " + + ") B ON A.`id` = B.`thread_id` " + + "WHERE A.`id` = ? " + + "ORDER BY A.`pinned` DESC, B.`created_at` DESC " + + "LIMIT 1" + )) { + statement.setInt(1, threadId); + + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + foundThread = new ForumThread(set); + cacheThread(foundThread); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return foundThread; + } + + private static void cacheThread(ForumThread thread) { + synchronized (forumThreadsCache) { + forumThreadsCache.put(thread.threadId, thread); + } + + THashSet guildThreads = guildThreadsCache.get(thread.guildId); + + if (guildThreads == null) { + guildThreads = new THashSet<>(); + synchronized (forumThreadsCache) { + guildThreadsCache.put(thread.guildId, guildThreads); + } + } + + synchronized (guildThreads) { + guildThreads.add(thread); + } + } + + public static void clearCache() { + for (THashSet threads : guildThreadsCache.values()) { + for (ForumThread thread : threads) { + thread.run(); + } + } + + synchronized (forumThreadsCache) { + forumThreadsCache.clear(); + } + + synchronized (guildThreadsCache) { + guildThreadsCache.clear(); + } + } + public int getThreadId() { return threadId; } @@ -147,6 +305,11 @@ public class ForumThread implements Runnable, ISerialize { return adminId; } + public void setAdminId(int adminId) { + this.adminId = adminId; + this.needsUpdate = true; + } + public ForumThreadComment getLastComment() { return lastComment; } @@ -155,13 +318,8 @@ public class ForumThread implements Runnable, ISerialize { this.lastComment = lastComment; } - public void setAdminId(int adminId) { - this.adminId = adminId; - this.needsUpdate = true; - } - private void loadComments() { - if(this.hasCommentsLoaded) + if (this.hasCommentsLoaded) return; synchronized (this.comments) { @@ -192,7 +350,7 @@ public class ForumThread implements Runnable, ISerialize { } public Collection getComments() { - if(!this.hasCommentsLoaded) { + if (!this.hasCommentsLoaded) { loadComments(); } @@ -200,7 +358,7 @@ public class ForumThread implements Runnable, ISerialize { } public Collection getComments(int limit, int offset) { - if(!this.hasCommentsLoaded) { + if (!this.hasCommentsLoaded) { loadComments(); } @@ -231,7 +389,7 @@ public class ForumThread implements Runnable, ISerialize { } public ForumThreadComment getCommentById(int commentId) { - if(!this.hasCommentsLoaded) { + if (!this.hasCommentsLoaded) { loadComments(); } @@ -251,7 +409,7 @@ public class ForumThread implements Runnable, ISerialize { int newComments = 0; ForumThreadComment lastComment = this.lastComment; - if(lastComment == null) { + if (lastComment == null) { for (ForumThreadComment comment : comments) { if (comment.getCreatedAt() > lastSeenAt) { newComments++; @@ -288,11 +446,10 @@ public class ForumThread implements Runnable, ISerialize { @Override public void run() { - if(!this.needsUpdate) + if (!this.needsUpdate) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE `guilds_forums_threads` SET `posts_count` = ?, `updated_at` = ?, `state` = ?, `pinned` = ?, `locked` = ?, `admin_id` = ? WHERE `id` = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE `guilds_forums_threads` SET `posts_count` = ?, `updated_at` = ?, `state` = ?, `pinned` = ?, `locked` = ?, `admin_id` = ? WHERE `id` = ?")) { statement.setInt(1, this.postsCount); statement.setInt(2, this.updatedAt); statement.setInt(3, this.state.getStateId()); @@ -303,178 +460,8 @@ public class ForumThread implements Runnable, ISerialize { statement.execute(); this.needsUpdate = false; - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - - public static ForumThread create(Guild guild, Habbo opener, String subject, String message) throws Exception { - ForumThread createdThread = null; - - if(Emulator.getPluginManager().fireEvent(new GuildForumThreadBeforeCreated(guild, opener, subject, message)).isCancelled()) - return null; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_threads`(`guild_id`, `opener_id`, `subject`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { - int timestamp = Emulator.getIntUnixTimestamp(); - - statement.setInt(1, guild.getId()); - statement.setInt(2, opener.getHabboInfo().getId()); - statement.setString(3, subject); - statement.setInt(4, timestamp); - statement.setInt(5, timestamp); - - if(statement.executeUpdate() < 1) - return null; - - ResultSet set = statement.getGeneratedKeys(); - if(set.next()) { - int threadId = set.getInt(1); - createdThread = new ForumThread(threadId, guild.getId(), opener.getHabboInfo().getId(), subject, 0, timestamp, timestamp, ForumThreadState.OPEN, false, false, 0, null); - cacheThread(createdThread); - - ForumThreadComment comment = ForumThreadComment.create(createdThread, opener, message); - createdThread.addComment(comment); - - Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return createdThread; - } - - public static THashSet getByGuildId(int guildId) { - THashSet threads = null; - - if(guildThreadsCache.containsKey(guildId)) { - guildThreadsCache.get(guildId); - } - - if(threads != null) - return threads; - - threads = new THashSet(); - - guildThreadsCache.put(guildId, threads); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT A.*, B.`id` AS `last_comment_id` " + - "FROM guilds_forums_threads A " + - "JOIN (" + - "SELECT * " + - "FROM `guilds_forums_comments` " + - "WHERE `id` IN (" + - "SELECT MAX(id) " + - "FROM `guilds_forums_comments` B " + - "GROUP BY `thread_id` " + - "ORDER BY B.`id` ASC " + - ") " + - "ORDER BY `id` DESC " + - ") B ON A.`id` = B.`thread_id` " + - "WHERE A.`guild_id` = ? " + - "ORDER BY A.`pinned` DESC, B.`created_at` DESC " - )) - { - statement.setInt(1, guildId); - - try(ResultSet set = statement.executeQuery()) { - while (set.next()) { - ForumThread thread = new ForumThread(set); - synchronized (threads) { - threads.add(thread); - } - cacheThread(thread); - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return threads; - } - - public static ForumThread getById(int threadId) throws SQLException { - ForumThread foundThread = forumThreadsCache.get(threadId); - - if(foundThread != null) - return foundThread; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( - "SELECT A.*, B.`id` AS `last_comment_id` " + - "FROM guilds_forums_threads A " + - "JOIN (" + - "SELECT * " + - "FROM `guilds_forums_comments` " + - "WHERE `id` IN (" + - "SELECT MAX(id) " + - "FROM `guilds_forums_comments` B " + - "GROUP BY `thread_id` " + - "ORDER BY B.`id` ASC " + - ") " + - "ORDER BY `id` DESC " + - ") B ON A.`id` = B.`thread_id` " + - "WHERE A.`id` = ? " + - "ORDER BY A.`pinned` DESC, B.`created_at` DESC " + - "LIMIT 1" - )) - { - statement.setInt(1, threadId); - - try(ResultSet set = statement.executeQuery()) { - while (set.next()) { - foundThread = new ForumThread(set); - cacheThread(foundThread); - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return foundThread; - } - - - private static void cacheThread(ForumThread thread) { - synchronized (forumThreadsCache) { - forumThreadsCache.put(thread.threadId, thread); - } - - THashSet guildThreads = guildThreadsCache.get(thread.guildId); - - if(guildThreads == null) { - guildThreads = new THashSet<>(); - synchronized (forumThreadsCache) { - guildThreadsCache.put(thread.guildId, guildThreads); - } - } - - synchronized (guildThreads) { - guildThreads.add(thread); - } - } - - public static void clearCache() { - for(THashSet threads : guildThreadsCache.values()) { - for(ForumThread thread : threads) { - thread.run(); - } - } - - synchronized (forumThreadsCache) { - forumThreadsCache.clear(); - } - - synchronized (guildThreadsCache) { - guildThreadsCache.clear(); - } - } } 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 1e320d5f..f1f05529 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 @@ -13,6 +13,7 @@ import java.sql.*; public class ForumThreadComment implements Runnable, ISerialize { + private static THashMap forumCommentsCache = new THashMap<>(); private final int commentId; private final int threadId; private final int userId; @@ -22,7 +23,6 @@ public class ForumThreadComment implements Runnable, ISerialize { private int adminId; private int index; private boolean needsUpdate; - private static THashMap forumCommentsCache = new THashMap<>(); public ForumThreadComment(int commentId, int threadId, int userId, String message, int createdAt, ForumThreadState state, int adminId) { this.commentId = commentId; @@ -51,22 +51,19 @@ public class ForumThreadComment implements Runnable, ISerialize { public static ForumThreadComment getById(int id) { ForumThreadComment foundComment = forumCommentsCache.get(id); - if(foundComment != null) + if (foundComment != null) return foundComment; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM `guilds_forums_comments` WHERE `id` = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM `guilds_forums_comments` WHERE `id` = ? LIMIT 1")) { statement.setInt(1, id); - try(ResultSet set = statement.executeQuery()) { + try (ResultSet set = statement.executeQuery()) { while (set.next()) { foundComment = new ForumThreadComment(set); cacheComment(foundComment); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -81,6 +78,37 @@ public class ForumThreadComment implements Runnable, ISerialize { forumCommentsCache.clear(); } + public static ForumThreadComment create(ForumThread thread, Habbo poster, String message) throws Exception { + ForumThreadComment createdComment = null; + + if (Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentBeforeCreated(thread, poster, message)).isCancelled()) + return null; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_comments`(`thread_id`, `user_id`, `message`, `created_at`) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) { + int timestamp = Emulator.getIntUnixTimestamp(); + + statement.setInt(1, thread.getThreadId()); + statement.setInt(2, poster.getHabboInfo().getId()); + statement.setString(3, message); + statement.setInt(4, timestamp); + + if (statement.executeUpdate() < 1) + return null; + + ResultSet set = statement.getGeneratedKeys(); + if (set.next()) { + int commentId = set.getInt(1); + createdComment = new ForumThreadComment(commentId, thread.getThreadId(), poster.getHabboInfo().getId(), message, timestamp, ForumThreadState.OPEN, 0); + + Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment)); + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return createdComment; + } + public int getCommentId() { return commentId; } @@ -161,55 +189,18 @@ public class ForumThreadComment implements Runnable, ISerialize { @Override public void run() { - if(!this.needsUpdate) + if (!this.needsUpdate) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;")) { statement.setInt(1, this.state.getStateId()); statement.setInt(2, this.adminId); statement.setInt(3, this.commentId); statement.execute(); this.needsUpdate = false; - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - - public static ForumThreadComment create(ForumThread thread, Habbo poster, String message) throws Exception { - ForumThreadComment createdComment = null; - - if(Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentBeforeCreated(thread, poster, message)).isCancelled()) - return null; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_comments`(`thread_id`, `user_id`, `message`, `created_at`) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) - { - int timestamp = Emulator.getIntUnixTimestamp(); - - statement.setInt(1, thread.getThreadId()); - statement.setInt(2, poster.getHabboInfo().getId()); - statement.setString(3, message); - statement.setInt(4, timestamp); - - if(statement.executeUpdate() < 1) - return null; - - ResultSet set = statement.getGeneratedKeys(); - if(set.next()) { - int commentId = set.getInt(1); - createdComment = new ForumThreadComment(commentId, thread.getThreadId(), poster.getHabboInfo().getId(), message, timestamp, ForumThreadState.OPEN, 0); - - Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment)); - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return createdComment; - } } 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 fcd4adf2..4e044b98 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 @@ -8,26 +8,21 @@ public enum ForumThreadState { private int stateId; - public int getStateId() - { - return this.stateId; - } - - ForumThreadState(int stateId) - { + ForumThreadState(int stateId) { this.stateId = stateId; } - public static ForumThreadState fromValue(int value) - { - for (ForumThreadState state : ForumThreadState.values()) - { - if (state.stateId == value) - { + public static ForumThreadState fromValue(int value) { + for (ForumThreadState state : ForumThreadState.values()) { + if (state.stateId == value) { return state; } } return CLOSED; } + + public int getStateId() { + return this.stateId; + } } 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 c9e69b8a..1593623b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java @@ -8,55 +8,44 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -public class HallOfFame -{ +public class HallOfFame { private final THashMap winners = new THashMap<>(); private String competitionName; - public HallOfFame() - { + public HallOfFame() { this.setCompetitionName("xmasRoomComp"); this.reload(); } - public void reload() - { + public void reload() { this.winners.clear(); - synchronized (this.winners) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery(Emulator.getConfig().getValue("hotelview.halloffame.query"))) - { - while (set.next()) - { + synchronized (this.winners) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery(Emulator.getConfig().getValue("hotelview.halloffame.query"))) { + while (set.next()) { HallOfFameWinner winner = new HallOfFameWinner(set); this.winners.put(winner.getId(), winner); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public THashMap getWinners() - { + public THashMap getWinners() { return this.winners; } - public String getCompetitionName() - { + public String getCompetitionName() { return this.competitionName; } - void setCompetitionName(String name) - { + 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 0a71abaa..998de6f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.hotelview; import java.sql.ResultSet; import java.sql.SQLException; -public class HallOfFameWinner implements Comparable -{ +public class HallOfFameWinner implements Comparable { private int id; @@ -17,8 +16,7 @@ public class HallOfFameWinner implements Comparable private int points; - public HallOfFameWinner(ResultSet set) throws SQLException - { + public HallOfFameWinner(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.username = set.getString("username"); this.look = set.getString("look"); @@ -26,32 +24,27 @@ public class HallOfFameWinner implements Comparable } - public int getId() - { + public int getId() { return this.id; } - public String getUsername() - { + public String getUsername() { return this.username; } - public String getLook() - { + public String getLook() { return this.look; } - public int getPoints() - { + public int getPoints() { return this.points; } @Override - public int compareTo(HallOfFameWinner o) - { + 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 b0a88504..b097edcd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java @@ -2,13 +2,11 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; -public class HotelViewManager -{ +public class HotelViewManager { private final HallOfFame hallOfFame; private final NewsList newsList; - public HotelViewManager() - { + public HotelViewManager() { long millis = System.currentTimeMillis(); this.hallOfFame = new HallOfFame(); this.newsList = new NewsList(); @@ -16,18 +14,15 @@ public class HotelViewManager Emulator.getLogging().logStart("Hotelview Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public HallOfFame getHallOfFame() - { + public HallOfFame getHallOfFame() { return this.hallOfFame; } - public NewsList getNewsList() - { + public NewsList getNewsList() { return this.newsList; } - public void dispose() - { + public void dispose() { Emulator.getLogging().logShutdownLine("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 ee961558..8be6fd7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java @@ -8,39 +8,30 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -public class NewsList -{ +public class NewsList { private final ArrayList newsWidgets; - public NewsList() - { + public NewsList() { this.newsWidgets = new ArrayList<>(); this.reload(); } - public void reload() - { - synchronized (this.newsWidgets) - { + public void reload() { + synchronized (this.newsWidgets) { this.newsWidgets.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM hotelview_news ORDER BY id DESC LIMIT 10")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM hotelview_news ORDER BY id DESC LIMIT 10")) { + while (set.next()) { this.newsWidgets.add(new NewsWidget(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public ArrayList getNewsWidgets() - { + public ArrayList getNewsWidgets() { return this.newsWidgets; } } 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 380b0b34..bb309763 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsWidget.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.hotelview; import java.sql.ResultSet; import java.sql.SQLException; -public class NewsWidget -{ +public class NewsWidget { private int id; @@ -26,8 +25,7 @@ public class NewsWidget private String image; - public NewsWidget(ResultSet set) throws SQLException - { + public NewsWidget(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.title = set.getString("title"); this.message = set.getString("text"); @@ -38,44 +36,37 @@ public class NewsWidget } - public int getId() - { + public int getId() { return this.id; } - public String getTitle() - { + public String getTitle() { return this.title; } - public String getMessage() - { + public String getMessage() { return this.message; } - public String getButtonMessage() - { + public String getButtonMessage() { return this.buttonMessage; } - public int getType() - { + public int getType() { return this.type; } - public String getLink() - { + public String getLink() { return this.link; } - public String getImage() - { + 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 ef8d53b5..f3dbafe7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -8,20 +8,18 @@ import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; -public class CrackableReward -{ +public class CrackableReward { public final int itemId; public final int count; public final Map> prizes; - public int totalChance; public final String achievementTick; public final String achievementCracked; public final int requiredEffect; public final int subscriptionDuration; public final RedeemableSubscriptionType subscriptionType; + public int totalChance; - public CrackableReward(ResultSet set) throws SQLException - { + public CrackableReward(ResultSet set) throws SQLException { this.itemId = set.getInt("item_id"); this.count = set.getInt("count"); this.achievementTick = set.getString("achievement_tick"); @@ -37,45 +35,35 @@ public class CrackableReward if (set.getString("prizes").isEmpty()) return; this.totalChance = 0; - for (String prize : prizes) - { - try - { + for (String prize : prizes) { + try { int itemId = 0; int chance = 100; - if (prize.contains(":") && prize.split(":").length == 2) - { + if (prize.contains(":") && prize.split(":").length == 2) { itemId = Integer.valueOf(prize.split(":")[0]); chance = Integer.valueOf(prize.split(":")[1]); - } - else - { + } else { itemId = Integer.valueOf(prize.replace(":", "")); } this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance)); this.totalChance += chance; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } } - public int getRandomReward() - { + public int getRandomReward() { if (this.prizes.size() == 0) return 0; int random = Emulator.getRandom().nextInt(this.totalChance); int notFound = 0; - for (Map.Entry> set : this.prizes.entrySet()) - { + for (Map.Entry> set : this.prizes.entrySet()) { notFound = set.getKey(); - if (random >= set.getValue().getKey() && random < set.getValue().getValue()) - { + if (random >= set.getValue().getKey() && random < set.getValue().getValue()) { return set.getKey(); } } 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 b7c938a6..f22fc5bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/FurnitureType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items; -public enum FurnitureType -{ +public enum FurnitureType { FLOOR("S"), WALL("I"), EFFECT("E"), @@ -12,15 +11,12 @@ public enum FurnitureType public final String code; - FurnitureType(String code) - { + FurnitureType(String code) { this.code = code; } - public static FurnitureType fromString(String code) - { - switch (code.toUpperCase()) - { + public static FurnitureType fromString(String code) { + switch (code.toUpperCase()) { case "S": return FLOOR; case "I": diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ICycleable.java b/src/main/java/com/eu/habbo/habbohotel/items/ICycleable.java index 6474c897..223c09e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ICycleable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ICycleable.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.habbohotel.rooms.Room; -public interface ICycleable -{ +public interface ICycleable { void cycle(Room room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java index 67e4a4e2..788f92d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -public interface IEventTriggers -{ +public interface IEventTriggers { void onClick(GameClient client, Room room, Object[] objects) throws Exception; void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception; 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 06b61a31..1a28b743 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -36,18 +36,36 @@ public class Item { private ItemInteraction interactionType; - public Item(ResultSet set) throws SQLException - { + public Item(ResultSet set) throws SQLException { this.load(set); } - public void update(ResultSet set) throws SQLException - { + public static boolean isPet(Item item) { + return item.getName().toLowerCase().startsWith("a0 pet"); + } + + public static double getCurrentHeight(HabboItem item) { + if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) { + if (item.getExtradata().isEmpty()) { + item.setExtradata("0"); + } + + try { + int index = Integer.valueOf(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length); + return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)]; + } catch (Exception e) { + + } + } + + return item.getBaseItem().getHeight(); + } + + public void update(ResultSet set) throws SQLException { this.load(set); } - private void load(ResultSet set) throws SQLException - { + private void load(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.spriteId = set.getInt("sprite_id"); this.name = set.getString("item_name"); @@ -56,8 +74,7 @@ public class Item { this.width = set.getShort("width"); this.length = set.getShort("length"); this.height = set.getDouble("stack_height"); - if (this.height == 0) - { + if (this.height == 0) { this.height = 1e-6; } this.allowStack = set.getBoolean("allow_stack"); @@ -76,180 +93,122 @@ public class Item { this.effectM = set.getShort("effect_id_male"); this.effectF = set.getShort("effect_id_female"); this.customParams = set.getString("customparams"); - if(!set.getString("vending_ids").isEmpty()) - { + if (!set.getString("vending_ids").isEmpty()) { this.vendingItems = new TIntArrayList(); String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(","); - for (String s : vendingIds) - { + for (String s : vendingIds) { this.vendingItems.add(Integer.valueOf(s.replace(" ", ""))); } } //if(this.interactionType.getType() == InteractionMultiHeight.class || this.interactionType.getType().isAssignableFrom(InteractionMultiHeight.class)) { - if(set.getString("multiheight").contains(";")) - { + if (set.getString("multiheight").contains(";")) { String[] s = set.getString("multiheight").split(";"); this.multiHeights = new double[s.length]; - for(int i = 0; i < s.length; i++) - { + for (int i = 0; i < s.length; i++) { this.multiHeights[i] = Double.parseDouble(s[i]); } - } - else - { + } else { this.multiHeights = new double[0]; } } } - public int getId() - { + public int getId() { return this.id; } - public int getSpriteId() - { + public int getSpriteId() { return this.spriteId; } - public String getName() - { + public String getName() { return this.name; } - public String getFullName() - { + public String getFullName() { return this.fullName; } - public FurnitureType getType() - { + public FurnitureType getType() { return this.type; } - public int getWidth() - { + public int getWidth() { return this.width; } - public int getLength() - { + public int getLength() { return this.length; } - public double getHeight() - { + public double getHeight() { return this.height; } - public boolean allowStack() - { + public boolean allowStack() { return this.allowStack; } - public boolean allowWalk() - { + public boolean allowWalk() { return this.allowWalk; } - public boolean allowSit() - { + public boolean allowSit() { return this.allowSit; } - public boolean allowLay() - { + public boolean allowLay() { return this.allowLay; } - public boolean allowRecyle() - { + public boolean allowRecyle() { return this.allowRecyle; } - public boolean allowTrade() - { + public boolean allowTrade() { return this.allowTrade; } - public boolean allowMarketplace() - { + public boolean allowMarketplace() { return this.allowMarketplace; } - public boolean allowGift() - { + public boolean allowGift() { return this.allowGift; } - public boolean allowInventoryStack() - { + public boolean allowInventoryStack() { return this.allowInventoryStack; } - public int getStateCount() - { + public int getStateCount() { return this.stateCount; } - public int getEffectM() - { + public int getEffectM() { return this.effectM; } - public int getEffectF() - { + public int getEffectF() { return this.effectF; } - public ItemInteraction getInteractionType() - { + public ItemInteraction getInteractionType() { return this.interactionType; } - public TIntArrayList getVendingItems() - { + public TIntArrayList getVendingItems() { return this.vendingItems; } - public int getRandomVendingItem() - { + public int getRandomVendingItem() { return this.vendingItems.get(Emulator.getRandom().nextInt(this.vendingItems.size())); } - public double[] getMultiHeights() - { + public double[] getMultiHeights() { return this.multiHeights; } - - public static boolean isPet(Item item) - { - return item.getName().toLowerCase().startsWith("a0 pet"); - } - - public static double getCurrentHeight(HabboItem item) - { - if(item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) - { - if (item.getExtradata().isEmpty()) - { - item.setExtradata("0"); - } - - try - { - int index = Integer.valueOf(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length); - return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)]; - } - catch (Exception e) - { - - } - } - - return item.getBaseItem().getHeight(); - } } 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 6bda6e67..2e07ba22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java @@ -2,27 +2,23 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.habbohotel.users.HabboItem; -public class ItemInteraction -{ +public class ItemInteraction { private final String name; private final Class type; - public ItemInteraction(String name, Class type) - { + public ItemInteraction(String name, Class type) { this.name = name; this.type = type; } - public Class getType() - { + public Class getType() { return this.type; } - public String getName() - { + 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 cfeef773..16a86a43 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -61,8 +61,7 @@ import java.lang.reflect.Constructor; import java.sql.*; import java.util.*; -public class ItemManager -{ +public class ItemManager { //Configuration. Loaded from database & updated accordingly. public static boolean RECYCLER_ENABLED = true; @@ -73,18 +72,16 @@ public class ItemManager private final YoutubeManager youtubeManager; private final TreeMap newuserGifts; - public ItemManager() - { - this.items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); - this.crackableRewards = new TIntObjectHashMap<>(); - this.interactionsList = new THashSet<>(); - this.soundTracks = new THashMap<>(); - this.youtubeManager = new YoutubeManager(); - this.newuserGifts = new TreeMap<>(); + public ItemManager() { + this.items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + this.crackableRewards = new TIntObjectHashMap<>(); + this.interactionsList = new THashSet<>(); + this.soundTracks = new THashMap<>(); + this.youtubeManager = new YoutubeManager(); + this.newuserGifts = new TreeMap<>(); } - public void load() - { + public void load() { Emulator.getPluginManager().fireEvent(new EmulatorLoadItemsManagerEvent()); long millis = System.currentTimeMillis(); @@ -99,266 +96,262 @@ public class ItemManager Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - protected void loadItemInteractions() - { - this.interactionsList.add(new ItemInteraction("default", InteractionDefault.class)); - this.interactionsList.add(new ItemInteraction("gate", InteractionGate.class)); - this.interactionsList.add(new ItemInteraction("guild_furni", InteractionGuildFurni.class)); - this.interactionsList.add(new ItemInteraction("guild_gate", InteractionGuildGate.class)); - this.interactionsList.add(new ItemInteraction("background_toner", InteractionBackgroundToner.class)); - this.interactionsList.add(new ItemInteraction("badge_display", InteractionBadgeDisplay.class)); - this.interactionsList.add(new ItemInteraction("mannequin", InteractionMannequin.class)); - this.interactionsList.add(new ItemInteraction("ads_bg", InteractionRoomAds.class)); - this.interactionsList.add(new ItemInteraction("trophy", InteractionTrophy.class)); - this.interactionsList.add(new ItemInteraction("vendingmachine", InteractionVendingMachine.class)); - this.interactionsList.add(new ItemInteraction("pressureplate", InteractionPressurePlate.class)); - this.interactionsList.add(new ItemInteraction("colorplate", InteractionColorPlate.class)); - this.interactionsList.add(new ItemInteraction("multiheight", InteractionMultiHeight.class)); - this.interactionsList.add(new ItemInteraction("dice", InteractionDice.class)); - this.interactionsList.add(new ItemInteraction("colorwheel", InteractionColorWheel.class)); - this.interactionsList.add(new ItemInteraction("cannon", InteractionCannon.class)); - this.interactionsList.add(new ItemInteraction("teleport", InteractionTeleport.class)); - this.interactionsList.add(new ItemInteraction("teleporttile", InteractionTeleportTile.class)); - this.interactionsList.add(new ItemInteraction("crackable", InteractionCrackable.class)); - this.interactionsList.add(new ItemInteraction("crackable_master", InteractionCrackableMaster.class)); - this.interactionsList.add(new ItemInteraction("nest", InteractionNest.class)); - this.interactionsList.add(new ItemInteraction("pet_drink", InteractionPetDrink.class)); - this.interactionsList.add(new ItemInteraction("pet_food", InteractionPetFood.class)); - this.interactionsList.add(new ItemInteraction("pet_toy", InteractionPetToy.class)); - this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class)); - this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class)); - this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class)); - this.interactionsList.add(new ItemInteraction("gift", InteractionGift.class)); - this.interactionsList.add(new ItemInteraction("stack_helper", InteractionStackHelper.class)); - this.interactionsList.add(new ItemInteraction("puzzle_box", InteractionPuzzleBox.class)); - this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class)); - this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class)); - this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class)); - this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class)); - this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class)); - this.interactionsList.add(new ItemInteraction("onewaygate", InteractionOneWayGate.class)); - this.interactionsList.add(new ItemInteraction("love_lock", InteractionLoveLock.class)); - this.interactionsList.add(new ItemInteraction("clothing", InteractionClothing.class)); - this.interactionsList.add(new ItemInteraction("roller", InteractionRoller.class)); - this.interactionsList.add(new ItemInteraction("postit", InteractionPostIt.class)); - this.interactionsList.add(new ItemInteraction("dimmer", InteractionMoodLight.class)); - this.interactionsList.add(new ItemInteraction("rentable_space", InteractionRentableSpace.class)); - this.interactionsList.add(new ItemInteraction("pyramid", InteractionPyramid.class)); - this.interactionsList.add(new ItemInteraction("musicdisc", InteractionMusicDisc.class)); - this.interactionsList.add(new ItemInteraction("fireworks", InteractionFireworks.class)); - this.interactionsList.add(new ItemInteraction("talking_furni", InteractionTalkingFurniture.class)); - this.interactionsList.add(new ItemInteraction("water_item", InteractionWaterItem.class)); - this.interactionsList.add(new ItemInteraction("water", InteractionWater.class)); - this.interactionsList.add(new ItemInteraction("viking_cotie", InteractionVikingCotie.class)); - this.interactionsList.add(new ItemInteraction("tile_fxprovider_nfs", InteractionTileEffectProvider.class)); - this.interactionsList.add(new ItemInteraction("mutearea", InteractionMuteArea.class)); - this.interactionsList.add(new ItemInteraction("information_terminal", InteractionInformationTerminal.class)); - this.interactionsList.add(new ItemInteraction("external_image", InteractionExternalImage.class)); - this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class)); - this.interactionsList.add(new ItemInteraction("jukebox", InteractionJukeBox.class)); - this.interactionsList.add(new ItemInteraction("switch", InteractionSwitch.class)); - this.interactionsList.add(new ItemInteraction("fx_box", InteractionFXBox.class)); - this.interactionsList.add(new ItemInteraction("blackhole", InteractionBlackHole.class)); - this.interactionsList.add(new ItemInteraction("effect_toggle", InteractionEffectToggle.class)); - this.interactionsList.add(new ItemInteraction("room_o_matic", InteractionRoomOMatic.class)); - this.interactionsList.add(new ItemInteraction("effect_tile", InteractionEffectTile.class)); - this.interactionsList.add(new ItemInteraction("sticky_pole", InteractionStickyPole.class)); - this.interactionsList.add(new ItemInteraction("trap", InteractionTrap.class)); - this.interactionsList.add(new ItemInteraction("tent", InteractionTent.class)); - this.interactionsList.add(new ItemInteraction("gym_equipment", InteractionGymEquipment.class)); - this.interactionsList.add(new ItemInteraction("handitem", InteractionHanditem.class)); - this.interactionsList.add(new ItemInteraction("handitem_tile", InteractionHanditemTile.class)); - this.interactionsList.add(new ItemInteraction("effect_giver", InteractionEffectGiver.class)); - this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class)); - this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class)); - this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class)); - this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class)); - this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class)); - this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); + protected void loadItemInteractions() { + this.interactionsList.add(new ItemInteraction("default", InteractionDefault.class)); + this.interactionsList.add(new ItemInteraction("gate", InteractionGate.class)); + this.interactionsList.add(new ItemInteraction("guild_furni", InteractionGuildFurni.class)); + this.interactionsList.add(new ItemInteraction("guild_gate", InteractionGuildGate.class)); + this.interactionsList.add(new ItemInteraction("background_toner", InteractionBackgroundToner.class)); + this.interactionsList.add(new ItemInteraction("badge_display", InteractionBadgeDisplay.class)); + this.interactionsList.add(new ItemInteraction("mannequin", InteractionMannequin.class)); + this.interactionsList.add(new ItemInteraction("ads_bg", InteractionRoomAds.class)); + this.interactionsList.add(new ItemInteraction("trophy", InteractionTrophy.class)); + this.interactionsList.add(new ItemInteraction("vendingmachine", InteractionVendingMachine.class)); + this.interactionsList.add(new ItemInteraction("pressureplate", InteractionPressurePlate.class)); + this.interactionsList.add(new ItemInteraction("colorplate", InteractionColorPlate.class)); + this.interactionsList.add(new ItemInteraction("multiheight", InteractionMultiHeight.class)); + this.interactionsList.add(new ItemInteraction("dice", InteractionDice.class)); + this.interactionsList.add(new ItemInteraction("colorwheel", InteractionColorWheel.class)); + this.interactionsList.add(new ItemInteraction("cannon", InteractionCannon.class)); + this.interactionsList.add(new ItemInteraction("teleport", InteractionTeleport.class)); + this.interactionsList.add(new ItemInteraction("teleporttile", InteractionTeleportTile.class)); + this.interactionsList.add(new ItemInteraction("crackable", InteractionCrackable.class)); + this.interactionsList.add(new ItemInteraction("crackable_master", InteractionCrackableMaster.class)); + this.interactionsList.add(new ItemInteraction("nest", InteractionNest.class)); + this.interactionsList.add(new ItemInteraction("pet_drink", InteractionPetDrink.class)); + this.interactionsList.add(new ItemInteraction("pet_food", InteractionPetFood.class)); + this.interactionsList.add(new ItemInteraction("pet_toy", InteractionPetToy.class)); + this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class)); + this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class)); + this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class)); + this.interactionsList.add(new ItemInteraction("gift", InteractionGift.class)); + this.interactionsList.add(new ItemInteraction("stack_helper", InteractionStackHelper.class)); + this.interactionsList.add(new ItemInteraction("puzzle_box", InteractionPuzzleBox.class)); + this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class)); + this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class)); + this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class)); + this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class)); + this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class)); + this.interactionsList.add(new ItemInteraction("onewaygate", InteractionOneWayGate.class)); + this.interactionsList.add(new ItemInteraction("love_lock", InteractionLoveLock.class)); + this.interactionsList.add(new ItemInteraction("clothing", InteractionClothing.class)); + this.interactionsList.add(new ItemInteraction("roller", InteractionRoller.class)); + this.interactionsList.add(new ItemInteraction("postit", InteractionPostIt.class)); + this.interactionsList.add(new ItemInteraction("dimmer", InteractionMoodLight.class)); + this.interactionsList.add(new ItemInteraction("rentable_space", InteractionRentableSpace.class)); + this.interactionsList.add(new ItemInteraction("pyramid", InteractionPyramid.class)); + this.interactionsList.add(new ItemInteraction("musicdisc", InteractionMusicDisc.class)); + this.interactionsList.add(new ItemInteraction("fireworks", InteractionFireworks.class)); + this.interactionsList.add(new ItemInteraction("talking_furni", InteractionTalkingFurniture.class)); + this.interactionsList.add(new ItemInteraction("water_item", InteractionWaterItem.class)); + this.interactionsList.add(new ItemInteraction("water", InteractionWater.class)); + this.interactionsList.add(new ItemInteraction("viking_cotie", InteractionVikingCotie.class)); + this.interactionsList.add(new ItemInteraction("tile_fxprovider_nfs", InteractionTileEffectProvider.class)); + this.interactionsList.add(new ItemInteraction("mutearea", InteractionMuteArea.class)); + this.interactionsList.add(new ItemInteraction("information_terminal", InteractionInformationTerminal.class)); + this.interactionsList.add(new ItemInteraction("external_image", InteractionExternalImage.class)); + this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class)); + this.interactionsList.add(new ItemInteraction("jukebox", InteractionJukeBox.class)); + this.interactionsList.add(new ItemInteraction("switch", InteractionSwitch.class)); + this.interactionsList.add(new ItemInteraction("fx_box", InteractionFXBox.class)); + this.interactionsList.add(new ItemInteraction("blackhole", InteractionBlackHole.class)); + this.interactionsList.add(new ItemInteraction("effect_toggle", InteractionEffectToggle.class)); + this.interactionsList.add(new ItemInteraction("room_o_matic", InteractionRoomOMatic.class)); + this.interactionsList.add(new ItemInteraction("effect_tile", InteractionEffectTile.class)); + this.interactionsList.add(new ItemInteraction("sticky_pole", InteractionStickyPole.class)); + this.interactionsList.add(new ItemInteraction("trap", InteractionTrap.class)); + this.interactionsList.add(new ItemInteraction("tent", InteractionTent.class)); + this.interactionsList.add(new ItemInteraction("gym_equipment", InteractionGymEquipment.class)); + this.interactionsList.add(new ItemInteraction("handitem", InteractionHanditem.class)); + this.interactionsList.add(new ItemInteraction("handitem_tile", InteractionHanditemTile.class)); + this.interactionsList.add(new ItemInteraction("effect_giver", InteractionEffectGiver.class)); + this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class)); + this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class)); + this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class)); + this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class)); + this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class)); + this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class)); - - this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerHabboEntersRoom.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerHabboSaysKeyword.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_periodically", WiredTriggerRepeater.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_period_long", WiredTriggerRepeaterLong.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_state_changed", WiredTriggerFurniStateToggled.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_at_given_time", WiredTriggerAtSetTime.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_at_time_long", WiredTriggerAtTimeLong.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_collision", WiredTriggerCollision.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_game_starts", WiredTriggerGameStarts.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_game_ends", WiredTriggerGameEnds.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_stf", WiredTriggerBotReachedFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_says_command", WiredTriggerHabboSaysCommand.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_idles", WiredTriggerHabboIdle.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_starts_dancing", WiredTriggerHabboStartsDancing.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_stops_dancing", WiredTriggerHabboStopsDancing.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerHabboEntersRoom.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerHabboSaysKeyword.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_periodically", WiredTriggerRepeater.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_period_long", WiredTriggerRepeaterLong.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_state_changed", WiredTriggerFurniStateToggled.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_at_given_time", WiredTriggerAtSetTime.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_at_time_long", WiredTriggerAtTimeLong.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_collision", WiredTriggerCollision.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_game_starts", WiredTriggerGameStarts.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_game_ends", WiredTriggerGameEnds.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_stf", WiredTriggerBotReachedFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_says_command", WiredTriggerHabboSaysCommand.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_idles", WiredTriggerHabboIdle.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_starts_dancing", WiredTriggerHabboStartsDancing.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_stops_dancing", WiredTriggerHabboStopsDancing.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class)); - this.interactionsList.add(new ItemInteraction("wf_act_toggle_state", WiredEffectToggleFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_reset_timers", WiredEffectResetTimers.class)); - this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot", WiredEffectMatchFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_move_rotate", WiredEffectMoveRotateFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_score", WiredEffectGiveScore.class)); - this.interactionsList.add(new ItemInteraction("wf_act_show_message", WiredEffectWhisper.class)); - this.interactionsList.add(new ItemInteraction("wf_act_teleport_to", WiredEffectTeleport.class)); - this.interactionsList.add(new ItemInteraction("wf_act_join_team", WiredEffectJoinTeam.class)); - this.interactionsList.add(new ItemInteraction("wf_act_leave_team", WiredEffectLeaveTeam.class)); - this.interactionsList.add(new ItemInteraction("wf_act_chase", WiredEffectMoveFurniTowards.class)); - this.interactionsList.add(new ItemInteraction("wf_act_flee", WiredEffectMoveFurniAway.class)); - this.interactionsList.add(new ItemInteraction("wf_act_move_to_dir", WiredEffectChangeFurniDirection.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_score_tm", WiredEffectGiveScoreToTeam.class)); - this.interactionsList.add(new ItemInteraction("wf_act_toggle_to_rnd", WiredEffectToggleRandom.class)); - this.interactionsList.add(new ItemInteraction("wf_act_move_furni_to", WiredEffectMoveFurniTo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_reward", WiredEffectGiveReward.class)); - this.interactionsList.add(new ItemInteraction("wf_act_call_stacks", WiredEffectTriggerStacks.class)); - this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_teleport", WiredEffectBotTeleport.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_move", WiredEffectBotWalkToFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_talk", WiredEffectBotTalk.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_give_handitem", WiredEffectBotGiveHandItem.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_clothes", WiredEffectBotClothes.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_diamonds", WiredEffectGiveDiamonds.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_credits", WiredEffectGiveCredits.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_duckets", WiredEffectGiveDuckets.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_badge", WiredEffectGiveBadge.class)); - this.interactionsList.add(new ItemInteraction("wf_act_forward_user", WiredEffectForwardToRoom.class)); - this.interactionsList.add(new ItemInteraction("wf_act_roller_speed", WiredEffectRollerSpeed.class)); - this.interactionsList.add(new ItemInteraction("wf_act_raise_furni", WiredEffectRaiseFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_lower_furni", WiredEffectLowerFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_respect", WiredEffectGiveRespect.class)); - this.interactionsList.add(new ItemInteraction("wf_act_alert", WiredEffectAlert.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class)); - this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot2", WiredEffectMatchFurniStaff.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class)); - this.interactionsList.add(new ItemInteraction("wf_act_open_habbo_pages", WiredEffectOpenHabboPages.class)); - this.interactionsList.add(new ItemInteraction("wf_act_give_achievement", WiredEffectGiveAchievement.class)); + this.interactionsList.add(new ItemInteraction("wf_act_toggle_state", WiredEffectToggleFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_reset_timers", WiredEffectResetTimers.class)); + this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot", WiredEffectMatchFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_move_rotate", WiredEffectMoveRotateFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_score", WiredEffectGiveScore.class)); + this.interactionsList.add(new ItemInteraction("wf_act_show_message", WiredEffectWhisper.class)); + this.interactionsList.add(new ItemInteraction("wf_act_teleport_to", WiredEffectTeleport.class)); + this.interactionsList.add(new ItemInteraction("wf_act_join_team", WiredEffectJoinTeam.class)); + this.interactionsList.add(new ItemInteraction("wf_act_leave_team", WiredEffectLeaveTeam.class)); + this.interactionsList.add(new ItemInteraction("wf_act_chase", WiredEffectMoveFurniTowards.class)); + this.interactionsList.add(new ItemInteraction("wf_act_flee", WiredEffectMoveFurniAway.class)); + this.interactionsList.add(new ItemInteraction("wf_act_move_to_dir", WiredEffectChangeFurniDirection.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_score_tm", WiredEffectGiveScoreToTeam.class)); + this.interactionsList.add(new ItemInteraction("wf_act_toggle_to_rnd", WiredEffectToggleRandom.class)); + this.interactionsList.add(new ItemInteraction("wf_act_move_furni_to", WiredEffectMoveFurniTo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_reward", WiredEffectGiveReward.class)); + this.interactionsList.add(new ItemInteraction("wf_act_call_stacks", WiredEffectTriggerStacks.class)); + this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_teleport", WiredEffectBotTeleport.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_move", WiredEffectBotWalkToFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_talk", WiredEffectBotTalk.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_give_handitem", WiredEffectBotGiveHandItem.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_clothes", WiredEffectBotClothes.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_diamonds", WiredEffectGiveDiamonds.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_credits", WiredEffectGiveCredits.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_duckets", WiredEffectGiveDuckets.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_badge", WiredEffectGiveBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_act_forward_user", WiredEffectForwardToRoom.class)); + this.interactionsList.add(new ItemInteraction("wf_act_roller_speed", WiredEffectRollerSpeed.class)); + this.interactionsList.add(new ItemInteraction("wf_act_raise_furni", WiredEffectRaiseFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_lower_furni", WiredEffectLowerFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_respect", WiredEffectGiveRespect.class)); + this.interactionsList.add(new ItemInteraction("wf_act_alert", WiredEffectAlert.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class)); + this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot2", WiredEffectMatchFurniStaff.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class)); + this.interactionsList.add(new ItemInteraction("wf_act_open_habbo_pages", WiredEffectOpenHabboPages.class)); + this.interactionsList.add(new ItemInteraction("wf_act_give_achievement", WiredEffectGiveAchievement.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_stuff_is", WiredConditionFurniTypeMatch.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_group", WiredConditionGroupMember.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionHabboCount.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionHabboHasEffect.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionHabboWearsBadge.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_time_less_than", WiredConditionLessTimeElapsed.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_match_snapshot", WiredConditionMatchStatePosition.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_time_more_than", WiredConditionMoreTimeElapsed.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_furni_on", WiredConditionNotFurniHaveFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_stuff_is", WiredConditionNotFurniTypeMatch.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotHabboCount.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotHabboHasEffect.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotHabboWearsBadge.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_group", WiredConditionNotInGroup.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_team", WiredConditionNotInTeam.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_match_snap", WiredConditionNotMatchStatePosition.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_trggrer_on", WiredConditionNotTriggerOnFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_team", WiredConditionTeamMember.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_motto_contains", WiredConditionMottoContains.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_battlebanzai", WiredConditionBattleBanzaiGameActive.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_battlebanzai", WiredConditionNotBattleBanzaiGameActive.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_freeze", WiredConditionFreezeGameActive.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_freeze", WiredConditionNotFreezeGameActive.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_rank", WiredConditionHabboHasRank.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_not_rank", WiredConditionHabboNotRank.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_credits", WiredConditionHabboHasCredits.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_duckets", WiredConditionHabboHasDuckets.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_diamonds", WiredConditionNotHabboHasDiamonds.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_credits", WiredConditionNotHabboHasCredits.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_duckets", WiredConditionNotHabboHasDuckets.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_owns_badge", WiredConditionHabboOwnsBadge.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_owns_badge", WiredConditionNotHabboOwnsBadge.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_is_dancing", WiredConditionHabboIsDancing.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_is_dancing", WiredConditionNotHabboIsDancing.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_stuff_is", WiredConditionFurniTypeMatch.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_group", WiredConditionGroupMember.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionHabboCount.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionHabboHasEffect.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionHabboWearsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_time_less_than", WiredConditionLessTimeElapsed.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_match_snapshot", WiredConditionMatchStatePosition.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_time_more_than", WiredConditionMoreTimeElapsed.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_furni_on", WiredConditionNotFurniHaveFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_stuff_is", WiredConditionNotFurniTypeMatch.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotHabboCount.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotHabboHasEffect.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotHabboWearsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_group", WiredConditionNotInGroup.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_team", WiredConditionNotInTeam.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_match_snap", WiredConditionNotMatchStatePosition.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_trggrer_on", WiredConditionNotTriggerOnFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_team", WiredConditionTeamMember.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_motto_contains", WiredConditionMottoContains.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_battlebanzai", WiredConditionBattleBanzaiGameActive.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_battlebanzai", WiredConditionNotBattleBanzaiGameActive.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_freeze", WiredConditionFreezeGameActive.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_freeze", WiredConditionNotFreezeGameActive.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_rank", WiredConditionHabboHasRank.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_not_rank", WiredConditionHabboNotRank.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_credits", WiredConditionHabboHasCredits.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_duckets", WiredConditionHabboHasDuckets.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_diamonds", WiredConditionNotHabboHasDiamonds.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_credits", WiredConditionNotHabboHasCredits.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_duckets", WiredConditionNotHabboHasDuckets.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_owns_badge", WiredConditionHabboOwnsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_owns_badge", WiredConditionNotHabboOwnsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_is_dancing", WiredConditionHabboIsDancing.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_is_dancing", WiredConditionNotHabboIsDancing.class)); - this.interactionsList.add(new ItemInteraction("wf_xtra_random", WiredExtraRandom.class)); - this.interactionsList.add(new ItemInteraction("wf_xtra_unseen", WiredExtraUnseen.class)); - this.interactionsList.add(new ItemInteraction("wf_blob", WiredBlob.class)); + this.interactionsList.add(new ItemInteraction("wf_xtra_random", WiredExtraRandom.class)); + this.interactionsList.add(new ItemInteraction("wf_xtra_unseen", WiredExtraUnseen.class)); + this.interactionsList.add(new ItemInteraction("wf_blob", WiredBlob.class)); - this.interactionsList.add(new ItemInteraction("wf_highscore", InteractionWiredHighscore.class)); + this.interactionsList.add(new ItemInteraction("wf_highscore", InteractionWiredHighscore.class)); - - //battlebanzai_pyramid - //battlebanzai_puck extends pushable - this.interactionsList.add(new ItemInteraction("battlebanzai_timer", InteractionBattleBanzaiTimer.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_tile", InteractionBattleBanzaiTile.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_random_teleport", InteractionBattleBanzaiTeleporter.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_sphere", InteractionBattleBanzaiSphere.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_puck", InteractionBattleBanzaiPuck.class)); + //battlebanzai_pyramid + //battlebanzai_puck extends pushable + this.interactionsList.add(new ItemInteraction("battlebanzai_timer", InteractionBattleBanzaiTimer.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_tile", InteractionBattleBanzaiTile.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_random_teleport", InteractionBattleBanzaiTeleporter.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_sphere", InteractionBattleBanzaiSphere.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_puck", InteractionBattleBanzaiPuck.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_gate_blue", InteractionBattleBanzaiGateBlue.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_gate_green", InteractionBattleBanzaiGateGreen.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_gate_red", InteractionBattleBanzaiGateRed.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_gate_yellow", InteractionBattleBanzaiGateYellow.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_gate_blue", InteractionBattleBanzaiGateBlue.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_gate_green", InteractionBattleBanzaiGateGreen.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_gate_red", InteractionBattleBanzaiGateRed.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_gate_yellow", InteractionBattleBanzaiGateYellow.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_counter_blue", InteractionBattleBanzaiScoreboardBlue.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_counter_green", InteractionBattleBanzaiScoreboardGreen.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_counter_red", InteractionBattleBanzaiScoreboardRed.class)); - this.interactionsList.add(new ItemInteraction("battlebanzai_counter_yellow", InteractionBattleBanzaiScoreboardYellow.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_counter_blue", InteractionBattleBanzaiScoreboardBlue.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_counter_green", InteractionBattleBanzaiScoreboardGreen.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_counter_red", InteractionBattleBanzaiScoreboardRed.class)); + this.interactionsList.add(new ItemInteraction("battlebanzai_counter_yellow", InteractionBattleBanzaiScoreboardYellow.class)); - - this.interactionsList.add(new ItemInteraction("freeze_block", InteractionFreezeBlock.class)); - this.interactionsList.add(new ItemInteraction("freeze_tile", InteractionFreezeTile.class)); - this.interactionsList.add(new ItemInteraction("freeze_exit", InteractionFreezeExitTile.class)); - this.interactionsList.add(new ItemInteraction("freeze_timer", InteractionFreezeTimer.class)); + this.interactionsList.add(new ItemInteraction("freeze_block", InteractionFreezeBlock.class)); + this.interactionsList.add(new ItemInteraction("freeze_tile", InteractionFreezeTile.class)); + this.interactionsList.add(new ItemInteraction("freeze_exit", InteractionFreezeExitTile.class)); + this.interactionsList.add(new ItemInteraction("freeze_timer", InteractionFreezeTimer.class)); - this.interactionsList.add(new ItemInteraction("freeze_gate_blue", InteractionFreezeGateBlue.class)); - this.interactionsList.add(new ItemInteraction("freeze_gate_green", InteractionFreezeGateGreen.class)); - this.interactionsList.add(new ItemInteraction("freeze_gate_red", InteractionFreezeGateRed.class)); - this.interactionsList.add(new ItemInteraction("freeze_gate_yellow", InteractionFreezeGateYellow.class)); + this.interactionsList.add(new ItemInteraction("freeze_gate_blue", InteractionFreezeGateBlue.class)); + this.interactionsList.add(new ItemInteraction("freeze_gate_green", InteractionFreezeGateGreen.class)); + this.interactionsList.add(new ItemInteraction("freeze_gate_red", InteractionFreezeGateRed.class)); + this.interactionsList.add(new ItemInteraction("freeze_gate_yellow", InteractionFreezeGateYellow.class)); - this.interactionsList.add(new ItemInteraction("freeze_counter_blue", InteractionFreezeScoreboardBlue.class)); - this.interactionsList.add(new ItemInteraction("freeze_counter_green", InteractionFreezeScoreboardGreen.class)); - this.interactionsList.add(new ItemInteraction("freeze_counter_red", InteractionFreezeScoreboardRed.class)); - this.interactionsList.add(new ItemInteraction("freeze_counter_yellow", InteractionFreezeScoreboardYellow.class)); + this.interactionsList.add(new ItemInteraction("freeze_counter_blue", InteractionFreezeScoreboardBlue.class)); + this.interactionsList.add(new ItemInteraction("freeze_counter_green", InteractionFreezeScoreboardGreen.class)); + this.interactionsList.add(new ItemInteraction("freeze_counter_red", InteractionFreezeScoreboardRed.class)); + this.interactionsList.add(new ItemInteraction("freeze_counter_yellow", InteractionFreezeScoreboardYellow.class)); - this.interactionsList.add(new ItemInteraction("icetag_pole", InteractionIceTagPole.class)); - this.interactionsList.add(new ItemInteraction("icetag_field", InteractionIceTagField.class)); + this.interactionsList.add(new ItemInteraction("icetag_pole", InteractionIceTagPole.class)); + this.interactionsList.add(new ItemInteraction("icetag_field", InteractionIceTagField.class)); - this.interactionsList.add(new ItemInteraction("bunnyrun_pole", InteractionBunnyrunPole.class)); - this.interactionsList.add(new ItemInteraction("bunnyrun_field", InteractionBunnyrunField.class)); + this.interactionsList.add(new ItemInteraction("bunnyrun_pole", InteractionBunnyrunPole.class)); + this.interactionsList.add(new ItemInteraction("bunnyrun_field", InteractionBunnyrunField.class)); - this.interactionsList.add(new ItemInteraction("rollerskate_field", InteractionRollerskateField.class)); + this.interactionsList.add(new ItemInteraction("rollerskate_field", InteractionRollerskateField.class)); - this.interactionsList.add(new ItemInteraction("football", InteractionFootball.class)); - this.interactionsList.add(new ItemInteraction("football_gate", InteractionFootballGate.class)); - this.interactionsList.add(new ItemInteraction("football_counter_blue", InteractionFootballScoreboardBlue.class)); - this.interactionsList.add(new ItemInteraction("football_counter_green", InteractionFootballScoreboardGreen.class)); - this.interactionsList.add(new ItemInteraction("football_counter_red", InteractionFootballScoreboardRed.class)); - this.interactionsList.add(new ItemInteraction("football_counter_yellow", InteractionFootballScoreboardYellow.class)); - this.interactionsList.add(new ItemInteraction("football_goal_blue", InteractionFootballGoalBlue.class)); - this.interactionsList.add(new ItemInteraction("football_goal_green", InteractionFootballGoalGreen.class)); - this.interactionsList.add(new ItemInteraction("football_goal_red", InteractionFootballGoalRed.class)); - this.interactionsList.add(new ItemInteraction("football_goal_yellow", InteractionFootballGoalYellow.class)); + this.interactionsList.add(new ItemInteraction("football", InteractionFootball.class)); + this.interactionsList.add(new ItemInteraction("football_gate", InteractionFootballGate.class)); + this.interactionsList.add(new ItemInteraction("football_counter_blue", InteractionFootballScoreboardBlue.class)); + this.interactionsList.add(new ItemInteraction("football_counter_green", InteractionFootballScoreboardGreen.class)); + this.interactionsList.add(new ItemInteraction("football_counter_red", InteractionFootballScoreboardRed.class)); + this.interactionsList.add(new ItemInteraction("football_counter_yellow", InteractionFootballScoreboardYellow.class)); + this.interactionsList.add(new ItemInteraction("football_goal_blue", InteractionFootballGoalBlue.class)); + this.interactionsList.add(new ItemInteraction("football_goal_green", InteractionFootballGoalGreen.class)); + this.interactionsList.add(new ItemInteraction("football_goal_red", InteractionFootballGoalRed.class)); + this.interactionsList.add(new ItemInteraction("football_goal_yellow", InteractionFootballGoalYellow.class)); this.interactionsList.add(new ItemInteraction("snowstorm_tree", null)); this.interactionsList.add(new ItemInteraction("snowstorm_machine", null)); @@ -366,24 +359,20 @@ public class ItemManager } - public void addItemInteraction(ItemInteraction itemInteraction) - { - for (ItemInteraction interaction : this.interactionsList) - { - if(interaction.getType() == itemInteraction.getType() || - interaction.getName().equalsIgnoreCase(itemInteraction.getName())) + public void addItemInteraction(ItemInteraction itemInteraction) { + for (ItemInteraction interaction : this.interactionsList) { + if (interaction.getType() == itemInteraction.getType() || + interaction.getName().equalsIgnoreCase(itemInteraction.getName())) - throw new RuntimeException("Interaction Types must be unique. An class with type: " + interaction.getClass().getName() + " was already added OR the key: " + interaction.getName() + " is already in use."); + throw new RuntimeException("Interaction Types must be unique. An class with type: " + interaction.getClass().getName() + " was already added OR the key: " + interaction.getName() + " is already in use."); } this.interactionsList.add(itemInteraction); } - public ItemInteraction getItemInteraction(Class type) - { - for (ItemInteraction interaction : this.interactionsList) - { + public ItemInteraction getItemInteraction(Class type) { + for (ItemInteraction interaction : this.interactionsList) { if (interaction.getType() == type) return interaction; } @@ -393,10 +382,8 @@ public class ItemManager } - public ItemInteraction getItemInteraction(String type) - { - for (ItemInteraction interaction : this.interactionsList) - { + public ItemInteraction getItemInteraction(String type) { + for (ItemInteraction interaction : this.interactionsList) { if (interaction.getName().equalsIgnoreCase(type)) return interaction; } @@ -405,242 +392,181 @@ public class ItemManager } - public void loadItems() - { + public void loadItems() { try ( Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery(("SELECT * FROM items_base ORDER BY id DESC")) - ) - { - while (set.next()) - { - try - { + ) { + while (set.next()) { + try { //Item proxyItem = int id = set.getInt("id"); if (!this.items.containsKey(id)) this.items.put(id, new Item(set)); else this.items.get(id).update(set); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to load Item (" + set.getInt("id") + ")"); Emulator.getLogging().logErrorLine(e); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void loadCrackable() - { + public void loadCrackable() { this.crackableRewards.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_crackable"); ResultSet set = statement.executeQuery()) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_crackable"); ResultSet set = statement.executeQuery()) { + while (set.next()) { CrackableReward reward; - try - { + try { reward = new CrackableReward(set); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("item_id")); Emulator.getLogging().logErrorLine(e); continue; } this.crackableRewards.put(set.getInt("item_id"), reward); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - public int getCrackableCount(int itemId) - { - if(this.crackableRewards.containsKey(itemId)) + public int getCrackableCount(int itemId) { + if (this.crackableRewards.containsKey(itemId)) return this.crackableRewards.get(itemId).count; else return 0; } - public int calculateCrackState(int count, int max, Item baseItem) - { - return (int)Math.floor((1.0D / ((double)max / (double)count) * baseItem.getStateCount())); + public int calculateCrackState(int count, int max, Item baseItem) { + return (int) Math.floor((1.0D / ((double) max / (double) count) * baseItem.getStateCount())); } - public CrackableReward getCrackableData(int itemId) - { + public CrackableReward getCrackableData(int itemId) { return this.crackableRewards.get(itemId); } - public Item getCrackableReward(int itemId) - { + public Item getCrackableReward(int itemId) { return this.getItem(this.crackableRewards.get(itemId).getRandomReward()); } - public void loadSoundTracks() - { + public void loadSoundTracks() { this.soundTracks.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM soundtracks"); ResultSet set = statement.executeQuery()) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM soundtracks"); ResultSet set = statement.executeQuery()) { + while (set.next()) { this.soundTracks.put(set.getString("code"), new SoundTrack(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public SoundTrack getSoundTrack(String code) - { + public SoundTrack getSoundTrack(String code) { return this.soundTracks.get(code); } - public SoundTrack getSoundTrack(int id) - { - for(Map.Entry entry : this.soundTracks.entrySet()) - { - if(entry.getValue().getId() == id) + public SoundTrack getSoundTrack(int id) { + for (Map.Entry entry : this.soundTracks.entrySet()) { + if (entry.getValue().getId() == id) return entry.getValue(); } return null; } - public HabboItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + public HabboItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, habboId); statement.setInt(2, item.getId()); statement.setString(3, extraData); statement.setString(4, limitedStack + ":" + limitedSells); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { Class itemClass = item.getInteractionType().getType(); - if (itemClass != null) - { - try - { + if (itemClass != null) { + 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) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); } } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - public void loadNewUserGifts() - { + public void loadNewUserGifts() { this.newuserGifts.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM nux_gifts")) - { - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM nux_gifts")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.newuserGifts.put(set.getInt("id"), new NewUserGift(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void addNewUserGift(NewUserGift gift) - { + public void addNewUserGift(NewUserGift gift) { this.newuserGifts.put(gift.getId(), gift); } - public void removeNewUserGift(NewUserGift gift) - { + public void removeNewUserGift(NewUserGift gift) { this.newuserGifts.remove(gift.getId()); } - public NewUserGift getNewUserGift(int id) - { + public NewUserGift getNewUserGift(int id) { return this.newuserGifts.get(id); } - public List getNewUserGifts() - { + public List getNewUserGifts() { return new ArrayList<>(this.newuserGifts.values()); } - public void deleteItem(HabboItem item) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) - { + public void deleteItem(HabboItem item) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { statement.setInt(1, item.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public HabboItem handleRecycle(Habbo habbo, String itemId) - { + public HabboItem handleRecycle(Habbo habbo, String itemId) { String extradata = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR); HabboItem item = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getGameEnvironment().getCatalogManager().ecotronItem.getId()); statement.setString(3, extradata); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items_presents VALUES (?, ?)")) - { - while (set.next() && item == null) - { + try (ResultSet set = statement.getGeneratedKeys()) { + 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.addBatch(); @@ -650,46 +576,33 @@ public class ItemManager preparedStatement.executeBatch(); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return item; } - public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box) - { + public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box) { Emulator.getThreading().run(new QueryDeleteHabboItem(box.getId())); HabboItem item = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1")) { statement.setInt(1, box.getId()); - try (ResultSet rewardSet = statement.executeQuery()) - { - if (rewardSet.next()) - { - try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items (user_id, item_id) VALUES(?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (ResultSet rewardSet = statement.executeQuery()) { + if (rewardSet.next()) { + try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items (user_id, item_id) VALUES(?, ?)", Statement.RETURN_GENERATED_KEYS)) { preparedStatement.setInt(1, habbo.getHabboInfo().getId()); preparedStatement.setInt(2, rewardSet.getInt("base_item_reward")); preparedStatement.execute(); - try (ResultSet set = preparedStatement.getGeneratedKeys()) - { - if (set.next()) - { - try (PreparedStatement request = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) - { + try (ResultSet set = preparedStatement.getGeneratedKeys()) { + if (set.next()) { + try (PreparedStatement request = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { request.setInt(1, set.getInt(1)); - try (ResultSet resultSet = request.executeQuery()) - { - if (resultSet.next()) - { - try (PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM items_presents WHERE item_id = ? LIMIT 1")) - { + try (ResultSet resultSet = request.executeQuery()) { + if (resultSet.next()) { + try (PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM items_presents WHERE item_id = ? LIMIT 1")) { deleteStatement.setInt(1, box.getId()); deleteStatement.execute(); @@ -703,116 +616,85 @@ public class ItemManager } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return item; } - public void insertTeleportPair(int itemOneId, int itemTwoId) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_teleports VALUES (?, ?)")) - { + public void insertTeleportPair(int itemOneId, int itemTwoId) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_teleports VALUES (?, ?)")) { statement.setInt(1, itemOneId); statement.setInt(2, itemTwoId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void insertHopper(HabboItem hopper) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_hoppers VALUES (?, ?)")) - { + public void insertHopper(HabboItem hopper) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_hoppers VALUES (?, ?)")) { statement.setInt(1, hopper.getId()); statement.setInt(2, hopper.getBaseItem().getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public int[] getTargetTeleportRoomId(HabboItem item) - { + public int[] getTargetTeleportRoomId(HabboItem item) { int[] a = new int[]{}; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_teleports INNER JOIN items ON items_teleports.teleport_one_id = items.id OR items_teleports.teleport_two_id = items.id WHERE items.id != ? AND items.room_id > 0 LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_teleports INNER JOIN items ON items_teleports.teleport_one_id = items.id OR items_teleports.teleport_two_id = items.id WHERE items.id != ? AND items.room_id > 0 LIMIT 1")) { statement.setInt(1, item.getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { a = new int[]{set.getInt("room_id"), set.getInt("id")}; } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return a; } - public HabboItem loadHabboItem(int itemId) - { + public HabboItem loadHabboItem(int itemId) { HabboItem item = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { statement.setInt(1, itemId); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { item = this.loadHabboItem(set); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return item; } - public HabboItem loadHabboItem(ResultSet set) throws SQLException - { + public HabboItem loadHabboItem(ResultSet set) throws SQLException { Item baseItem = this.getItem(set.getInt("item_id")); - if(baseItem == null) + if (baseItem == null) return null; Class itemClass = baseItem.getInteractionType().getType(); - if(itemClass != null) - { - try - { + if (itemClass != null) { + try { Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); c.setAccessible(true); - return (HabboItem)c.newInstance(set, baseItem); - } - catch (Exception e) - { + return (HabboItem) c.newInstance(set, baseItem); + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -820,69 +702,52 @@ public class ItemManager return null; } - public HabboItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) - { + public HabboItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) { HabboItem gift = null; int userId = 0; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if(habbo != null) - { + if (habbo != null) { userId = habbo.getHabboInfo().getId(); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE username = ?")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE username = ?")) { statement.setString(1, username); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { userId = set.getInt(1); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - if(userId == 0) + if (userId == 0) return null; - if (extraData.length() > 1000) - { + if (extraData.length() > 1000) { Emulator.getLogging().logErrorLine("Extradata exceeds maximum length of 1000 characters:" + extraData); extraData = extraData.substring(0, 1000); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userId); statement.setInt(2, item.getId()); statement.setString(3, extraData); statement.setString(4, limitedStack + ":" + limitedSells); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { gift = new InteractionGift(set.getInt(1), userId, item, extraData, limitedStack, limitedSells); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if(gift != null) - { - if(habbo != null) - { + if (gift != null) { + if (habbo != null) { habbo.getInventory().getItemsComponent().addItem(gift); habbo.getClient().sendResponse(new AddHabboItemComposer(gift)); @@ -892,35 +757,27 @@ public class ItemManager return gift; } - public Item getItem(int itemId) - { - if(itemId < 0) + public Item getItem(int itemId) { + if (itemId < 0) return null; return this.items.get(itemId); } - public TIntObjectMap getItems() - { + public TIntObjectMap getItems() { return this.items; } - public Item getItem(String itemName) - { + public Item getItem(String itemName) { TIntObjectIterator item = this.items.iterator(); - for(int i = this.items.size(); i-- > 0;) - { - try - { + for (int i = this.items.size(); i-- > 0; ) { + try { item.advance(); - if (item.value().getName().toLowerCase().equals(itemName.toLowerCase())) - { + if (item.value().getName().toLowerCase().equals(itemName.toLowerCase())) { return item.value(); } - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } @@ -928,24 +785,20 @@ public class ItemManager return null; } - public YoutubeManager getYoutubeManager() - { + public YoutubeManager getYoutubeManager() { return this.youtubeManager; } - public void dispose() - { + public void dispose() { this.items.clear(); Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!"); } - public List getInteractionList() - { + public List getInteractionList() { List interactions = new ArrayList<>(); - for (ItemInteraction interaction : this.interactionsList) - { + for (ItemInteraction interaction : this.interactionsList) { interactions.add(interaction.getName()); } 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 9987969b..90aff433 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java @@ -11,22 +11,20 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.Map; -public class NewUserGift implements ISerialize -{ +public class NewUserGift implements ISerialize { private final int id; private final Type type; private final String imageUrl; private Map items = new HashMap<>(); - public NewUserGift(ResultSet set) throws SQLException - { + public NewUserGift(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.type = Type.valueOf(set.getString("type").toUpperCase()); this.imageUrl = set.getString("image"); this.items.put(this.type == Type.ROOM ? "" : set.getString("value"), this.type == Type.ROOM ? set.getString("value") : ""); } - public NewUserGift(int id, Type type, String imageUrl, Map items) - { + + public NewUserGift(int id, Type type, String imageUrl, Map items) { this.id = id; this.imageUrl = imageUrl; this.type = type; @@ -34,64 +32,50 @@ public class NewUserGift implements ISerialize } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString(this.imageUrl); message.appendInt(this.items.size()); - for (Map.Entry entry : this.items.entrySet()) - { + for (Map.Entry entry : this.items.entrySet()) { message.appendString(entry.getKey()); //Item Name message.appendString(entry.getValue()); //Extra Info } } - public void give(Habbo habbo) - { - if (this.type == Type.ITEM) - { - for (Map.Entry set : this.items.entrySet()) - { + public void give(Habbo habbo) { + if (this.type == Type.ITEM) { + for (Map.Entry set : this.items.entrySet()) { Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getKey()); - if (item != null) - { + if (item != null) { HabboItem createdItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); - if (createdItem != null) - { + if (createdItem != null) { habbo.addFurniture(createdItem); } } } - } - else if (this.type == Type.ROOM) - { + } else if (this.type == Type.ROOM) { //TODO Give room } } - public int getId() - { + public int getId() { return this.id; } - public Type getType() - { + public Type getType() { return this.type; } - public String getImageUrl() - { + public String getImageUrl() { return this.imageUrl; } - public Map getItems() - { + public Map getItems() { return this.items; } - public enum Type - { + 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 2ed8470c..4822d78b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java @@ -2,8 +2,7 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; -public enum PostItColor -{ +public enum PostItColor { BLUE("9CCEFF"), @@ -18,25 +17,21 @@ public enum PostItColor public final String hexColor; - PostItColor(String hexColor) - { + PostItColor(String hexColor) { this.hexColor = hexColor; } - public static boolean isCustomColor(String color) - { - for(PostItColor postItColor : PostItColor.values()) - { - if(postItColor.hexColor.equalsIgnoreCase(color)) + public static boolean isCustomColor(String color) { + for (PostItColor postItColor : PostItColor.values()) { + if (postItColor.hexColor.equalsIgnoreCase(color)) return false; } return true; } - public static PostItColor randomColorNotYellow() - { + public static PostItColor randomColorNotYellow() { return PostItColor.values()[Emulator.getRandom().nextInt(3)]; } } 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 e16cf981..6747e7bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java @@ -6,8 +6,7 @@ public enum RedeemableSubscriptionType { public final String subscriptionType; - RedeemableSubscriptionType(String subscriptionType) - { + RedeemableSubscriptionType(String subscriptionType) { this.subscriptionType = subscriptionType; } 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 d2364166..53430c13 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/SoundTrack.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.items; import java.sql.ResultSet; import java.sql.SQLException; -public class SoundTrack -{ +public class SoundTrack { private int id; private String name; private String author; @@ -12,8 +11,7 @@ public class SoundTrack private String data; private int length; - public SoundTrack(ResultSet set) throws SQLException - { + public SoundTrack(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.author = set.getString("author"); @@ -22,33 +20,27 @@ public class SoundTrack this.length = set.getInt("length"); } - public int getId() - { + public int getId() { return this.id; } - public String getName() - { + public String getName() { return this.name; } - public String getAuthor() - { + public String getAuthor() { return this.author; } - public String getCode() - { + public String getCode() { return this.code; } - public String getData() - { + public String getData() { return this.data; } - public int getLength() - { + 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 900b4bd3..82d54f2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -9,71 +9,53 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -public class YoutubeManager -{ +public class YoutubeManager { public THashMap> playLists = new THashMap<>(); public THashMap videos = new THashMap<>(); - public void load() - { + public void load() { this.videos.clear(); this.playLists.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (Statement statement = connection.createStatement()) - { - try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_items")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (Statement statement = connection.createStatement()) { + try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_items")) { + while (set.next()) { this.videos.put(set.getInt("id"), new YoutubeItem(set)); } } - try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_playlists ORDER BY `order` ASC")) - { - while (set.next()) - { - if (!this.playLists.containsKey(set.getInt("item_id"))) - { + try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_playlists ORDER BY `order` ASC")) { + while (set.next()) { + if (!this.playLists.containsKey(set.getInt("item_id"))) { this.playLists.put(set.getInt("item_id"), new ArrayList<>()); } YoutubeItem item = this.videos.get(set.getInt("video_id")); - if (item != null) - { + if (item != null) { this.playLists.get(set.getInt("item_id")).add(item); } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public ArrayList getPlaylist(Item item) - { - if (this.playLists.containsKey(item.getId())) - { + public ArrayList getPlaylist(Item item) { + if (this.playLists.containsKey(item.getId())) { return this.playLists.get(item.getId()); } return new ArrayList<>(); } - public YoutubeItem getVideo(Item item, String video) - { - if (this.playLists.contains(item.getId())) - { - for (YoutubeItem v : this.playLists.get(item.getId())) - { - if (v.video.equalsIgnoreCase(video)) - { + public YoutubeItem getVideo(Item item, String video) { + if (this.playLists.contains(item.getId())) { + for (YoutubeItem v : this.playLists.get(item.getId())) { + if (v.video.equalsIgnoreCase(video)) { return v; } } @@ -82,12 +64,9 @@ public class YoutubeManager return null; } - public String getPreviewImage(Item item) - { - if (this.playLists.contains(item.getId())) - { - if (!this.playLists.get(item.getId()).isEmpty()) - { + public String getPreviewImage(Item item) { + if (this.playLists.contains(item.getId())) { + if (!this.playLists.get(item.getId()).isEmpty()) { return this.playLists.get(item.getId()).get(0).video; } } @@ -95,18 +74,15 @@ public class YoutubeManager return ""; } - public YoutubeItem getVideo(Item item, int index) - { - if (this.playLists.containsKey(item.getId())) - { + public YoutubeItem getVideo(Item item, int index) { + if (this.playLists.containsKey(item.getId())) { return this.playLists.get(item.getId()).get(index); } return null; } - public class YoutubeItem - { + public class YoutubeItem { public final int id; public final String video; public final String title; @@ -114,8 +90,7 @@ public class YoutubeManager public final int startTime; public final int endTime; - public YoutubeItem(ResultSet set) throws SQLException - { + public YoutubeItem(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.video = set.getString("video"); this.title = set.getString("title"); 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 52fbfdc5..840ede43 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 @@ -12,33 +12,26 @@ import com.eu.habbo.threading.runnables.BackgroundAnimation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBackgroundToner extends HabboItem -{ - public InteractionBackgroundToner(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBackgroundToner extends HabboItem { + public InteractionBackgroundToner(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBackgroundToner(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBackgroundToner(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(5 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(4); - if (this.getExtradata().split(":").length == 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])); - } - else - { + } else { serverMessage.appendInt(0); serverMessage.appendInt(126); serverMessage.appendInt(126); @@ -52,36 +45,29 @@ public class InteractionBackgroundToner extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if(client.getHabbo().getRoomUnit().cmdSit && client.getHabbo().getRoomUnit().getEffectId() == 1337) - { + if (client.getHabbo().getRoomUnit().cmdSit && client.getHabbo().getRoomUnit().getEffectId() == 1337) { Emulator.getThreading().run(new BackgroundAnimation(this, room)); return; } - if(this.getExtradata().split(":").length == 4) - { + if (this.getExtradata().split(":").length == 4) { String[] data = this.getExtradata().split(":"); this.setExtradata((data[0].equals("0") ? "1" : "0") + ":" + data[1] + ":" + data[2] + ":" + data[3]); room.updateItem(this); - } - else - { + } else { this.setExtradata("0:126:126:126"); room.updateItem(this); } @@ -90,26 +76,22 @@ public class InteractionBackgroundToner extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java index 767f1efd..01b552f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java @@ -10,33 +10,26 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBadgeDisplay extends HabboItem -{ - public InteractionBadgeDisplay(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBadgeDisplay extends HabboItem { + public InteractionBadgeDisplay(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBadgeDisplay(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBadgeDisplay(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(4); serverMessage.appendString("0"); String[] data = this.getExtradata().split((char) 9 + ""); - if(data.length == 3) - { + if (data.length == 3) { serverMessage.appendString(data[2]); serverMessage.appendString(data[1]); serverMessage.appendString(data[0]); - } - else - { + } else { serverMessage.appendString(this.getExtradata()); serverMessage.appendString("Unknown User"); serverMessage.appendString("Unknown Date"); @@ -46,38 +39,32 @@ public class InteractionBadgeDisplay extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java index 5b55d907..29c0e0ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java @@ -10,44 +10,33 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBlackHole extends InteractionGate -{ - public InteractionBlackHole(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBlackHole extends InteractionGate { + public InteractionBlackHole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBlackHole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBlackHole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount"); int holesCountProgress = 0; Habbo owner = room.getHabbo(this.getUserId()); - if (owner == null) - { + if (owner == null) { holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), holeCountAchievement); - } - else - { + } else { holesCountProgress = owner.getHabboStats().getAchievementProgress(holeCountAchievement); } int holeDifference = room.getRoomSpecialTypes().getItemsOfType(InteractionBlackHole.class).size() - holesCountProgress; - if (holeDifference > 0) - { - if (owner != null) - { + if (holeDifference > 0) { + if (owner != null) { AchievementManager.progressAchievement(owner, holeCountAchievement, holeDifference); - } - else - { + } else { AchievementManager.progressAchievement(this.getUserId(), holeCountAchievement, holeDifference); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java index bde3b555..00ea3d9b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java @@ -15,25 +15,21 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionCannon extends HabboItem -{ +public class InteractionCannon extends HabboItem { public boolean cooldown = false; - - public InteractionCannon(ResultSet set, Item baseItem) throws SQLException - { + + public InteractionCannon(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionCannon(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionCannon(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -41,26 +37,22 @@ public class InteractionCannon extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client != null) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { super.onClick(client, room, objects); } - - if(room == null) + + if (room == null) return; RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); @@ -69,10 +61,8 @@ public class InteractionCannon extends HabboItem tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8)); tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? 5 : 4)) % 8)); - if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) - { - if (client != null) - { + if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) { + if (client != null) { client.getHabbo().getRoomUnit().setCanWalk(false); client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation()); client.getHabbo().getRoomUnit().lookAtPoint(fuseTile); @@ -88,33 +78,28 @@ public class InteractionCannon extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } - + @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java index fa92dddb..d9aaf6fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java @@ -9,39 +9,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionClothing extends HabboItem -{ - public InteractionClothing(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionClothing extends HabboItem { + public InteractionClothing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionClothing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionClothing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(1); serverMessage.appendString(""); 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 e8a623de..a16115cb 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 @@ -8,60 +8,48 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionColorPlate extends InteractionDefault -{ - public InteractionColorPlate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionColorPlate extends InteractionDefault { + public InteractionColorPlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionColorPlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionColorPlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); this.change(room, 1); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); this.change(room, -1); } - private void change(Room room, int amount) - { + private void change(Room room, int amount) { int state = 0; - if (this.getExtradata() == null || this.getExtradata().isEmpty()) - { + if (this.getExtradata() == null || this.getExtradata().isEmpty()) { this.setExtradata("0"); } - try - { + try { state = Integer.valueOf(this.getExtradata()); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } state += amount; - if (state > this.getBaseItem().getStateCount()) - { + if (state > this.getBaseItem().getStateCount()) { state = this.getBaseItem().getStateCount(); } - if (state < 0) - { + if (state < 0) { state = 0; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java index 98e8d440..55c896fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java @@ -13,23 +13,19 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionColorWheel extends HabboItem -{ +public class InteractionColorWheel extends HabboItem { private Runnable rollTaks; - public InteractionColorWheel(ResultSet set, Item baseItem) throws SQLException - { + public InteractionColorWheel(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionColorWheel(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionColorWheel(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -37,27 +33,23 @@ public class InteractionColorWheel extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); if (!room.hasRights(client.getHabbo())) return; - if(this.rollTaks == null) - { + if (this.rollTaks == null) { this.setExtradata("-1"); room.sendComposer(new WallItemUpdateComposer(this).compose()); Emulator.getThreading().run(this); @@ -66,25 +58,21 @@ public class InteractionColorWheel extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit client, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit client, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } - public void clearRunnable() - { + public void clearRunnable() { this.rollTaks = null; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java index a70eb81a..a73106f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java @@ -8,27 +8,20 @@ import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionCostumeHopper extends InteractionHopper -{ - public InteractionCostumeHopper(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionCostumeHopper extends InteractionHopper { + public InteractionCostumeHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionCostumeHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionCostumeHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client.getHabbo().getRoomUnit().getEffectId() > 0) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client.getHabbo().getRoomUnit().getEffectId() > 0) { super.onClick(client, room, objects); - } - else - { + } else { client.sendResponse(new CustomNotificationComposer(CustomNotificationComposer.HOPPER_NO_COSTUME)); } } 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 5a3c80fe..70869154 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 @@ -19,26 +19,22 @@ import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionCrackable extends HabboItem -{ +public class InteractionCrackable extends HabboItem { + private final Object lock = new Object(); public boolean cracked = false; protected int ticks = 0; - private final Object lock = new Object(); - public InteractionCrackable(ResultSet set, Item baseItem) throws SQLException - { + public InteractionCrackable(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.getExtradata().length() == 0) + public void serializeExtradata(ServerMessage serverMessage) { + if (this.getExtradata().length() == 0) this.setExtradata("0"); serverMessage.appendInt(7 + (this.isLimited() ? 256 : 0)); @@ -51,36 +47,30 @@ public class InteractionCrackable extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client == null) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client == null) { return; } super.onClick(client, room, objects); - synchronized (this.lock) - { + synchronized (this.lock) { if (this.getRoomId() == 0) return; if (this.cracked) return; - if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) - { + if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) { client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY()))); return; } @@ -100,16 +90,13 @@ public class InteractionCrackable extends HabboItem } } - public void onTick(Habbo habbo, Room room) - { + public void onTick(Habbo habbo, Room room) { if (this.cracked) return; - if (this.allowAnyone() || this.getUserId() == habbo.getHabboInfo().getId()) - { + if (this.allowAnyone() || this.getUserId() == habbo.getHabboInfo().getId()) { CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId()); - if (rewardData != null) - { + if (rewardData != null) { if (rewardData.requiredEffect > 0 && habbo.getRoomUnit().getEffectId() != rewardData.requiredEffect) return; @@ -118,17 +105,14 @@ public class InteractionCrackable extends HabboItem this.needsUpdate(true); room.updateItem(this); - if (!rewardData.achievementTick.isEmpty()) - { + if (!rewardData.achievementTick.isEmpty()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementTick)); } - if (!this.cracked && this.ticks == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())) - { + 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()) - { + if (!rewardData.achievementCracked.isEmpty()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked)); } @@ -155,35 +139,29 @@ public class InteractionCrackable extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit client, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit client, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit client, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit client, Room room, Object[] objects) throws Exception { } - public boolean allowAnyone() - { + public boolean allowAnyone() { return false; } - protected boolean placeInRoom() - { + protected boolean placeInRoom() { return true; } - public boolean resetable() - { + public boolean resetable() { return false; } @@ -191,8 +169,7 @@ public class InteractionCrackable extends HabboItem return true; } - public void reset(Room room) - { + public void reset(Room room) { this.cracked = false; this.ticks = 0; this.setExtradata("0"); @@ -200,8 +177,7 @@ public class InteractionCrackable extends HabboItem } @Override - public boolean isUsable() - { + public boolean isUsable() { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java index d031b0a7..60244939 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java @@ -5,33 +5,27 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionCrackableMaster extends InteractionCrackable -{ - public InteractionCrackableMaster(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionCrackableMaster extends InteractionCrackable { + public InteractionCrackableMaster(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionCrackableMaster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionCrackableMaster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - protected boolean placeInRoom() - { + protected boolean placeInRoom() { return false; } @Override - public boolean resetable() - { + public boolean resetable() { return true; } @Override - public boolean allowAnyone() - { + public boolean allowAnyone() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java index b9dc71f2..d25a3cc8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java @@ -11,67 +11,55 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -public abstract class InteractionCustomValues extends HabboItem -{ +public abstract class InteractionCustomValues extends HabboItem { public final THashMap values = new THashMap<>(); - public InteractionCustomValues(ResultSet set, Item baseItem, THashMap defaultValues) throws SQLException - { + public InteractionCustomValues(ResultSet set, Item baseItem, THashMap defaultValues) throws SQLException { super(set, baseItem); this.values.putAll(defaultValues); - for(String s : set.getString("extra_data").split(";")) - { + for (String s : set.getString("extra_data").split(";")) { String[] data = s.split("="); - if(data.length == 2) - { + if (data.length == 2) { this.values.put(data[0], data[1]); } } } - public InteractionCustomValues(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) - { + public InteractionCustomValues(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) { super(id, userId, item, extradata, limitedStack, limitedSells); this.values.putAll(defaultValues); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void run() - { + public void run() { this.setExtradata(this.toExtraData()); super.run(); } - public String toExtraData() - { + public String toExtraData() { StringBuilder data = new StringBuilder(); - synchronized (this.values) - { - for (Map.Entry set : this.values.entrySet()) - { + synchronized (this.values) { + for (Map.Entry set : this.values.entrySet()) { data.append(set.getKey()).append("=").append(set.getValue()).append(";"); } } @@ -80,12 +68,10 @@ public abstract class InteractionCustomValues extends HabboItem } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(this.values.size()); - for (Map.Entry set : this.values.entrySet()) - { + for (Map.Entry set : this.values.entrySet()) { serverMessage.appendString(set.getKey()); serverMessage.appendString(set.getValue()); } 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 928ca2d9..72b13092 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 @@ -17,21 +17,17 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionDefault extends HabboItem -{ - public InteractionDefault(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionDefault extends HabboItem { + public InteractionDefault(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionDefault(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionDefault(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -39,24 +35,22 @@ public class InteractionDefault extends HabboItem } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.getBaseItem().allowWalk(); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); for (RoomUnit unit : room.getRoomUnits()) { - if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // If the unit was previously on the furni... + if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) + continue; // If the unit was previously on the furni... if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore... try { @@ -68,29 +62,21 @@ public class InteractionDefault extends HabboItem } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(room != null && (client == null || this.canToggle(client.getHabbo(), room) || (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (room != null && (client == null || this.canToggle(client.getHabbo(), room) || (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))) { super.onClick(client, room, objects); - if (objects != null && objects.length > 0) - { - if (objects[0] instanceof Integer) - { + if (objects != null && objects.length > 0) { + if (objects[0] instanceof Integer) { if (this.getExtradata().length() == 0) this.setExtradata("0"); - if (this.getBaseItem().getStateCount() > 0) - { + if (this.getBaseItem().getStateCount() > 0) { int currentState = 0; - try - { + try { currentState = Integer.valueOf(this.getExtradata()); - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { Emulator.getLogging().logErrorLine("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); } @@ -105,51 +91,38 @@ public class InteractionDefault extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (roomUnit != null) - { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) - { + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) - { + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); } } - } - else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) - { + } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { Bot bot = room.getBot(roomUnit); - if (bot != null) - { - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) - { + if (bot != null) { + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); return; } - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) - { + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) { room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); } } @@ -159,61 +132,46 @@ public class InteractionDefault extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - if (roomUnit != null) - { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - if (objects != null && objects.length == 2) - { - if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) - { + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (objects != null && objects.length == 2) { + if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) { RoomTile goalTile = (RoomTile) objects[1]; HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y); - if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) - { + if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { return; } } } - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) - { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) - { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { room.giveEffect(habbo, 0, -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) - { + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { room.giveEffect(habbo, 0, -1); } } - } - else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) - { + } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { Bot bot = room.getBot(roomUnit); - if (bot != null) - { - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) - { + if (bot != null) { + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { room.giveEffect(roomUnit, 0, -1); return; } - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) - { + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { room.giveEffect(roomUnit, 0, -1); } } @@ -222,14 +180,12 @@ public class InteractionDefault extends HabboItem } } - public boolean canToggle(Habbo habbo, Room room) - { + public boolean canToggle(Habbo habbo, Room room) { return room.hasRights(habbo); } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java index f4801a1e..aa938ee0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java @@ -14,21 +14,17 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionDice extends HabboItem -{ - public InteractionDice(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { +public class InteractionDice extends HabboItem { + public InteractionDice(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - public InteractionDice(ResultSet set, Item baseItem) throws SQLException - { + public InteractionDice(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -36,28 +32,22 @@ public class InteractionDice extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null) - { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) - { - if (!this.getExtradata().equalsIgnoreCase("-1")) - { + if (client != null) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (!this.getExtradata().equalsIgnoreCase("-1")) { FurnitureDiceRolledEvent event = (FurnitureDiceRolledEvent) Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1)); if (event.isCancelled()) @@ -67,12 +57,9 @@ public class InteractionDice extends HabboItem room.updateItemState(this); Emulator.getThreading().run(this); - if (event.result > 0) - { + if (event.result > 0) { Emulator.getThreading().run(new RandomDiceNumber(room, this, event.result), 1500); - } - else - { + } else { Emulator.getThreading().run(new RandomDiceNumber(this, room, this.getBaseItem().getStateCount()), 1500); } } @@ -81,26 +68,22 @@ public class InteractionDice extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } 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 30672f87..2d9106c9 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 @@ -11,34 +11,28 @@ import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionEffectGiver extends InteractionDefault -{ - public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionEffectGiver extends InteractionDefault { + public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { 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().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } - protected void handle(Room room, RoomUnit roomUnit) - { + protected void handle(Room room, RoomUnit roomUnit) { if (this.getExtradata().isEmpty()) this.setExtradata("0"); if (!this.getExtradata().equals("0")) return; @@ -46,16 +40,13 @@ public class InteractionEffectGiver extends InteractionDefault HabboItem instance = this; room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem(), -1); - if (this.getBaseItem().getStateCount() > 1) - { + if (this.getBaseItem().getStateCount() > 1) { this.setExtradata("1"); room.updateItem(this); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { InteractionEffectGiver.this.setExtradata("0"); room.updateItem(instance); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java index eb8dd772..cb8eb2ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java @@ -11,81 +11,64 @@ import com.eu.habbo.habbohotel.users.HabboGender; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionEffectTile extends InteractionPressurePlate -{ - public InteractionEffectTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionEffectTile extends InteractionPressurePlate { + public InteractionEffectTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalk(roomUnit, room, objects); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (roomUnit.getRoomUnitType() == RoomUnitType.USER) - { + if (roomUnit.getRoomUnitType() == RoomUnitType.USER) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender()); } - } - else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT) - { + } else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT) { Bot bot = room.getBot(roomUnit); - if (bot != null) - { + if (bot != null) { this.giveEffect(room, roomUnit, bot.getGender()); } } } - private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender) - { - if (gender.equals(HabboGender.M)) - { + private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender) { + if (gender.equals(HabboGender.M)) { room.giveEffect(roomUnit, this.getBaseItem().getEffectM(), -1); - } else - { + } else { room.giveEffect(roomUnit, this.getBaseItem().getEffectF(), -1); } } @Override - public boolean isUsable() - { + public boolean isUsable() { return false; } } 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 fa46011d..feb63992 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 @@ -8,35 +8,26 @@ import com.eu.habbo.habbohotel.users.HabboGender; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionEffectToggle extends InteractionDefault -{ - public InteractionEffectToggle(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionEffectToggle extends InteractionDefault { + public InteractionEffectToggle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionEffectToggle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionEffectToggle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (this.getExtradata().isEmpty()) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (this.getExtradata().isEmpty()) { this.setExtradata("0"); } - if (client != null) - { - if (room.hasRights(client.getHabbo())) - { - if (Integer.valueOf(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) - { + if (client != null) { + if (room.hasRights(client.getHabbo())) { + if (Integer.valueOf(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())) - { + (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 eafb4cbc..5ea9050e 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 @@ -16,38 +16,29 @@ import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionEffectVendingMachine extends InteractionDefault -{ - public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionEffectVendingMachine extends InteractionDefault { + public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionEffectVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionEffectVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null) - { + if (client != null) { RoomTile tile = getSquareInFront(room.getLayout(), this); - if (tile != null) - { - if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) - { - if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) - { + if (tile != null) { + if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) { room.updateHabbo(client.getHabbo()); - if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) - { + if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]); client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); @@ -56,24 +47,17 @@ public class InteractionEffectVendingMachine extends InteractionDefault room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); Emulator.getThreading().run(this, 1000); HabboItem instance = this; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem(), 30); } }); } - } - else - { - if (!tile.isWalkable()) - { - for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) - { - if (t != null && t.isWalkable()) - { + } else { + if (!tile.isWalkable()) { + for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + if (t != null && t.isWalkable()) { tile = t; break; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java index 127286fc..b6a06826 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java @@ -10,39 +10,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionExternalImage extends HabboItem -{ - public InteractionExternalImage(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionExternalImage extends HabboItem { + public InteractionExternalImage(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionExternalImage(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionExternalImage(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -50,8 +43,7 @@ public class InteractionExternalImage extends HabboItem } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { } //{"t":10000000, "u":"http://arcturus.pw/camera/", "m":"idk", "s":1, "w":"http://arcturus.pw/camera/image.png"} 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 ff235711..f68a0aa8 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 @@ -12,39 +12,30 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFXBox extends InteractionDefault -{ - public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFXBox extends InteractionDefault { + public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && room.hasRights(client.getHabbo())) - { - if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) - { - if (this.getBaseItem().getEffectM() > 0) - { + if (client != null && room.hasRights(client.getHabbo())) { + if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) { + if (this.getBaseItem().getEffectM() > 0) { room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); } } - if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) - { - if (this.getBaseItem().getEffectF() > 0) - { + if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) { + if (this.getBaseItem().getEffectF() > 0) { room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); } } @@ -53,11 +44,9 @@ public class InteractionFXBox extends InteractionDefault room.updateItemState(this); room.removeHabboItem(this); HabboItem item = this; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { new QueryDeleteHabboItem(item.getId()).run(); room.sendComposer(new RemoveFloorItemComposer(item).compose()); } 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 e9f11a45..645c0d4e 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 @@ -12,58 +12,49 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFireworks extends HabboItem -{ - public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFireworks extends HabboItem { + public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionFireworks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFireworks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.getBaseItem().allowWalk(); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); super.serializeExtradata(serverMessage); //Design flaw ;( } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if(client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect) + if (client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect) { AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger")); } } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } } 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 57bceec2..14e38794 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 @@ -11,84 +11,72 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGate extends HabboItem -{ - public InteractionGate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionGate extends HabboItem { + public InteractionGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); super.serializeExtradata(serverMessage); } - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } - public boolean isWalkable() - { + public boolean isWalkable() { return this.getExtradata().equals("1"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE); if (client != null && !room.hasRights(client.getHabbo()) && !isWired) return; - if(!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty()) + if (!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty()) return; - if(this.getExtradata().length() == 0) + if (this.getExtradata().length() == 0) this.setExtradata("0"); - this.setExtradata((Integer.valueOf(this.getExtradata()) + 1 ) % 2 + ""); + this.setExtradata((Integer.valueOf(this.getExtradata()) + 1) % 2 + ""); room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); this.needsUpdate(true); room.updateItemState(this); } - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } 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 f49ab59a..869b59a3 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 @@ -12,8 +12,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGift extends HabboItem -{ +public class InteractionGift extends HabboItem { + public boolean explode = false; private int[] itemId; private int colorId = 0; private int ribbonId = 0; @@ -22,39 +22,28 @@ public class InteractionGift extends HabboItem private String sender = ""; private String look = ""; - public boolean explode = false; - - public InteractionGift(ResultSet set, Item baseItem) throws SQLException - { + public InteractionGift(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - try - { + try { this.loadData(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId()); } } - public InteractionGift(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGift(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - try - { + try { this.loadData(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId()); } } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { //serverMessage.appendInt(this.colorId * 1000 + this.ribbonId); serverMessage.appendInt(1); serverMessage.appendInt(6); @@ -75,44 +64,37 @@ public class InteractionGift extends HabboItem } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } - private void loadData() throws NumberFormatException - { + private void loadData() throws NumberFormatException { String[] data = null; if (this.getExtradata().contains("\t")) data = this.getExtradata().split("\t"); - if (data != null && data.length >= 5) - { + if (data != null && data.length >= 5) { int count = Integer.valueOf(data[0]); this.itemId = new int[count]; - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.itemId[i] = Integer.valueOf(data[i + 1]); } @@ -121,13 +103,11 @@ public class InteractionGift extends HabboItem this.showSender = data[count + 3].equalsIgnoreCase("1"); this.message = data[count + 4]; - if (data.length - count >= 7 && this.showSender) - { + if (data.length - count >= 7 && this.showSender) { this.sender = data[count + 5]; this.look = data[count + 6]; } - } else - { + } else { this.itemId = new int[0]; this.colorId = 0; this.ribbonId = 0; @@ -136,21 +116,17 @@ public class InteractionGift extends HabboItem } } - public int getColorId() - { + public int getColorId() { return this.colorId; } - public int getRibbonId() - { + public int getRibbonId() { return this.ribbonId; } - public THashSet loadItems() - { + public THashSet loadItems() { THashSet items = new THashSet<>(); - for (int anItemId : this.itemId) - { + for (int anItemId : this.itemId) { if (anItemId == 0) continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java index 22dc31e0..721f252f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java @@ -5,21 +5,17 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGroupEffectTile extends InteractionEffectTile -{ - public InteractionGroupEffectTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionGroupEffectTile extends InteractionEffectTile { + public InteractionGroupEffectTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionGroupEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGroupEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean requiresAllTilesOccupied() - { + public boolean requiresAllTilesOccupied() { return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java index d00c8217..6aae5d31 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java @@ -5,21 +5,17 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGroupPressurePlate extends InteractionPressurePlate -{ - public InteractionGroupPressurePlate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionGroupPressurePlate extends InteractionPressurePlate { + public InteractionGroupPressurePlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionGroupPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGroupPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean requiresAllTilesOccupied() - { + public boolean requiresAllTilesOccupied() { return true; } } \ No newline at end of file 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 c5c51b9f..8b3c05ea 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 @@ -1,40 +1,33 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGuildFurni extends InteractionDefault -{ +public class InteractionGuildFurni extends InteractionDefault { private int guildId; - public InteractionGuildFurni(ResultSet set, Item baseItem) throws SQLException - { + public InteractionGuildFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.guildId = set.getInt("guild_id"); } - public InteractionGuildFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGuildFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.guildId = 0; } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); - if(guild != null) - { + if (guild != null) { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(5); serverMessage.appendString(this.getExtradata()); @@ -44,14 +37,11 @@ public class InteractionGuildFurni extends InteractionDefault serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).valueA); super.serializeExtradata(serverMessage); - } - else - { + } else { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); - if(this.isLimited()) - { + if (this.isLimited()) { serverMessage.appendInt(10); serverMessage.appendInt(100); } @@ -59,30 +49,25 @@ public class InteractionGuildFurni extends InteractionDefault } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.getBaseItem().allowWalk(); } - public int getGuildId() - { + public int getGuildId() { return this.guildId; } - public void setGuildId(int guildId) - { + public void setGuildId(int guildId) { this.guildId = guildId; } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java index 14bfe977..d552d5a9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java @@ -12,29 +12,25 @@ import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGuildGate extends InteractionGuildFurni -{ - public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionGuildGate extends InteractionGuildFurni { + public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionGuildGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGuildGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } + @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { - if(roomUnit == null) + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + if (roomUnit == null) return false; Habbo habbo = room.getHabbo(roomUnit); @@ -43,28 +39,24 @@ public class InteractionGuildGate extends InteractionGuildFurni } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if(this.canWalkOn(roomUnit, room, objects)) - { + if (this.canWalkOn(roomUnit, room, objects)) { this.setExtradata("1"); room.updateItemState(this); } } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); Emulator.getThreading().run(new CloseGate(this, room), 500); } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { this.setExtradata("0"); room.updateItemState(this); } 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 4135ce56..a4c14418 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 @@ -11,96 +11,78 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGymEquipment extends InteractionEffectTile implements ICycleable -{ +public class InteractionGymEquipment extends InteractionEffectTile implements ICycleable { private int startTime = 0; private int roomUnitId = -1; - public InteractionGymEquipment(ResultSet set, Item baseItem) throws SQLException - { + public InteractionGymEquipment(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionGymEquipment(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGymEquipment(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.USER) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.roomUnitId == -1; } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.forceRotation()) - { + if (this.forceRotation()) { roomUnit.setRotation(RoomUserRotation.fromValue(this.getRotation())); roomUnit.canRotate = false; } this.roomUnitId = roomUnit.getId(); - if (roomUnit.getRoomUnitType() == RoomUnitType.USER) - { + if (roomUnit.getRoomUnitType() == RoomUnitType.USER) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { this.startTime = Emulator.getIntUnixTimestamp(); } } } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); room.giveEffect(roomUnit, 0, -1); - if (this.forceRotation()) - { + if (this.forceRotation()) { roomUnit.canRotate = true; } this.reset(room); } - public String achievementName() - { + public String achievementName() { return Emulator.getConfig().getValue("hotel.furni.gym.achievement." + this.getBaseItem().getName(), ""); } - public boolean forceRotation() - { + public boolean forceRotation() { return Emulator.getConfig().getBoolean("hotel.furni.gym.forcerot." + this.getBaseItem().getName(), true); } @Override - public void cycle(Room room) - { - if (this.roomUnitId != -1) - { + public void cycle(Room room) { + if (this.roomUnitId != -1) { Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId); - if (habbo != null) - { + if (habbo != null) { int timestamp = Emulator.getIntUnixTimestamp(); - if (timestamp - this.startTime >= 120) - { + if (timestamp - this.startTime >= 120) { String achievement = this.achievementName(); - if (!achievement.isEmpty()) - { + if (!achievement.isEmpty()) { AchievementManager.progressAchievement(habbo.getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement)); } @@ -111,19 +93,15 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC } @Override - public void setRotation(int rotation) - { + public void setRotation(int rotation) { super.setRotation(rotation); - if (this.forceRotation() && this.roomUnitId != -1) - { + if (this.forceRotation() && this.roomUnitId != -1) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room != null) - { + if (room != null) { RoomUnit roomUnit = this.getCurrentRoomUnit(room); - if (roomUnit != null) - { + if (roomUnit != null) { roomUnit.setRotation(RoomUserRotation.fromValue(rotation)); room.updateRoomUnit(roomUnit); } @@ -132,12 +110,10 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { super.onPickUp(room); - if (this.roomUnitId != -1) - { + if (this.roomUnitId != -1) { this.setEffect(room, 0); } @@ -145,43 +121,34 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); - if (!oldLocation.equals(newLocation)) - { + if (!oldLocation.equals(newLocation)) { this.setEffect(room, 0); this.reset(room); } } - private void setEffect(Room room, int effectId) - { + private void setEffect(Room room, int effectId) { if (this.roomUnitId == -1) return; room.giveEffect(this.getCurrentRoomUnit(room), effectId, -1); } - private void reset(Room room) - { + private void reset(Room room) { this.roomUnitId = -1; this.startTime = 0; this.setExtradata("0"); room.updateItem(this); } - private RoomUnit getCurrentRoomUnit(Room room) - { + private RoomUnit getCurrentRoomUnit(Room room) { Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId); - if (habbo != null) - { + if (habbo != null) { return habbo.getRoomUnit(); - } - else - { + } else { Bot bot = room.getBotByRoomUnitId(this.roomUnitId); - if (bot != null) - { + if (bot != null) { return bot.getRoomUnit(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java index b980c8be..e6103f97 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java @@ -12,27 +12,22 @@ import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubGate extends InteractionGate -{ - public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHabboClubGate extends InteractionGate { + public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { return habbo.getHabboStats().hasActiveClub(); } @@ -40,27 +35,21 @@ public class InteractionHabboClubGate extends InteractionGate } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if(this.canWalkOn(roomUnit, room, objects)) - { + if (this.canWalkOn(roomUnit, room, objects)) { this.setExtradata("1"); room.updateItemState(this); - } - else - { + } else { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)); } @@ -69,23 +58,18 @@ public class InteractionHabboClubGate extends InteractionGate } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { - if (this.canWalkOn(client.getHabbo().getRoomUnit(), room, null)) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { + if (this.canWalkOn(client.getHabbo().getRoomUnit(), room, null)) { super.onClick(client, room, objects); - } - else - { + } else { client.sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)); } } } + @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); Emulator.getThreading().run(new CloseGate(this, room), 500); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java index e2691d60..1fb38ffa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java @@ -9,34 +9,26 @@ import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubHopper extends InteractionHopper -{ - public InteractionHabboClubHopper(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHabboClubHopper extends InteractionHopper { + public InteractionHabboClubHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHabboClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHabboClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client.getHabbo().getHabboStats().hasActiveClub()) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client.getHabbo().getHabboStats().hasActiveClub()) { super.onClick(client, room, objects); - } - else - { + } else { client.sendResponse(new CustomNotificationComposer(CustomNotificationComposer.HOPPER_NO_HC)); } } @Override - protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) - { + protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) { return super.canUseTeleport(client, front, room) && client.getHabbo().getHabboStats().hasActiveClub(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java index 81831ad0..9d1bfb1b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java @@ -9,25 +9,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubTeleportTile extends InteractionTeleportTile -{ - public InteractionHabboClubTeleportTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHabboClubTeleportTile extends InteractionTeleportTile { + public InteractionHabboClubTeleportTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHabboClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHabboClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboStats().hasActiveClub(); } @@ -35,8 +30,7 @@ public class InteractionHabboClubTeleportTile extends InteractionTeleportTile } @Override - public boolean canUseTeleport(GameClient client, Room room) - { + public boolean canUseTeleport(GameClient client, Room room) { return super.canUseTeleport(client, room) && client.getHabbo().getHabboStats().hasActiveClub(); } } \ No newline at end of file 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 09dbe6e3..b6923128 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 @@ -11,32 +11,26 @@ import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHanditem extends InteractionDefault -{ - public InteractionHanditem(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHanditem extends InteractionDefault { + public InteractionHanditem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHanditem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHanditem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { 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().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } - protected void handle(Room room, RoomUnit roomUnit) - { + protected void handle(Room room, RoomUnit roomUnit) { if (this.getExtradata().isEmpty()) this.setExtradata("0"); if (!this.getExtradata().equals("0")) return; @@ -44,16 +38,13 @@ public class InteractionHanditem extends InteractionDefault HabboItem instance = this; room.giveHandItem(roomUnit, this.getBaseItem().getRandomVendingItem()); - if (this.getBaseItem().getStateCount() > 1) - { + if (this.getBaseItem().getStateCount() > 1) { this.setExtradata("1"); room.updateItem(this); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { InteractionHanditem.this.setExtradata("0"); room.updateItem(instance); } 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 0f7ee8b8..83e1bd24 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 @@ -8,29 +8,22 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHanditemTile extends InteractionHanditem -{ - public InteractionHanditemTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHanditemTile extends InteractionHanditem { + public InteractionHanditemTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHanditemTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHanditemTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { InteractionHanditemTile instance = this; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY()) - { + public void run() { + if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY()) { instance.handle(room, roomUnit); } } 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 d875904e..fa0d2571 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 @@ -13,23 +13,19 @@ import com.eu.habbo.threading.runnables.hopper.HopperActionOne; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHopper extends HabboItem -{ - public InteractionHopper(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionHopper extends HabboItem { + public InteractionHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -37,43 +33,34 @@ public class InteractionHopper extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if(room != null) - { + if (room != null) { RoomTile loc = HabboItem.getSquareInFront(room.getLayout(), this); - if (loc != null) - { - if (this.canUseTeleport(client, loc, room)) - { + if (loc != null) { + if (this.canUseTeleport(client, loc, room)) { client.getHabbo().getRoomUnit().isTeleporting = true; this.setExtradata("1"); room.updateItemState(this); Emulator.getThreading().run(new HopperActionOne(this, room, client), 500); - } - else - { + } else { client.getHabbo().getRoomUnit().setGoalLocation(loc); } } @@ -81,39 +68,34 @@ public class InteractionHopper extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public void run() - { - if(!this.getExtradata().equals("0")) - { + public void run() { + if (!this.getExtradata().equals("0")) { this.setExtradata("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { room.updateItemState(this); } } super.run(); } - protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) - { - if(client.getHabbo().getRoomUnit().getX() != front.x) + protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) { + if (client.getHabbo().getRoomUnit().getX() != front.x) return false; - if(client.getHabbo().getRoomUnit().getY() != front.y) + if (client.getHabbo().getRoomUnit().getY() != front.y) return false; - if(client.getHabbo().getRoomUnit().isTeleporting) + if (client.getHabbo().getRoomUnit().isTeleporting) return false; - if(!room.getHabbosAt(this.getX(), this.getY()).isEmpty()) + if (!room.getHabbosAt(this.getX(), this.getY()).isEmpty()) return false; return this.getExtradata().equals("0"); 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 f69be678..e4b3a793 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 @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -11,22 +10,18 @@ import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionInformationTerminal extends InteractionCustomValues -{ - public static final THashMap defaultValues = new THashMap() - { +public class InteractionInformationTerminal extends InteractionCustomValues { + public static final THashMap defaultValues = new THashMap() { { this.put("internalLink", "habbopages/chat/commands"); } }; - public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException - { + public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, defaultValues); } - public InteractionInformationTerminal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionInformationTerminal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); } @@ -35,7 +30,7 @@ public class InteractionInformationTerminal extends InteractionCustomValues super.onWalk(roomUnit, room, objects); Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null && this.values.containsKey("internalLink")) { + if (habbo != null && this.values.containsKey("internalLink")) { habbo.getClient().sendResponse(new NuxAlertComposer(this.values.get("internalLink"))); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index 57fffaa4..95eddcd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -10,21 +10,17 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionJukeBox extends HabboItem -{ - public InteractionJukeBox(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionJukeBox extends HabboItem { + public InteractionJukeBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionJukeBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionJukeBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -32,37 +28,29 @@ public class InteractionJukeBox extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && objects.length == 1) - { - if ((Integer)objects[0] == 0) - { - if (room.getTraxManager().isPlaying()) - { + if (client != null && objects.length == 1) { + if ((Integer) objects[0] == 0) { + if (room.getTraxManager().isPlaying()) { room.getTraxManager().stop(); - } else - { + } else { room.getTraxManager().play(0, client.getHabbo()); } } @@ -70,23 +58,19 @@ public class InteractionJukeBox extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { super.onPickUp(room); this.setExtradata("0"); - if (room.getTraxManager().isPlaying() && room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) - { + if (room.getTraxManager().isPlaying() && room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) { room.getTraxManager().clearPlayList(); } } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { super.onPlace(room); - if (room.getTraxManager().isPlaying()) - { + if (room.getTraxManager().isPlaying()) { this.setExtradata("1"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java index f047cd70..9b207caf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java @@ -16,40 +16,33 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; -public class InteractionLoveLock extends HabboItem -{ +public class InteractionLoveLock extends HabboItem { public int userOneId; public int userTwoId; - public InteractionLoveLock(ResultSet set, Item baseItem) throws SQLException - { + public InteractionLoveLock(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionLoveLock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionLoveLock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(6); String[] data = this.getExtradata().split("\t"); - if(data.length == 6) - { + if (data.length == 6) { serverMessage.appendString("1"); serverMessage.appendString(data[1]); serverMessage.appendString(data[2]); serverMessage.appendString(data[3]); serverMessage.appendString(data[4]); serverMessage.appendString(data[5]); - } - else - { + } else { serverMessage.appendString("0"); serverMessage.appendString(""); serverMessage.appendString(""); @@ -62,47 +55,37 @@ public class InteractionLoveLock extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(this.getExtradata().contains("\t")) + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (this.getExtradata().contains("\t")) return; - if(client == null) + if (client == null) return; - if(RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) - { - if(this.userOneId == 0) - { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) { + if (this.userOneId == 0) { this.userOneId = client.getHabbo().getHabboInfo().getId(); client.sendResponse(new LoveLockFurniStartComposer(this)); - } - else - { - if(this.userOneId != client.getHabbo().getHabboInfo().getId()) - { + } else { + if (this.userOneId != client.getHabbo().getHabboInfo().getId()) { Habbo habbo = room.getHabbo(this.userOneId); - if (habbo != null) - { + if (habbo != null) { this.userTwoId = client.getHabbo().getHabboInfo().getId(); client.sendResponse(new LoveLockFurniStartComposer(this)); } @@ -111,11 +94,9 @@ public class InteractionLoveLock extends HabboItem } } - public boolean lock(Habbo userOne, Habbo userTwo, Room room) - { + public boolean lock(Habbo userOne, Habbo userTwo, Room room) { RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); - if(RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentLocation(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentLocation(), tile)) - { + if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentLocation(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentLocation(), tile)) { String data = "1"; data += "\t"; data += userOne.getHabboInfo().getUsername(); 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 65fed46a..2901a7b9 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 @@ -9,40 +9,32 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UserDataComposer; -import com.eu.habbo.util.figure.FigureUtil; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMannequin extends HabboItem -{ - public InteractionMannequin(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionMannequin extends HabboItem { + public InteractionMannequin(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionMannequin(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMannequin(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(3); - if(this.getExtradata().split(":").length >= 2) - { + if (this.getExtradata().split(":").length >= 2) { String[] data = this.getExtradata().split(":"); serverMessage.appendString("GENDER"); serverMessage.appendString(data[0].toLowerCase()); serverMessage.appendString("FIGURE"); serverMessage.appendString(data[1]); serverMessage.appendString("OUTFIT_NAME"); - serverMessage.appendString((data.length >= 3 ? data[2] : "")); - } - else - { + serverMessage.appendString((data.length >= 3 ? data[2] : "")); + } else { serverMessage.appendString("GENDER"); serverMessage.appendString("m"); serverMessage.appendString("FIGURE"); @@ -57,39 +49,32 @@ public class InteractionMannequin extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { String[] lookCode = this.getExtradata().split(":")[1].split("\\."); StringBuilder look = new StringBuilder(); - for (String part : client.getHabbo().getHabboInfo().getLook().split("\\.")) - { + for (String part : client.getHabbo().getHabboInfo().getLook().split("\\.")) { String type = part.split("-")[0]; boolean found = false; - for (String s : lookCode) - { - if (s.contains(type)) - { + for (String s : lookCode) { + if (s.contains(type)) { found = true; look.append(s).append("."); } } - if (!found) - { + if (!found) { look.append(part).append("."); } } @@ -100,20 +85,17 @@ public class InteractionMannequin extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } 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 91a57df3..51e47e6c 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 @@ -10,25 +10,21 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMonsterCrackable extends InteractionCrackable implements ICycleable -{ +public class InteractionMonsterCrackable extends InteractionCrackable implements ICycleable { private int lastHealthChange = 0; private boolean respawn = false; - public InteractionMonsterCrackable(ResultSet set, Item baseItem) throws SQLException - { + + public InteractionMonsterCrackable(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void cycle(Room room) - { - if (this.ticks > 0 && Emulator.getIntUnixTimestamp() - this.lastHealthChange > 30) - { + public void cycle(Room room) { + if (this.ticks > 0 && Emulator.getIntUnixTimestamp() - this.lastHealthChange > 30) { this.lastHealthChange = Emulator.getIntUnixTimestamp(); this.ticks--; room.updateItem(this); @@ -36,22 +32,19 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { if (room.isPublicRoom()) this.respawn = true; super.onClick(client, room, objects); } @Override - public boolean resetable() - { + public boolean resetable() { return this.respawn; } @Override - public void reset(Room room) - { + public void reset(Room room) { RoomTile tile = room.getRandomWalkableTile(); this.setX(tile.x); this.setY(tile.y); @@ -60,20 +53,17 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements } @Override - public boolean allowAnyone() - { + public boolean allowAnyone() { return this.respawn; } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } @Override - protected boolean placeInRoom() - { + protected boolean placeInRoom() { return this.respawn; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java index c94fa060..f9ac09da 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java @@ -11,56 +11,58 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMonsterPlantSeed extends HabboItem -{ - public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionMonsterPlantSeed extends HabboItem { + public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - if (this.getExtradata().isEmpty()) - { + if (this.getExtradata().isEmpty()) { this.setExtradata("" + randomRarityLevel()); this.needsUpdate(true); } } - public InteractionMonsterPlantSeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMonsterPlantSeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - if (this.getExtradata().isEmpty()) - { + if (this.getExtradata().isEmpty()) { this.setExtradata("" + randomRarityLevel()); this.needsUpdate(true); } } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public static int randomRarityLevel() { + int number = Emulator.getRandom().nextInt(66); + int count = 0; + for (int i = 1; i <= 11; i++) { + count += 11 - i; + if (number <= count) { + return i; + } + } + return 10; } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(1); serverMessage.appendString("rarity"); @@ -68,19 +70,4 @@ public class InteractionMonsterPlantSeed extends HabboItem super.serializeExtradata(serverMessage); } - - public static int randomRarityLevel() - { - int number = Emulator.getRandom().nextInt(66); - int count = 0; - for (int i = 1; i <= 11; i++) - { - count += 11 - i; - if (number <= count) - { - return i; - } - } - return 10; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java index b7b1e8df..d9c181d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java @@ -11,21 +11,17 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMoodLight extends HabboItem -{ - public InteractionMoodLight(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionMoodLight extends HabboItem { + public InteractionMoodLight(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionMoodLight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMoodLight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -33,32 +29,25 @@ public class InteractionMoodLight extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onPlace(Room room) - { - if(room != null) - { - for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) - { - if (data.isEnabled()) - { + public void onPlace(Room room) { + if (room != null) { + for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + if (data.isEnabled()) { this.setExtradata(data.toString()); this.needsUpdate(true); room.updateItem(this); @@ -69,8 +58,7 @@ public class InteractionMoodLight extends HabboItem } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } 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 9a21df67..f73af35e 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 @@ -17,16 +17,17 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMultiHeight extends HabboItem -{ - public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { +public class InteractionMultiHeight extends HabboItem { + public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } + public InteractionMultiHeight(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -34,44 +35,32 @@ public class InteractionMultiHeight extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } - public InteractionMultiHeight(ResultSet set, Item baseItem) throws SQLException - { - super(set, baseItem); - } - @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.getBaseItem().allowWalk(); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null) - { + if (client != null) { if (!room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) return; } - if (objects.length > 0) - { - if (objects[0] instanceof Integer && room != null) - { + if (objects.length > 0) { + if (objects[0] instanceof Integer && room != null) { this.needsUpdate(true); - if(this.getExtradata().length() == 0) + if (this.getExtradata().length() == 0) this.setExtradata("0"); - if(this.getBaseItem().getMultiHeights().length > 0) - { + if (this.getBaseItem().getMultiHeights().length > 0) { this.setExtradata("" + (Integer.valueOf(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length)); this.needsUpdate(true); room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); @@ -79,26 +68,20 @@ public class InteractionMultiHeight extends HabboItem //room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.valueOf(this.getExtradata())] * 256.0D).compose()); } - if(this.isWalkable()) - { + if (this.isWalkable()) { THashSet habbos = room.getHabbosOnItem(this); THashSet updatedUnits = new THashSet<>(); - for (Habbo habbo : habbos) - { - if(habbo.getRoomUnit() == null) + for (Habbo habbo : habbos) { + if (habbo.getRoomUnit() == null) continue; - if(habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) continue; - if (this.getBaseItem().getMultiHeights().length >= 0) - { - if (this.getBaseItem().allowSit()) - { + if (this.getBaseItem().getMultiHeights().length >= 0) { + if (this.getBaseItem().allowSit()) { habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + ""); - } - else - { + } else { habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ()); } @@ -113,33 +96,25 @@ public class InteractionMultiHeight extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (roomUnit != null) - { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) - { + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) - { + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); } } @@ -149,28 +124,21 @@ public class InteractionMultiHeight extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - if (roomUnit != null) - { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) - { + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { room.giveEffect(habbo, 0, -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) - { + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { room.giveEffect(habbo, 0, -1); } } @@ -180,8 +148,7 @@ public class InteractionMultiHeight extends HabboItem } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } } 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 67e0ba49..a0e245b7 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 @@ -11,51 +11,40 @@ import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMusicDisc extends HabboItem -{ +public class InteractionMusicDisc extends HabboItem { private int songId; private boolean inQueue; - public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException - { + public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); String[] stuff = this.getExtradata().split("\n"); - if(stuff.length >= 7 && !stuff[6].isEmpty()) - { - try - { + if (stuff.length >= 7 && !stuff[6].isEmpty()) { + try { this.songId = Integer.valueOf(stuff[6]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); } } } - public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); String[] stuff = this.getExtradata().split("\n"); - if(stuff.length >= 7 && !stuff[6].isEmpty()) - { - try - { + if (stuff.length >= 7 && !stuff[6].isEmpty()) { + try { this.songId = Integer.valueOf(stuff[6]); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); } } } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -63,51 +52,43 @@ public class InteractionMusicDisc extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } - public int getSongId() - { + public int getSongId() { return this.songId; } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { super.onPlace(room); room.sendComposer(new JukeBoxMySongsComposer(room.getTraxManager().myList()).compose()); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { super.onPickUp(room); room.getTraxManager().removeSong(this.getId()); } - public boolean inQueue() - { + public boolean inQueue() { return this.inQueue; } - public void inQueue(boolean inQueue) - { + public void inQueue(boolean inQueue) { this.inQueue = inQueue; } } 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 d5cccdb9..fcc9522a 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 @@ -8,42 +8,41 @@ import java.awt.*; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMuteArea extends InteractionCustomValues -{ - public static THashMap defaultValues = new THashMap() - { +public class InteractionMuteArea extends InteractionCustomValues { + public static THashMap defaultValues = new THashMap() { { - this.put("tilesLeft", "0");} + this.put("tilesLeft", "0"); + } + { - this.put("tilesRight", "0");} + this.put("tilesRight", "0"); + } + { - this.put("tilesFront", "0");} + this.put("tilesFront", "0"); + } + { - this.put("tilesBack", "0");} + this.put("tilesBack", "0"); + } }; - public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException - { + public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, defaultValues); } - public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); } - public boolean inSquare(RoomTile location) - { - try - { + public boolean inSquare(RoomTile location) { + try { return new Rectangle( - this.getX() - Integer.valueOf(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); - } - catch (Exception e) - { + this.getX() - Integer.valueOf(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); + } catch (Exception e) { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java index ab7b4e4b..36fb719a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -16,21 +15,17 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionNest extends HabboItem -{ - public InteractionNest(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionNest extends HabboItem { + public InteractionNest(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -38,46 +33,41 @@ public class InteractionNest extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return this.getBaseItem().allowWalk(); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if(pet == null) + if (pet == null) return; - if(pet instanceof RideablePet && ((RideablePet) pet).getRider() != null) + if (pet instanceof RideablePet && ((RideablePet) pet).getRider() != null) return; - if(!pet.getPetData().haveNest(this)) + if (!pet.getPetData().haveNest(this)) return; - if(pet.getEnergy() > 85) + if (pet.getEnergy() > 85) return; pet.setTask(PetTasks.NEST); @@ -89,8 +79,7 @@ public class InteractionNest extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } } 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 069cf12b..5b3cdb75 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 @@ -19,23 +19,19 @@ import com.eu.habbo.threading.runnables.HabboItemNewState; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionObstacle extends HabboItem -{ - public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionObstacle extends HabboItem { + public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -43,13 +39,11 @@ public class InteractionObstacle extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { Pet pet = room.getPet(roomUnit); - if (pet instanceof HorsePet) - { - HorsePet horsePet = (HorsePet)pet; + if (pet instanceof HorsePet) { + HorsePet horsePet = (HorsePet) pet; return horsePet.getRider() != null; } @@ -58,39 +52,30 @@ public class InteractionObstacle extends HabboItem } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { Pet pet = room.getPet(roomUnit); - if(pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) - { - if (pet.getTask() != null && pet.getTask().equals(PetTasks.RIDE)) - { - if (pet.getRoomUnit().hasStatus(RoomUnitStatus.JUMP)) - { + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { + if (pet.getTask() != null && pet.getTask().equals(PetTasks.RIDE)) { + if (pet.getRoomUnit().hasStatus(RoomUnitStatus.JUMP)) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); Emulator.getThreading().run(new HabboItemNewState(this, room, "0"), 2000); - } else - { + } else { int state = 0; - for (int i = 0; i < 2; i++) - { + for (int i = 0; i < 2; i++) { state = Emulator.getRandom().nextInt(4) + 1; if (state == 4) @@ -111,39 +96,26 @@ public class InteractionObstacle extends HabboItem } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) - { + if (habbo == null) { Pet pet = room.getPet(roomUnit); - if(pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) - { - if (roomUnit.getBodyRotation().getValue() % 2 == 0) - { - if (this.getRotation() == 2) - { - if(roomUnit.getBodyRotation().equals(RoomUserRotation.WEST)) - { + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { + if (roomUnit.getBodyRotation().getValue() % 2 == 0) { + if (this.getRotation() == 2) { + if (roomUnit.getBodyRotation().equals(RoomUserRotation.WEST)) { ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() - 3), roomUnit.getY())); - } - else if(roomUnit.getBodyRotation().equals(RoomUserRotation.EAST)) - { + } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.EAST)) { ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() + 3), roomUnit.getY())); } - } - else if(this.getRotation() == 4) - { - if(roomUnit.getBodyRotation().equals(RoomUserRotation.NORTH)) - { + } else if (this.getRotation() == 4) { + if (roomUnit.getBodyRotation().equals(RoomUserRotation.NORTH)) { ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() - 3))); - } - else if(roomUnit.getBodyRotation().equals(RoomUserRotation.SOUTH)) - { + } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.SOUTH)) { ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() + 3))); } } @@ -153,18 +125,15 @@ public class InteractionObstacle extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) - { + if (habbo == null) { Pet pet = room.getPet(roomUnit); - if(pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) - { + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); } } 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 01bb9101..844b042e 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 @@ -16,45 +16,37 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionOneWayGate extends HabboItem -{ +public class InteractionOneWayGate extends HabboItem { private boolean walkable = false; - public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException - { + public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionOneWayGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionOneWayGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return this.getBaseItem().allowWalk(); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return walkable; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.getExtradata().length() == 0) - { + public void serializeExtradata(ServerMessage serverMessage) { + if (this.getExtradata().length() == 0) { this.setExtradata("0"); this.needsUpdate(true); } @@ -66,29 +58,25 @@ public class InteractionOneWayGate extends HabboItem } @Override - public void onClick(final GameClient client, final Room room, Object[] objects) throws Exception - { + public void onClick(final GameClient client, final Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null) - { + if (client != null) { RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation()); - if(tileInfront == null) + if (tileInfront == null) return; RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); - if(currentLocation == null) + if (currentLocation == null) return; RoomUnit unit = client.getHabbo().getRoomUnit(); - if(unit == null) + if (unit == null) return; - if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) - { - if(!currentLocation.hasUnits()) - { + if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) { + if (!currentLocation.hasUnits()) { List onSuccess = new ArrayList(); List onFail = new ArrayList(); @@ -132,43 +120,37 @@ public class InteractionOneWayGate extends HabboItem } } - private void refresh(Room room) - { + private void refresh(Room room) { this.setExtradata("0"); room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose()); room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); this.refresh(room); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); this.refresh(room); } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { super.onPlace(room); this.refresh(room); } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); this.refresh(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java index ce8e0ad0..48049fee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java @@ -19,37 +19,31 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPetBreedingNest extends HabboItem -{ +public class InteractionPetBreedingNest extends HabboItem { public Pet petOne = null; public Pet petTwo = null; - public InteractionPetBreedingNest(ResultSet set, Item baseItem) throws SQLException - { + public InteractionPetBreedingNest(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPetBreedingNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPetBreedingNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return room.getPet(roomUnit) != null && !this.boxFull(); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -57,29 +51,23 @@ public class InteractionPetBreedingNest extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { Pet pet = room.getPet(roomUnit); - if (pet != null) - { - if (!this.boxFull()) - { + if (pet != null) { + if (!this.boxFull()) { this.addPet(pet); - if (this.boxFull()) - { + if (this.boxFull()) { Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId()); Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId()); - if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) - { + if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) { ownerPetTwo.getClient().sendResponse(new PetBreedingResultComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername())); this.setExtradata("1"); room.updateItem(this); @@ -89,16 +77,12 @@ public class InteractionPetBreedingNest extends HabboItem } } - public boolean addPet(Pet pet) - { - if (this.petOne == null) - { + public boolean addPet(Pet pet) { + if (this.petOne == null) { this.petOne = pet; this.petOne.getRoomUnit().setCanWalk(false); return true; - } - else if (this.petTwo == null && this.petOne != pet) - { + } else if (this.petTwo == null && this.petOne != pet) { this.petTwo = pet; this.petTwo.getRoomUnit().setCanWalk(false); return true; @@ -107,14 +91,12 @@ public class InteractionPetBreedingNest extends HabboItem return false; } - public boolean boxFull() - { + public boolean boxFull() { return this.petOne != null && this.petTwo != null; } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { if (this.petOne != null && this.petOne.getRoomUnit() == roomUnit) this.petOne = null; if (this.petTwo != null && this.petTwo.getRoomUnit() == roomUnit) this.petTwo = null; @@ -123,25 +105,20 @@ public class InteractionPetBreedingNest extends HabboItem } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } - public void stopBreeding(Habbo habbo) - { + public void stopBreeding(Habbo habbo) { this.setExtradata("0"); habbo.getHabboInfo().getCurrentRoom().updateItem(this); - if (this.petOne != null) - { + if (this.petOne != null) { habbo.getClient().sendResponse(new PetPackageNameValidationComposer(this.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, "")); } - if (this.petTwo.getUserId() != habbo.getHabboInfo().getId()) - { + if (this.petTwo.getUserId() != habbo.getHabboInfo().getId()) { Habbo owner = this.petTwo.getRoom().getHabbo(this.petTwo.getUserId()); - if (owner != null) - { + if (owner != null) { owner.getClient().sendResponse(new PetPackageNameValidationComposer(this.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, "")); } } @@ -150,25 +127,21 @@ public class InteractionPetBreedingNest extends HabboItem } - private void freePets() - { - if (this.petOne != null) - { + private void freePets() { + if (this.petOne != null) { this.petOne.getRoomUnit().setCanWalk(true); this.petOne.setTask(PetTasks.FREE); this.petOne = null; } - if (this.petTwo != null) - { + if (this.petTwo != null) { this.petTwo.getRoomUnit().setCanWalk(true); this.petTwo.setTask(PetTasks.FREE); this.petTwo = null; } } - public void breed(Habbo habbo, String name, int petOneId, int petTwoId) - { + public void breed(Habbo habbo, String name, int petOneId, int petTwoId) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId())); this.setExtradata("2"); @@ -177,11 +150,9 @@ public class InteractionPetBreedingNest extends HabboItem HabboItem box = this; Pet petOne = this.petOne; Pet petTwo = this.petTwo; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient()); //habbo.getClient().sendResponse(new PetPackageNameValidationComposer(box.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, "")); @@ -192,8 +163,7 @@ public class InteractionPetBreedingNest extends HabboItem habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box); habbo.getClient().sendResponse(new PetBreedingCompleted(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring))); - if (box.getBaseItem().getName().startsWith("pet_breeding_")) - { + if (box.getBaseItem().getName().startsWith("pet_breeding_")) { String boxType = box.getBaseItem().getName().replace("pet_breeding_", ""); String achievement = boxType.substring(0, 1).toUpperCase() + boxType.substring(1) + "Breeder"; AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java index 3efb8df4..b0a3131f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java @@ -15,31 +15,24 @@ import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPetDrink extends InteractionDefault -{ - public InteractionPetDrink(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionPetDrink extends InteractionDefault { + public InteractionPetDrink(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPetDrink(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPetDrink(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if(pet != null) - { - if(pet.getPetData().haveDrinkItem(this)) - { - if (pet.levelThirst >= 35) - { + if (pet != null) { + if (pet.getPetData().haveDrinkItem(this)) { + if (pet.levelThirst >= 35) { pet.setTask(PetTasks.EAT); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); @@ -57,8 +50,7 @@ public class InteractionPetDrink extends InteractionDefault } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java index 0e13bf9b..07e3fd90 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java @@ -14,34 +14,27 @@ import com.eu.habbo.threading.runnables.PetEatAction; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPetFood extends InteractionDefault -{ - public InteractionPetFood(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionPetFood extends InteractionDefault { + public InteractionPetFood(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPetFood(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPetFood(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if(this.getExtradata().length() == 0) + if (this.getExtradata().length() == 0) this.setExtradata("0"); Pet pet = room.getPet(roomUnit); - if(pet != null) - { - if(pet.getPetData().haveFoodItem(this)) - { - if (pet.levelHunger >= 35) - { + if (pet != null) { + if (pet.getPetData().haveFoodItem(this)) { + if (pet.levelHunger >= 35) { pet.setTask(PetTasks.EAT); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); @@ -57,8 +50,7 @@ public class InteractionPetFood extends InteractionDefault @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java index d7ed49e6..f70540b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java @@ -14,31 +14,25 @@ import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPetToy extends InteractionDefault -{ - public InteractionPetToy(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionPetToy extends InteractionDefault { + public InteractionPetToy(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionPetToy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPetToy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if(pet != null) - { - if (pet.getEnergy() <= 35) - { + if (pet != null) { + if (pet.getEnergy() <= 35) { return; } @@ -50,11 +44,9 @@ public class InteractionPetToy extends InteractionDefault pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, "0"); pet.packetUpdate = true; HabboItem item = this; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { pet.addHappyness(25); item.setExtradata("0"); room.updateItem(item); @@ -67,22 +59,19 @@ public class InteractionPetToy extends InteractionDefault } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if (pet != null) - { + if (pet != null) { this.setExtradata("0"); room.updateItemState(this); } } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java index 188640a7..b7038613 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java @@ -9,43 +9,36 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPostIt extends HabboItem -{ +public class InteractionPostIt extends HabboItem { public static String STICKYPOLE_PREFIX_TEXT = ""; - public InteractionPostIt(ResultSet set, Item baseItem) throws SQLException - { + public InteractionPostIt(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPostIt(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPostIt(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata().replace(((char)9 ) + "", "")); + serverMessage.appendString(this.getExtradata().replace(((char) 9) + "", "")); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java index 0e2702c5..d734d3ad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java @@ -9,39 +9,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPoster extends HabboItem -{ - public InteractionPoster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { +public class InteractionPoster extends HabboItem { + public InteractionPoster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - public InteractionPoster(ResultSet set, Item baseItem) throws SQLException - { + public InteractionPoster(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); 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 320d1b8a..17b77a39 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 @@ -13,41 +13,34 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPressurePlate extends HabboItem -{ - public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionPressurePlate extends HabboItem { + public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -55,51 +48,42 @@ public class InteractionPressurePlate extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { updateState(room); } }, 100); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { updateState(room); } }, 100); } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); updateState(room); } - public void updateState(Room room) - { + public void updateState(Room room) { boolean occupied = false; if (room == null || room.getLayout() == null || this.getBaseItem() == null) return; @@ -112,17 +96,14 @@ public class InteractionPressurePlate extends HabboItem if (tiles == null) return; - for (RoomTile tile : tiles) - { + for (RoomTile tile : tiles) { boolean hasHabbos = room.hasHabbosAt(tile.x, tile.y); - if (!hasHabbos && this.requiresAllTilesOccupied()) - { + if (!hasHabbos && this.requiresAllTilesOccupied()) { occupied = false; break; } - if (hasHabbos) - { + if (hasHabbos) { occupied = true; } } @@ -132,13 +113,11 @@ public class InteractionPressurePlate extends HabboItem } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } - public boolean requiresAllTilesOccupied() - { + public boolean requiresAllTilesOccupied() { return false; } 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 4fe2a4f1..3cd88425 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 @@ -15,45 +15,39 @@ public abstract class InteractionPushable extends InteractionDefault { private KickBallAction currentThread; - public InteractionPushable(ResultSet set, Item baseItem) throws SQLException - { + public InteractionPushable(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionPushable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPushable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalkOff(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - if(!(this.currentThread == null || this.currentThread.dead)) + if (!(this.currentThread == null || this.currentThread.dead)) return; int velocity = this.getWalkOffVelocity(roomUnit, room); RoomUserRotation direction = this.getWalkOffDirection(roomUnit, room); this.onKick(room, roomUnit, velocity, direction); - if(velocity > 0) - { - if(this.currentThread != null) + if (velocity > 0) { + if (this.currentThread != null) this.currentThread.dead = true; this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity); @@ -62,20 +56,17 @@ public abstract class InteractionPushable extends InteractionDefault { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); if (client == null) return; - if(RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) - { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) { int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room); RoomUserRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room); this.onTackle(room, client.getHabbo().getRoomUnit(), velocity, direction); - if(velocity > 0) - { - if(this.currentThread != null) + if (velocity > 0) { + if (this.currentThread != null) this.currentThread.dead = true; this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity); @@ -85,29 +76,26 @@ public abstract class InteractionPushable extends InteractionDefault { } @Override - public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); int velocity; 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().x && this.getY() == roomUnit.getGoal().y) //User clicked on the tile the ball is on, they want to kick it { velocity = this.getWalkOnVelocity(roomUnit, room); direction = this.getWalkOnDirection(roomUnit, room); this.onKick(room, roomUnit, velocity, direction); - } - else //User is walking past the ball, they want to drag it with them + } else //User is walking past the ball, they want to drag it with them { velocity = this.getDragVelocity(roomUnit, room); direction = this.getDragDirection(roomUnit, room); this.onDrag(room, roomUnit, velocity, direction); } - if(velocity > 0) - { - if(this.currentThread != null) + if (velocity > 0) { + if (this.currentThread != null) this.currentThread.dead = true; this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity); 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 91f187d1..21d42d2a 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 @@ -11,25 +11,21 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPuzzleBox extends HabboItem -{ - public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionPuzzleBox extends HabboItem { + public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPuzzleBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPuzzleBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) return; - if(!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) + if (!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) return; @@ -37,8 +33,7 @@ public class InteractionPuzzleBox extends HabboItem client.getHabbo().getRoomUnit().lookAtPoint(boxLocation); room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); - switch (client.getHabbo().getRoomUnit().getBodyRotation()) - { + switch (client.getHabbo().getRoomUnit().getBodyRotation()) { case NORTH_EAST: case NORTH_WEST: case SOUTH_EAST: @@ -48,20 +43,18 @@ public class InteractionPuzzleBox extends HabboItem RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) - { + if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) { return; } double offset = room.getStackHeight(tile.x, tile.y, false) - this.getZ(); - if(!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue()))) + if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue()))) return; HabboItem item = room.getTopItemAt(tile.x, tile.y); - if(item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) - { + if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) { room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose()); client.getHabbo().getRoomUnit().setGoalLocation(boxLocation); this.needsUpdate(true); @@ -69,8 +62,7 @@ public class InteractionPuzzleBox extends HabboItem } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -78,20 +70,17 @@ public class InteractionPuzzleBox extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } 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 3437185d..1ddc2be9 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 @@ -8,29 +8,23 @@ import com.eu.habbo.habbohotel.rooms.Room; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPyramid extends InteractionGate -{ +public class InteractionPyramid extends InteractionGate { private int nextChange; - public InteractionPyramid(ResultSet set, Item baseItem) throws SQLException - { + public InteractionPyramid(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionPyramid(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionPyramid(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - public void change(Room room) - { - if(!(this.getExtradata().equals("0") || this.getExtradata().equals("1"))) + public void change(Room room) { + if (!(this.getExtradata().equals("0") || this.getExtradata().equals("1"))) this.setExtradata("0"); - if(room != null) - { - if(room.getHabbosAt(this.getX(), this.getY()).isEmpty()) - { + if (room != null) { + if (room.getHabbosAt(this.getX(), this.getY()).isEmpty()) { int state = Integer.valueOf(this.getExtradata()); state = Math.abs(state - 1); @@ -42,19 +36,16 @@ public class InteractionPyramid extends InteractionGate } } - public int getNextChange() - { + public int getNextChange() { return this.nextChange; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { } @Override - public boolean isUsable() - { + public boolean isUsable() { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java index a0f2da01..250d7504 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java @@ -1,13 +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.RedeemableSubscriptionType; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.users.UserClubComposer; -import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java index e247b9e9..4635c63f 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 @@ -19,57 +19,42 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionRentableSpace extends HabboItem -{ +public class InteractionRentableSpace extends HabboItem { private int renterId; private String renterName; private int endTimestamp; - public InteractionRentableSpace(ResultSet set, Item baseItem) throws SQLException - { + public InteractionRentableSpace(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); String[] data = set.getString("extra_data").split(":"); this.renterName = "Unknown"; - if(data.length == 2) - { + if (data.length == 2) { this.renterId = Integer.valueOf(data[0]); this.endTimestamp = Integer.valueOf(data[1]); - if(this.renterId > 0) - { - if(this.isRented()) - { + if (this.renterId > 0) { + if (this.isRented()) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.renterId); - if (habbo != null) - { + if (habbo != null) { this.renterName = habbo.getHabboInfo().getUsername(); - } else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT username FROM users WHERE id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT username FROM users WHERE id = ? LIMIT 1")) { statement.setInt(1, this.renterId); - try (ResultSet row = statement.executeQuery()) - { - if (row.next()) - { + try (ResultSet row = statement.executeQuery()) { + if (row.next()) { this.renterName = row.getString("username"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - } - else - { - if(this.getRoomId() > 0) - { + } else { + if (this.getRoomId() > 0) { Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()))); this.renterId = 0; } @@ -78,29 +63,26 @@ public class InteractionRentableSpace extends HabboItem } } - public InteractionRentableSpace(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionRentableSpace(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.renterName = ""; } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { - if(this.getExtradata().isEmpty()) + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + if (this.getExtradata().isEmpty()) return false; Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return true; - if(habbo.getHabboInfo().getId() == room.getId()) + if (habbo.getHabboInfo().getId() == room.getId()) return true; - if(this.endTimestamp > Emulator.getIntUnixTimestamp()) - { + if (this.endTimestamp > Emulator.getIntUnixTimestamp()) { return this.renterId > 0 && this.renterId == habbo.getHabboInfo().getId(); } @@ -108,57 +90,49 @@ public class InteractionRentableSpace extends HabboItem } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { this.sendRentWidget(client.getHabbo()); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.getExtradata().isEmpty()) + public void serializeExtradata(ServerMessage serverMessage) { + if (this.getExtradata().isEmpty()) this.setExtradata("0:0"); serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); - if(this.isRented()) - { + if (this.isRented()) { serverMessage.appendInt(1); serverMessage.appendString("renterId"); serverMessage.appendString(this.renterId + ""); - } - else - { + } else { serverMessage.appendInt(0); } super.serializeExtradata(serverMessage); } - public void rent(Habbo habbo) - { - if(this.isRented()) + public void rent(Habbo habbo) { + if (this.isRented()) return; - if(habbo.getHabboStats().isRentingSpace()) + if (habbo.getHabboStats().isRentingSpace()) return; - if(habbo.getHabboInfo().getCredits() < this.rentCost()) + if (habbo.getHabboInfo().getCredits() < this.rentCost()) return; - if(habbo.getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) + if (habbo.getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) return; this.setRenterId(habbo.getHabboInfo().getId()); @@ -171,52 +145,41 @@ public class InteractionRentableSpace extends HabboItem this.run(); } - public void endRent() - { + public void endRent() { this.setEndTimestamp(0); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return; Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); THashSet items = new THashSet<>(); - for(int i = rect.x; i < rect.x + rect.getWidth(); i++) - { - for(int j = rect.y; j < rect.y + rect.getHeight(); j++) - { + for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { + for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { items.addAll(room.getItemsAt(i, j, this.getZ())); } } - for(HabboItem item : items) - { - if(item.getUserId() == this.renterId) - { + for (HabboItem item : items) { + if (item.getUserId() == this.renterId) { room.pickUpItem(item, null); } } Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.renterId); - if(habbo != null) - { + if (habbo != null) { habbo.getHabboStats().setRentedItemId(0); habbo.getHabboStats().setRentedTimeEnd(0); - } - else - { + } else { int zero = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET rent_space_id = ?, rent_space_endtime = ? WHERE user_id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET rent_space_id = ?, rent_space_endtime = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, zero); statement.setInt(2, zero); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -230,52 +193,42 @@ public class InteractionRentableSpace extends HabboItem } @Override - public String getExtradata() - { + public String getExtradata() { return this.renterId + ":" + this.endTimestamp; } - public int getRenterId() - { + public int getRenterId() { return this.renterId; } - public void setRenterId(int renterId) - { + public void setRenterId(int renterId) { this.renterId = renterId; } - public String getRenterName() - { + public String getRenterName() { return this.renterName; } - public void setRenterName(String renterName) - { + public void setRenterName(String renterName) { this.renterName = renterName; } - public int getEndTimestamp() - { + public int getEndTimestamp() { return this.endTimestamp; } - public void setEndTimestamp(int endTimestamp) - { + public void setEndTimestamp(int endTimestamp) { this.endTimestamp = endTimestamp; } - public boolean isRented() - { + public boolean isRented() { return this.endTimestamp > Emulator.getIntUnixTimestamp(); } - public int rentCost() - { + public int rentCost() { String[] data = this.getBaseItem().getName().replace("hblooza_spacerent", "").split("x"); - if(data.length == 2) - { + if (data.length == 2) { int x = Integer.valueOf(data[0]); int y = Integer.valueOf(data[1]); @@ -285,33 +238,27 @@ public class InteractionRentableSpace extends HabboItem return 1337; } - public int getRentErrorCode(Habbo habbo) - { - if(this.isRented() && this.renterId != habbo.getHabboInfo().getId()) - { + public int getRentErrorCode(Habbo habbo) { + if (this.isRented() && this.renterId != habbo.getHabboInfo().getId()) { return RentableSpaceInfoComposer.SPACE_ALREADY_RENTED; } - if(habbo.getHabboStats().isRentingSpace() && habbo.getHabboStats().getRentedItemId() != this.getId()) - { + if (habbo.getHabboStats().isRentingSpace() && habbo.getHabboStats().getRentedItemId() != this.getId()) { return RentableSpaceInfoComposer.CAN_RENT_ONLY_ONE_SPACE; } - if(habbo.getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) - { + if (habbo.getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) { return RentableSpaceInfoComposer.CANT_RENT_NO_HABBO_CLUB; } - if(this.rentCost() > habbo.getHabboInfo().getCredits()) - { + if (this.rentCost() > habbo.getHabboInfo().getCredits()) { return RentableSpaceInfoComposer.NOT_ENOUGH_CREDITS; } return 0; } - public void sendRentWidget(Habbo habbo) - { + public void sendRentWidget(Habbo habbo) { habbo.getClient().sendResponse(new RentableSpaceInfoComposer(habbo, this, this.getRentErrorCode(habbo))); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java index 0eb24d07..09a9a846 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java @@ -1,6 +1,5 @@ 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.rooms.Room; @@ -15,24 +14,21 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionRoller extends HabboItem -{ +public class InteractionRoller extends HabboItem { public static boolean NO_RULES = false; - public InteractionRoller(ResultSet set, Item baseItem) throws SQLException - { + + public InteractionRoller(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionRoller(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionRoller(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -40,58 +36,46 @@ public class InteractionRoller extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) - { + public boolean canStackAt(Room room, List>> itemsAtLocation) { if (NO_RULES) return true; if (itemsAtLocation.isEmpty()) return false; - for (Pair> set : itemsAtLocation) - { - if (set.getValue() != null && !set.getValue().isEmpty()) - { - if (set.getValue().size() > 1) - { + for (Pair> set : itemsAtLocation) { + if (set.getValue() != null && !set.getValue().isEmpty()) { + if (set.getValue().size() > 1) { return false; - } - else if (!set.getValue().contains(this)) - { + } else if (!set.getValue().contains(this)) { return false; } } 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 7b92b6dd..d37dea17 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 @@ -8,41 +8,44 @@ import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionRoomAds extends InteractionCustomValues -{ - public final static THashMap defaultValues = new THashMap() - { +public class InteractionRoomAds extends InteractionCustomValues { + public final static THashMap defaultValues = new THashMap() { { - this.put("imageUrl", "");} + this.put("imageUrl", ""); + } + { - this.put("clickUrl", "");} + this.put("clickUrl", ""); + } + { - this.put("offsetX", "0");} + this.put("offsetX", "0"); + } + { - this.put("offsetY", "0");} + this.put("offsetY", "0"); + } + { - this.put("offsetZ", "0");} + this.put("offsetZ", "0"); + } }; - public InteractionRoomAds(ResultSet set, Item baseItem) throws SQLException - { + public InteractionRoomAds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, defaultValues); } - public InteractionRoomAds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionRoomAds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java index f5cecd98..28fa960e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java @@ -8,23 +8,18 @@ import com.eu.habbo.messages.outgoing.navigator.OpenRoomCreationWindowComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionRoomOMatic extends InteractionDefault -{ - public InteractionRoomOMatic(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionRoomOMatic extends InteractionDefault { + public InteractionRoomOMatic(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionRoomOMatic(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionRoomOMatic(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { client.sendResponse(new OpenRoomCreationWindowComposer()); } } 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 2c8bef3d..3a6bf457 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 @@ -16,38 +16,31 @@ import java.awt.*; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionSnowboardSlope extends InteractionMultiHeight -{ - public InteractionSnowboardSlope(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { +public class InteractionSnowboardSlope extends InteractionMultiHeight { + public InteractionSnowboardSlope(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - public InteractionSnowboardSlope(ResultSet set, Item baseItem) throws SQLException - { + public InteractionSnowboardSlope(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { room.giveEffect(roomUnit, 97, -1); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - if (roomUnit.getEffectId() == 97) - { + if (roomUnit.getEffectId() == 97) { room.giveEffect(roomUnit, 0, -1); } } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { super.onPlace(room); THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class); @@ -57,46 +50,36 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight int progress; Habbo habbo = room.getHabbo(room.getOwnerId()); - if (habbo != null) - { + if (habbo != null) { progress = habbo.getHabboStats().getAchievementProgress(snowboardBuild); - } - else - { + } else { progress = AchievementManager.getAchievementProgressForHabbo(room.getOwnerId(), snowboardBuild); } progress = Math.max(items.size() - progress, 0); - if (progress > 0) - { + if (progress > 0) { AchievementManager.progressAchievement(room.getOwnerId(), snowboardBuild); } } @Override - public void onPickUp(Room room) - { - for (Habbo habbo : room.getHabbosOnItem(this)) - { - if (habbo.getRoomUnit().getEffectId() == 97) - { + public void onPickUp(Room room) { + for (Habbo habbo : room.getHabbosOnItem(this)) { + if (habbo.getRoomUnit().getEffectId() == 97) { room.giveEffect(habbo, 0, -1); } } } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + 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()); - for (Habbo habbo : room.getHabbosOnItem(this)) - { - if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().x, habbo.getRoomUnit().getCurrentLocation().y)) - { + for (Habbo habbo : room.getHabbosOnItem(this)) { + if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().x, habbo.getRoomUnit().getCurrentLocation().y)) { room.giveEffect(habbo, 0, -1); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java index 53b8c623..5955665f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java @@ -9,39 +9,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionStackHelper extends HabboItem -{ - public InteractionStackHelper(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionStackHelper extends HabboItem { + public InteractionStackHelper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionStackHelper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionStackHelper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -49,8 +42,7 @@ public class InteractionStackHelper extends HabboItem } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java index 00adb4fd..cd434e5f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionStickyPole extends InteractionDefault -{ - public InteractionStickyPole(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionStickyPole extends InteractionDefault { + public InteractionStickyPole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionStickyPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionStickyPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java index e15bf896..87543a07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java @@ -10,55 +10,44 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionSwitch extends InteractionDefault -{ - public InteractionSwitch(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionSwitch extends InteractionDefault { + public InteractionSwitch(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionSwitch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionSwitch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canToggle(Habbo habbo, Room room) - { + public boolean canToggle(Habbo habbo, Room room) { return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation()); } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client == null) + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client == null) return; - if (!this.canToggle(client.getHabbo(), room)) - { + if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; - for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) - { - if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) - { + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { closestTile = client.getHabbo().getRoomUnit().getCurrentLocation(); } } - if (closestTile != null) - { + if (closestTile != null) { client.getHabbo().getRoomUnit().setGoalLocation(closestTile); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java index cf83680d..c958a9d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTalkingFurniture extends InteractionDefault -{ - public InteractionTalkingFurniture(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTalkingFurniture extends InteractionDefault { + public InteractionTalkingFurniture(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTalkingFurniture(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTalkingFurniture(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } } 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 bae4d4ea..94f219b8 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 @@ -5,12 +5,10 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.RoomUnit; 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.items.ItemIntStateComposer; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.threading.runnables.teleport.TeleportActionOne; @@ -19,30 +17,26 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionTeleport extends HabboItem -{ +public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; private int roomUnitID = -1; private boolean walkable = false; - public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException - { + public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); walkable = baseItem.allowWalk(); this.setExtradata("0"); } - public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); walkable = item.allowWalk(); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -50,8 +44,7 @@ public class InteractionTeleport extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return this.getBaseItem().allowWalk() || roomUnit.getId() == this.roomUnitID; } @@ -69,28 +62,27 @@ public class InteractionTeleport extends HabboItem Habbo habbo = client.getHabbo(); - if(habbo == null) + if (habbo == null) return; RoomUnit unit = habbo.getRoomUnit(); - if(unit == null) + if (unit == null) return; RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); - if(currentLocation == null) + if (currentLocation == null) return; RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); - if(!canUseTeleport(client, room)) + if (!canUseTeleport(client, room)) return; - if(this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { + if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); - } - else if(unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { + } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); this.setExtradata("1"); @@ -124,8 +116,7 @@ public class InteractionTeleport extends HabboItem unit.setGoalLocation(currentLocation); unit.setCanLeaveRoomByDoor(false); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); - } - else { + } else { // walk to teleport and interact List onSuccess = new ArrayList(); List onFail = new ArrayList(); @@ -140,12 +131,10 @@ public class InteractionTeleport extends HabboItem } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if(room != null && client != null && objects.length <= 1) - { + if (room != null && client != null && objects.length <= 1) { tryTeleport(client, room); } } @@ -155,15 +144,12 @@ public class InteractionTeleport extends HabboItem } @Override - public void run() - { - if(!this.getExtradata().equals("0")) - { + public void run() { + if (!this.getExtradata().equals("0")) { this.setExtradata("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { room.updateItem(this); } } @@ -171,37 +157,31 @@ public class InteractionTeleport extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.targetId = 0; this.targetRoomId = 0; this.roomUnitID = -1; this.setExtradata("0"); } - public int getTargetId() - { + public int getTargetId() { return this.targetId; } - public void setTargetId(int targetId) - { + public void setTargetId(int targetId) { this.targetId = targetId; } - public int getTargetRoomId() - { + public int getTargetRoomId() { return this.targetRoomId; } - public void setTargetRoomId(int targetRoomId) - { + public void setTargetRoomId(int targetRoomId) { this.targetRoomId = targetRoomId; } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @@ -209,23 +189,22 @@ public class InteractionTeleport extends HabboItem Habbo habbo = client.getHabbo(); - if(habbo == null) + if (habbo == null) return false; RoomUnit unit = habbo.getRoomUnit(); - if(unit == null) + if (unit == null) return false; - if(habbo.getHabboInfo().getRiding() != null) + if (habbo.getHabboInfo().getRiding() != null) return false; return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); } - public void startTeleport(Room room, Habbo habbo) - { - if(habbo.getRoomUnit().isTeleporting) + public void startTeleport(Room room, Habbo habbo) { + if (habbo.getRoomUnit().isTeleporting) return; this.roomUnitID = -1; @@ -234,8 +213,7 @@ public class InteractionTeleport extends HabboItem } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java index 2ed23f67..8f283757 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java @@ -1,30 +1,24 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTeleportTile extends InteractionTeleport -{ - public InteractionTeleportTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTeleportTile extends InteractionTeleport { + public InteractionTeleportTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @@ -34,19 +28,15 @@ public class InteractionTeleportTile extends InteractionTeleport } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { - if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if(!canUseTeleport(habbo.getClient(), room)) + if (habbo != null) { + if (!canUseTeleport(habbo.getClient(), room)) return; - if (!habbo.getRoomUnit().isTeleporting) - { + if (!habbo.getRoomUnit().isTeleporting) { habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation()); this.startTeleport(room, habbo); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java index f0dfed15..bf2d2021 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTent extends InteractionDefault -{ - public InteractionTent(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTent extends InteractionDefault { + public InteractionTent(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } } 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 572967b9..733d6c45 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 @@ -9,45 +9,38 @@ import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTileEffectProvider extends InteractionCustomValues -{ - public static THashMap defaultValues = new THashMap() - { - { - this.put("effectId", "0");} +public class InteractionTileEffectProvider extends InteractionCustomValues { + public static THashMap defaultValues = new THashMap() { + { + this.put("effectId", "0"); + } }; - public InteractionTileEffectProvider(ResultSet set, Item baseItem) throws SQLException - { + public InteractionTileEffectProvider(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, defaultValues); } - public InteractionTileEffectProvider(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTileEffectProvider(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception - { + 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")); - if(roomUnit.getEffectId() == effectId) - { + if (roomUnit.getEffectId() == effectId) { effectId = 0; } @@ -55,11 +48,9 @@ public class InteractionTileEffectProvider extends InteractionCustomValues room.updateItem(this); final InteractionTileEffectProvider proxy = this; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { proxy.values.put("state", "0"); room.updateItem(proxy); } 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 134d83a0..adf949e0 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 @@ -11,21 +11,17 @@ import com.eu.habbo.habbohotel.users.HabboGender; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTrap extends InteractionDefault -{ - public InteractionTrap(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTrap extends InteractionDefault { + public InteractionTrap(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); if (!this.getExtradata().equals("1")) @@ -33,41 +29,32 @@ public class InteractionTrap extends InteractionDefault int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName()); - if (delay == 0) - { + if (delay == 0) { Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000"); delay = 3000; } - if (roomUnit != null) - { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) - { + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) - { + 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(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { room.giveEffect(roomUnit, 0, -1); roomUnit.setCanWalk(true); } @@ -79,7 +66,6 @@ public class InteractionTrap extends InteractionDefault } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java index a7a9890d..36d978e8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java @@ -10,59 +10,49 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTrophy extends HabboItem -{ - public InteractionTrophy(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTrophy extends HabboItem { + public InteractionTrophy(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); super.serializeExtradata(serverMessage); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + 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 308f1a4f..19a5c52b 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 @@ -16,50 +16,39 @@ import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionVendingMachine extends HabboItem -{ - public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionVendingMachine extends HabboItem { + public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null) - { + if (client != null) { RoomTile tile = getSquareInFront(room.getLayout(), this); - if (tile != null) - { - if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) - { - if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) - { + if (tile != null) { + if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) { room.updateHabbo(client.getHabbo()); - if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) - { + if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]); client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); @@ -69,18 +58,15 @@ public class InteractionVendingMachine extends HabboItem Emulator.getThreading().run(this, 1000); Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem())); - if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); - if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); } - } - else - { - if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) - { - for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) - { - if (t != null && t.isWalkable()) - { + } else { + if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) { + for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + if (t != null && t.isWalkable()) { tile = t; break; } @@ -94,33 +80,27 @@ public class InteractionVendingMachine extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void run() - { + public void run() { super.run(); - if(this.getExtradata().equals("1")) - { + if (this.getExtradata().equals("1")) { this.setExtradata("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { room.updateItem(this); } } @@ -128,8 +108,7 @@ public class InteractionVendingMachine extends HabboItem @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -137,8 +116,7 @@ public class InteractionVendingMachine extends HabboItem } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } 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 b5ca29f3..c8fa52b4 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 @@ -9,40 +9,31 @@ import com.eu.habbo.habbohotel.rooms.Room; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionVikingCotie extends InteractionDefault -{ - public InteractionVikingCotie(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionVikingCotie extends InteractionDefault { + public InteractionVikingCotie(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionVikingCotie(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionVikingCotie(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(this.getExtradata().isEmpty()) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (this.getExtradata().isEmpty()) { this.setExtradata("0"); } - if (client != null && client.getHabbo().getHabboInfo().getId() == this.getUserId()) - { - if (client.getHabbo().getRoomUnit().getEffectId() == 172 || client.getHabbo().getRoomUnit().getEffectId() == 173) - { + 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()); - if (state < 5) - { + if (state < 5) { state++; this.setExtradata(state + ""); room.updateItem(this); - if (state == 5) - { + if (state == 5) { AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("ViciousViking")); } } @@ -51,8 +42,7 @@ public class InteractionVikingCotie extends InteractionDefault } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } } 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 971e4b61..9a7c0183 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 @@ -19,87 +19,71 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionWater extends InteractionDefault -{ - public InteractionWater(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionWater extends InteractionDefault { + public InteractionWater(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionWater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionWater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); this.recalculate(room); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.recalculate(room); Object[] empty = new Object[]{}; - for (Habbo habbo : room.getHabbosOnItem(this)) - { - try - { + for (Habbo habbo : room.getHabbosOnItem(this)) { + try { this.onWalkOff(habbo.getRoomUnit(), room, empty); - } catch (Exception e) - { + } catch (Exception e) { } } - for (Bot bot : room.getBotsOnItem(this)) - { - try - { + for (Bot bot : room.getBotsOnItem(this)) { + try { this.onWalkOff(bot.getRoomUnit(), room, empty); + } catch (Exception e) { } - catch (Exception e) - {} } } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { this.recalculate(room); } - public void refreshWaters(Room room) - { - if(room == null) - { + public void refreshWaters(Room room) { + if (room == null) { room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); } - int _1 = 0; - int _2 = 0; - int _3 = 0; - int _4 = 0; - int _5 = 0; - int _6 = 0; - int _7 = 0; - int _8 = 0; - int _9 = 0; + int _1 = 0; + int _2 = 0; + int _3 = 0; + int _4 = 0; + int _5 = 0; + int _6 = 0; + int _7 = 0; + int _8 = 0; + int _9 = 0; int _10 = 0; int _11 = 0; int _12 = 0; - for(HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) - { + for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) { ((InteractionWaterItem) item).update(); } - if (!this.getBaseItem().getName().equalsIgnoreCase("bw_water_2")) - { + if (!this.getBaseItem().getName().equalsIgnoreCase("bw_water_2")) { if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() - 1)) _1 = 1; if (room.waterTiles.containsKey(this.getX()) && room.waterTiles.get(this.getX()).contains(this.getY() - 1)) @@ -127,31 +111,31 @@ public class InteractionWater extends InteractionDefault } //if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1; - if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1; - if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1; + if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1; + if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1; //if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1; - if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1; - if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1; - if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1; - if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1; + if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1; + if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1; + if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1; + if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1; //if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1; if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1; if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1; //if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1; int result = 0; - result |= _1 << 11; - result |= _2 << 10; - result |= _3 << 9; - result |= _4 << 8; - result |= _5 << 7; - result |= _6 << 6; - result |= _7 << 5; - result |= _8 << 4; - result |= _9 << 3; + result |= _1 << 11; + result |= _2 << 10; + result |= _3 << 9; + result |= _4 << 8; + result |= _5 << 7; + result |= _6 << 6; + result |= _7 << 5; + result |= _8 << 4; + result |= _9 << 3; result |= _10 << 2; result |= _11 << 1; - result |= _12 ; + result |= _12; this.setExtradata(result + ""); this.needsUpdate(true); @@ -159,65 +143,51 @@ public class InteractionWater extends InteractionDefault } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { Pet pet = room.getPet(roomUnit); - if (pet != null) - { + if (pet != null) { pet.getRoomUnit().setStatus(RoomUnitStatus.DIP, "0"); } } - private void recalculate(Room room) - { + private void recalculate(Room room) { THashMap tiles = new THashMap<>(); - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) - { - for (short i = 0; i < item.getBaseItem().getLength(); i++) - { - for (short j = 0; j < item.getBaseItem().getWidth(); j++) - { - if (!tiles.containsKey((short)(item.getX() + i))) - { - tiles.put((short)(item.getX() + i), new TIntArrayList()); + for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) { + for (short i = 0; i < item.getBaseItem().getLength(); i++) { + for (short j = 0; j < item.getBaseItem().getWidth(); j++) { + if (!tiles.containsKey((short) (item.getX() + i))) { + tiles.put((short) (item.getX() + i), new TIntArrayList()); } - tiles.get((short)(item.getX() + i)).add(item.getY() + j); + tiles.get((short) (item.getX() + i)).add(item.getY() + j); } } } room.waterTiles = tiles; - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) - { - ((InteractionWater)item).refreshWaters(room); + for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) { + ((InteractionWater) item).refreshWaters(room); } } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @Override - public boolean canToggle(Habbo habbo, Room room) - { + public boolean canToggle(Habbo habbo, Room room) { return false; } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) - { - for (Pair> set : itemsAtLocation) - { - for (HabboItem item : set.getValue()) - { - if (!(item instanceof InteractionWater)) - { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { + for (HabboItem item : set.getValue()) { + if (!(item instanceof InteractionWater)) { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java index cae6d5ba..481c8ad3 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 @@ -13,72 +13,59 @@ import java.awt.*; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionWaterItem extends InteractionDefault -{ - public InteractionWaterItem(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionWaterItem extends InteractionDefault { + public InteractionWaterItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionWaterItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionWaterItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { this.update(); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); this.needsUpdate(true); } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { this.update(); } - public void update() - { + public void update() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return; Rectangle rectangle = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); boolean foundWater = true; - for(short x = (short)rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) - { - for(short y = (short)rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) - { + for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) { + for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) { boolean tile = false; THashSet items = room.getItemsAt(room.getLayout().getTile(x, y)); - for(HabboItem item : items) - { - if (item instanceof InteractionWater) - { + for (HabboItem item : items) { + if (item instanceof InteractionWater) { tile = true; break; } } - if (!tile) - { + if (!tile) { foundWater = false; } } } - if (foundWater) - { + if (foundWater) { this.setExtradata("1"); this.needsUpdate(true); room.updateItem(this); @@ -91,14 +78,12 @@ public class InteractionWaterItem extends InteractionDefault } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @Override - public boolean canToggle(Habbo habbo, Room room) - { + public boolean canToggle(Habbo habbo, Room room) { return false; } } 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 5e01f723..cede4c8d 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 @@ -13,18 +13,15 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionWired extends HabboItem -{ +public abstract class InteractionWired extends HabboItem { private long cooldown; - InteractionWired(ResultSet set, Item baseItem) throws SQLException - { + InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @@ -38,21 +35,18 @@ public abstract class InteractionWired extends HabboItem public abstract void loadWiredData(ResultSet set, Room room) throws SQLException; @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -60,32 +54,23 @@ public abstract class InteractionWired extends HabboItem } @Override - public void run() - { - if(this.needsUpdate()) - { + public void run() { + if (this.needsUpdate()) { String wiredData = this.getWiredData(); - if (wiredData == null) - { + if (wiredData == null) { wiredData = ""; } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) - { - if(this.getRoomId() != 0) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) { + if (this.getRoomId() != 0) { statement.setString(1, wiredData); - } - else - { + } else { statement.setString(1, ""); } statement.setInt(2, this.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -93,46 +78,38 @@ public abstract class InteractionWired extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.onPickUp(); } public abstract void onPickUp(); - public void activateBox(Room room) - { + public void activateBox(Room room) { this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); room.sendComposer(new ItemStateComposer(this).compose()); } - protected long requiredCooldown() - { + protected long requiredCooldown() { return 50L; } - - public boolean canExecute(long newMillis) - { + public boolean canExecute(long newMillis) { return newMillis - this.cooldown >= this.requiredCooldown(); } - public void setCooldown(long newMillis) - { + public void setCooldown(long newMillis) { this.cooldown = newMillis; } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @Override - public boolean isUsable() - { + public boolean isUsable() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index dd1241d9..d8c7ed41 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -12,37 +12,29 @@ import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionWiredCondition extends InteractionWired -{ - public InteractionWiredCondition(ResultSet set, Item baseItem) throws SQLException - { +public abstract class InteractionWiredCondition extends InteractionWired { + public InteractionWiredCondition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionWiredCondition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionWiredCondition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { - if (room.hasRights(client.getHabbo())) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { + if (room.hasRights(client.getHabbo())) { client.sendResponse(new WiredConditionDataComposer(this, room)); this.activateBox(room); } @@ -50,20 +42,17 @@ public abstract class InteractionWiredCondition extends InteractionWired } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @@ -71,8 +60,7 @@ public abstract class InteractionWiredCondition extends InteractionWired public abstract boolean saveData(ClientMessage packet); - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.AND; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index 09295dae..a6ae8ab4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -11,39 +11,31 @@ import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionWiredEffect extends InteractionWired -{ +public abstract class InteractionWiredEffect extends InteractionWired { private int delay; - public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException - { + public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionWiredEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionWiredEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { - if (room.hasRights(client.getHabbo())) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { + if (room.hasRights(client.getHabbo())) { client.sendResponse(new WiredEffectDataComposer(this, room)); this.activateBox(room); } @@ -51,43 +43,34 @@ public abstract class InteractionWiredEffect extends InteractionWired } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } public abstract boolean saveData(ClientMessage packet, GameClient gameClient); - - protected void setDelay(int value) - { - this.delay = value; - } - - - public int getDelay() - { + public int getDelay() { return this.delay; } + protected void setDelay(int value) { + this.delay = value; + } public abstract WiredEffectType getType(); - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java index cde34021..b946d7d9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java @@ -8,39 +8,31 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionWiredExtra extends InteractionWired -{ - protected InteractionWiredExtra(ResultSet set, Item baseItem) throws SQLException - { +public abstract class InteractionWiredExtra extends InteractionWired { + protected InteractionWiredExtra(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - protected InteractionWiredExtra(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + protected InteractionWiredExtra(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { - if (room.hasRights(client.getHabbo())) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { + if (room.hasRights(client.getHabbo())) { this.activateBox(room); } } } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } } \ No newline at end of file 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 f9d030f9..5f79597a 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 @@ -15,158 +15,123 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionWiredHighscore extends HabboItem -{ +public class InteractionWiredHighscore extends HabboItem { public WiredHighscoreScoreType scoreType; public WiredHighscoreClearType clearType; private THashSet data; private int lastUpdate; - public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException - { + public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.scoreType = WiredHighscoreScoreType.CLASSIC; this.clearType = WiredHighscoreClearType.ALLTIME; - try - { + try { String name = this.getBaseItem().getName().split("_")[1].toUpperCase().split("\\*")[0]; int ctype = Integer.valueOf(this.getBaseItem().getName().split("\\*")[1]) - 1; this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - if(this.getRoomId() > 0) - { + if (this.getRoomId() > 0) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { this.reloadData(room); } } } - public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.scoreType = WiredHighscoreScoreType.CLASSIC; this.clearType = WiredHighscoreClearType.ALLTIME; - try - { + try { String name = this.getBaseItem().getName().split("_")[1].toUpperCase().split("\\*")[0]; int ctype = Integer.valueOf(this.getBaseItem().getName().split("\\*")[1]) - 1; this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) { this.setExtradata("0"); } - try - { + try { int state = Integer.valueOf(this.getExtradata()); this.setExtradata(Math.abs(state - 1) + ""); this.reloadData(room); room.updateItem(this); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(6); serverMessage.appendString(this.getExtradata()); serverMessage.appendInt(this.scoreType.type); //score type serverMessage.appendInt(this.clearType.type); //clear type - if(this.getRoomId() == 0) - { + if (this.getRoomId() == 0) { serverMessage.appendInt(0); - } - else - { + } else { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { serverMessage.appendInt(0); - } - else - { - if(Emulator.getIntUnixTimestamp() - this.lastUpdate > 60 * 60) - { + } else { + if (Emulator.getIntUnixTimestamp() - this.lastUpdate > 60 * 60) { this.reloadData(room); } - if(this.data != null) - { + if (this.data != null) { serverMessage.appendInt(this.data.size()); //count - for (WiredHighscoreData dataSet : this.data) - { - if (this.scoreType == WiredHighscoreScoreType.PERTEAM) - { + for (WiredHighscoreData dataSet : this.data) { + if (this.scoreType == WiredHighscoreScoreType.PERTEAM) { serverMessage.appendInt(dataSet.teamScore); //Team score - } else if (dataSet.usernames.length == 1) - { + } else if (dataSet.usernames.length == 1) { serverMessage.appendInt(dataSet.score); - } else - { + } else { serverMessage.appendInt(dataSet.totalScore); } serverMessage.appendInt(dataSet.usernames.length); //Users count - for (String codeDragon : dataSet.usernames) - { + for (String codeDragon : dataSet.usernames) { serverMessage.appendString(codeDragon); } } - } - else - { + } else { serverMessage.appendInt(0); } } @@ -176,23 +141,19 @@ public class InteractionWiredHighscore extends HabboItem } @Override - public void onPlace(Room room) - { + public void onPlace(Room room) { this.reloadData(room); } @Override - public void onPickUp(Room room) - { - if (this.data != null) - { + public void onPickUp(Room room) { + if (this.data != null) { this.data.clear(); } this.lastUpdate = 0; } - private void reloadData(Room room) - { + private void reloadData(Room room) { this.data = room.getWiredHighscoreData(this.scoreType, this.clearType); this.lastUpdate = Emulator.getIntUnixTimestamp(); } 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 cbc066f5..30ed0565 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 @@ -11,39 +11,31 @@ import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionWiredTrigger extends InteractionWired -{ +public abstract class InteractionWiredTrigger extends InteractionWired { private int delay; - protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException - { + protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - protected InteractionWiredTrigger(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + protected InteractionWiredTrigger(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if (client != null) - { - if (room.hasRights(client.getHabbo())) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null) { + if (room.hasRights(client.getHabbo())) { client.sendResponse(new WiredTriggerDataComposer(this, room)); this.activateBox(room); } @@ -51,20 +43,17 @@ public abstract class InteractionWiredTrigger extends InteractionWired } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @@ -72,18 +61,15 @@ public abstract class InteractionWiredTrigger extends InteractionWired public abstract boolean saveData(ClientMessage packet); - protected void setDelay(int value) - { - this.delay = value; - } - - protected int getDelay() - { + protected int getDelay() { return this.delay; } - public boolean isTriggeredByRoomUnit() - { + protected void setDelay(int value) { + this.delay = value; + } + + public boolean isTriggeredByRoomUnit() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java index a00690dc..438025a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java @@ -10,40 +10,33 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionYoutubeTV extends HabboItem -{ - public InteractionYoutubeTV(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionYoutubeTV extends HabboItem { + public InteractionYoutubeTV(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionYoutubeTV(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionYoutubeTV(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.getExtradata().length() == 0) + public void serializeExtradata(ServerMessage serverMessage) { + if (this.getExtradata().length() == 0) this.setExtradata(""); serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java index 83f1407b..b56491bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java @@ -10,35 +10,29 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionGameGate extends InteractionGameTeamItem -{ - public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public abstract class InteractionGameGate extends InteractionGameTeamItem { + public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); this.setExtradata("0"); } - public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); this.setExtradata("0"); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -48,11 +42,11 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem public void updateState(Game game, int maxPlayers) { int memberCount = 0; - if(game.getTeam(this.teamColor) != null) { + if (game.getTeam(this.teamColor) != null) { memberCount = game.getTeam(this.teamColor).getMembers().size(); } - if(memberCount > maxPlayers) { + if (memberCount > maxPlayers) { memberCount = maxPlayers; } this.setExtradata(memberCount + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java index a418d9ac..eb416b80 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java @@ -8,23 +8,19 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionGameScoreboard extends InteractionGameTeamItem -{ - protected InteractionGameScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public abstract class InteractionGameScoreboard extends InteractionGameTeamItem { + protected InteractionGameScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); this.setExtradata("0"); } - protected InteractionGameScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + protected InteractionGameScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -32,8 +28,7 @@ public abstract class InteractionGameScoreboard extends InteractionGameTeamItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java index 268aba05..f52ff6b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java @@ -7,19 +7,16 @@ import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionGameTeamItem extends HabboItem -{ +public abstract class InteractionGameTeamItem extends HabboItem { public final GameTeamColors teamColor; - protected InteractionGameTeamItem(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { + protected InteractionGameTeamItem(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem); this.teamColor = teamColor; } - protected InteractionGameTeamItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + protected InteractionGameTeamItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells); this.teamColor = teamColor; 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 b87bf269..186d3afd 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 @@ -4,9 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; -import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; -import com.eu.habbo.habbohotel.games.freeze.FreezeGame; -import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; @@ -17,75 +14,35 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; -import java.lang.reflect.InvocationTargetException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Map; -public abstract class InteractionGameTimer extends HabboItem implements Runnable -{ +public abstract class InteractionGameTimer extends HabboItem implements Runnable { private int baseTime = 0; private int timeNow = 0; private boolean isRunning = false; private boolean isPaused = false; private boolean threadActive = false; - public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException - { + public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); String[] data = set.getString("extra_data").split("\t"); - if (data.length >= 2) - { + if (data.length >= 2) { this.baseTime = Integer.valueOf(data[1]); this.timeNow = this.baseTime; } - if (data.length >= 1) - { + if (data.length >= 1) { this.setExtradata(data[0]); } } - public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public void run() { - if(this.needsUpdate() || this.needsDelete()) { - super.run(); - } - - if(this.getRoomId() == 0) { - this.threadActive = false; - return; - } - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if(room == null || !this.isRunning || this.isPaused) { - this.threadActive = false; - return; - } - - if(this.timeNow > 0) { - this.threadActive = true; - Emulator.getThreading().run(this, 1000); - this.timeNow--; - room.updateItem(this); - } - else { - this.isRunning = false; - this.isPaused = false; - this.threadActive = false; - endGamesIfLastTimer(room); - } - } - public static void endGamesIfLastTimer(Room room) { boolean gamesActive = false; for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { @@ -116,21 +73,65 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable } } - if(triggerWired) { + if (triggerWired) { WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); } } + public static Game getOrCreateGame(Room room, Class gameClass) { + Game game = (gameClass.cast(room.getGame(gameClass))); + + if (game == null) { + try { + game = gameClass.getDeclaredConstructor(Room.class).newInstance(room); + room.addGame(game); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } + + return game; + } + @Override - public void onPickUp(Room room) - { + public void run() { + if (this.needsUpdate() || this.needsDelete()) { + super.run(); + } + + if (this.getRoomId() == 0) { + this.threadActive = false; + return; + } + + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + + if (room == null || !this.isRunning || this.isPaused) { + this.threadActive = false; + return; + } + + if (this.timeNow > 0) { + this.threadActive = true; + Emulator.getThreading().run(this, 1000); + this.timeNow--; + room.updateItem(this); + } else { + this.isRunning = false; + this.isPaused = false; + this.threadActive = false; + endGamesIfLastTimer(room); + } + } + + @Override + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public void onPlace(Room room) - { - if(this.baseTime == 0) { + public void onPlace(Room room) { + if (this.baseTime == 0) { this.baseTime = 30; this.timeNow = this.baseTime; } @@ -140,8 +141,7 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString("" + timeNow); @@ -149,33 +149,28 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(this.getExtradata().isEmpty()) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (this.getExtradata().isEmpty()) { this.setExtradata("0"); } // if wired triggered it - if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning) - { + if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning) { endGamesIfLastTimer(room); - for(Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { + for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { Game game = getOrCreateGame(room, gameClass); - if(!game.isRunning) { + if (!game.isRunning) { game.initialise(); } } @@ -183,72 +178,68 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable timeNow = this.baseTime; this.isRunning = true; room.updateItem(this); - WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { }); + WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{}); - if(!this.threadActive) { + if (!this.threadActive) { this.threadActive = true; Emulator.getThreading().run(this); } - } - else if(client != null) - { + } else if (client != null) { if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER))) return; int state = 1; - if(objects.length >= 1 && objects[0] instanceof Integer) { + if (objects.length >= 1 && objects[0] instanceof Integer) { state = (Integer) objects[0]; } - switch (state) - { + switch (state) { case 1: - if(this.isRunning) { + if (this.isRunning) { this.isPaused = !this.isPaused; boolean allPaused = this.isPaused; - for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { - if(!timer.isPaused) + for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { + if (!timer.isPaused) allPaused = false; } - for(Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { + for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { Game game = getOrCreateGame(room, gameClass); - if(allPaused) { + if (allPaused) { game.pause(); - } - else { + } else { game.unpause(); } } - if(!this.isPaused) { + if (!this.isPaused) { this.isRunning = true; timeNow = this.baseTime; room.updateItem(this); - if(!this.threadActive) { + if (!this.threadActive) { this.threadActive = true; Emulator.getThreading().run(this); } } } - if(!this.isRunning) { + if (!this.isRunning) { endGamesIfLastTimer(room); - for(Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { + for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { Game game = getOrCreateGame(room, gameClass); game.initialise(); } - WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { }); + WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{}); this.isRunning = true; timeNow = this.baseTime; room.updateItem(this); - if(!this.threadActive) { + if (!this.threadActive) { this.threadActive = true; Emulator.getThreading().run(this); } @@ -256,12 +247,12 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable break; case 2: - if(!this.isRunning) { + if (!this.isRunning) { this.increaseTimer(room); return; } - if(this.isPaused) { + if (this.isPaused) { this.isPaused = false; this.isRunning = false; @@ -298,42 +289,35 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } - public static Game getOrCreateGame(Room room, Class gameClass) - { - Game game = (gameClass.cast(room.getGame(gameClass))); - - if (game == null) { - try { - game = gameClass.getDeclaredConstructor(Room.class).newInstance(room); - room.addGame(game); - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); - } - } - - return game; - } - - private void increaseTimer(Room room) - { - if(this.isRunning) + private void increaseTimer(Room room) { + if (this.isRunning) return; this.needsUpdate(true); - switch(this.baseTime) - { - case 0: this.baseTime = 30; break; - case 30: this.baseTime = 60; break; - case 60: this.baseTime = 120; break; - case 120: this.baseTime = 180; break; - case 180: this.baseTime = 300; break; - case 300: this.baseTime = 600; break; + switch (this.baseTime) { + case 0: + this.baseTime = 30; + break; + case 30: + this.baseTime = 60; + break; + case 60: + this.baseTime = 120; + break; + case 120: + this.baseTime = 180; + break; + case 180: + this.baseTime = 300; + break; + case 300: + this.baseTime = 600; + break; //case 600: this.baseTime = 0; break; default: @@ -346,16 +330,14 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable } @Override - public String getDatabaseExtraData() - { + public String getDatabaseExtraData() { return this.getExtradata() + "\t" + this.baseTime; } public abstract Class getGameType(); @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return true; } 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 7ed26f14..ca9ecee2 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 @@ -12,86 +12,72 @@ import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiPuck extends InteractionPushable -{ - public InteractionBattleBanzaiPuck(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBattleBanzaiPuck extends InteractionPushable { + public InteractionBattleBanzaiPuck(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBattleBanzaiPuck(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiPuck(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public int getWalkOnVelocity(RoomUnit roomUnit, Room room) - { + public int getWalkOnVelocity(RoomUnit roomUnit, Room room) { return 6; } @Override - public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public int getWalkOffVelocity(RoomUnit roomUnit, Room room) - { + public int getWalkOffVelocity(RoomUnit roomUnit, Room room) { return 0; } @Override - public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public int getDragVelocity(RoomUnit roomUnit, Room room) - { + public int getDragVelocity(RoomUnit roomUnit, Room room) { return 1; } @Override - public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public int getTackleVelocity(RoomUnit roomUnit, Room room) - { + public int getTackleVelocity(RoomUnit roomUnit, Room room) { return 6; } @Override - public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public int getNextRollDelay(int currentStep, int totalSteps) - { + public int getNextRollDelay(int currentStep, int totalSteps) { int t = 2500; - return (totalSteps == 1) ? 500 : 100*((t=t/t-1)*t*t*t*t + 1) + (currentStep * 100); + return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100); } @Override - public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) - { - switch(currentDirection) - { + public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) { + switch (currentDirection) { default: case NORTH: return RoomUserRotation.SOUTH; case NORTH_EAST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) return RoomUserRotation.NORTH_WEST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) return RoomUserRotation.SOUTH_EAST; else return RoomUserRotation.SOUTH_WEST; @@ -100,9 +86,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable return RoomUserRotation.WEST; case SOUTH_EAST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) return RoomUserRotation.SOUTH_WEST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) return RoomUserRotation.NORTH_EAST; else return RoomUserRotation.NORTH_WEST; @@ -111,9 +97,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable return RoomUserRotation.NORTH; case SOUTH_WEST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) return RoomUserRotation.SOUTH_EAST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) return RoomUserRotation.NORTH_WEST; else return RoomUserRotation.NORTH_EAST; @@ -122,9 +108,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable return RoomUserRotation.EAST; case NORTH_WEST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) return RoomUserRotation.NORTH_EAST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) return RoomUserRotation.SOUTH_WEST; else return RoomUserRotation.SOUTH_EAST; @@ -132,14 +118,12 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public boolean validMove(Room room, RoomTile from, RoomTile to) - { + public boolean validMove(Room room, RoomTile from, RoomTile to) { if (room == null || from == null || to == null) return false; HabboItem topItem = room.getTopItemAt(to.x, to.y, this); @@ -148,45 +132,35 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable } @Override - public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) - { + public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { Habbo habbo = room.getHabbo(kicker); - if (habbo != null) - { - BattleBanzaiGame game = (BattleBanzaiGame)room.getGame(BattleBanzaiGame.class); - if (game != null) - { + if (habbo != null) { + BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); + if (game != null) { GameTeam team = game.getTeamForHabbo(habbo); - if (team != null) - { + if (team != null) { HabboItem item = room.getTopItemAt(to.x, to.y); - if (item instanceof InteractionBattleBanzaiTile) - { - try - { + if (item instanceof InteractionBattleBanzaiTile) { + try { item.onWalkOn(kicker, room, null); - } catch (Exception e) - { + } catch (Exception e) { return; } } @@ -200,20 +174,17 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable } @Override - public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) - { + public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) { } @Override - public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) - { + public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) { } @Override - public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) - { + public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { HabboItem topItem = room.getTopItemAt(to.x, to.y); return to.state == RoomTileState.OPEN && to.isWalkable() && topItem instanceof InteractionBattleBanzaiTile; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java index b1bafc2c..8494b4c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java @@ -9,23 +9,19 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiSphere extends HabboItem -{ - public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBattleBanzaiSphere extends HabboItem { + public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionBattleBanzaiSphere(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiSphere(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -33,19 +29,16 @@ public class InteractionBattleBanzaiSphere extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index a3213f07..067f1056 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.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.threading.runnables.BanzaiRandomTeleport; @@ -14,23 +13,19 @@ import com.eu.habbo.threading.runnables.BanzaiRandomTeleport; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiTeleporter extends HabboItem -{ - public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBattleBanzaiTeleporter extends HabboItem { + public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionBattleBanzaiTeleporter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiTeleporter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -38,32 +33,27 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this); @@ -80,8 +70,7 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); } } 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 f955e4cc..24e98ed6 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 @@ -16,23 +16,19 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionBattleBanzaiTile extends HabboItem -{ - public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBattleBanzaiTile extends HabboItem { + public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionBattleBanzaiTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -40,52 +36,47 @@ public class InteractionBattleBanzaiTile extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if(this.getExtradata().isEmpty()) + if (this.getExtradata().isEmpty()) this.setExtradata("0"); int state = Integer.valueOf(this.getExtradata()); - if(state % 3 == 2) + if (state % 3 == 2) return; Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return; - if(this.isLocked()) + if (this.isLocked()) return; - if(habbo.getHabboInfo().getCurrentGame() != null && habbo.getHabboInfo().getCurrentGame().equals(BattleBanzaiGame.class)) - { - BattleBanzaiGame game = ((BattleBanzaiGame)room.getGame(BattleBanzaiGame.class)); + if (habbo.getHabboInfo().getCurrentGame() != null && habbo.getHabboInfo().getCurrentGame().equals(BattleBanzaiGame.class)) { + BattleBanzaiGame game = ((BattleBanzaiGame) room.getGame(BattleBanzaiGame.class)); - if(game == null) + if (game == null) return; - if(!game.state.equals(GameState.RUNNING)) + if (!game.state.equals(GameState.RUNNING)) return; game.markTile(habbo, this, state); @@ -93,19 +84,16 @@ public class InteractionBattleBanzaiTile extends HabboItem } - public boolean isLocked() - { - if(this.getExtradata().isEmpty()) + public boolean isLocked() { + if (this.getExtradata().isEmpty()) return false; return Integer.valueOf(this.getExtradata()) % 3 == 2; } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) - { - for (Pair> set : itemsAtLocation) - { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java index fff7871e..e21ff2d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java @@ -10,39 +10,32 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiTimer extends InteractionGameTimer -{ - public InteractionBattleBanzaiTimer(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBattleBanzaiTimer extends InteractionGameTimer { + public InteractionBattleBanzaiTimer(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBattleBanzaiTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public Class getGameType() - { + public Class getGameType() { return BattleBanzaiGame.class; } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } 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 28637cba..5948ec9e 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 @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; @@ -10,65 +9,53 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiGate extends InteractionGameGate -{ - public InteractionBattleBanzaiGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public class InteractionBattleBanzaiGate extends InteractionGameGate { + public InteractionBattleBanzaiGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); } - public InteractionBattleBanzaiGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionBattleBanzaiGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); } @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); + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + return room.getGame(BattleBanzaiGame.class) == null || ((BattleBanzaiGame) room.getGame(BattleBanzaiGame.class)).state.equals(GameState.IDLE); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return false; - return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame)(room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE); + return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame) (room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } //TODO: Move to upper class @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); - if(game == null) - { + if (game == null) { game = BattleBanzaiGame.class.getDeclaredConstructor(Room.class).newInstance(room); room.addGame(game); } GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit)); - if(team != null) - { + if (team != null) { game.removeHabbo(room.getHabbo(roomUnit)); - } - else - { + } else { game.addHabbo(room.getHabbo(roomUnit), this.teamColor); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java index c9f2ddde..206bd98b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiGateBlue extends InteractionBattleBanzaiGate -{ +public class InteractionBattleBanzaiGateBlue extends InteractionBattleBanzaiGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.BLUE; - public InteractionBattleBanzaiGateBlue(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiGateBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java index 8884a79a..ee488fba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiGateGreen extends InteractionBattleBanzaiGate -{ +public class InteractionBattleBanzaiGateGreen extends InteractionBattleBanzaiGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.GREEN; - public InteractionBattleBanzaiGateGreen(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiGateGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java index 52394503..ceeca701 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiGateRed extends InteractionBattleBanzaiGate -{ +public class InteractionBattleBanzaiGateRed extends InteractionBattleBanzaiGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.RED; - public InteractionBattleBanzaiGateRed(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiGateRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java index b37e176a..ec6609e4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiGateYellow extends InteractionBattleBanzaiGate -{ +public class InteractionBattleBanzaiGateYellow extends InteractionBattleBanzaiGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.YELLOW; - public InteractionBattleBanzaiGateYellow(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiGateYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java index 04d7e731..e3b8c24f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java @@ -9,33 +9,27 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiScoreboard extends InteractionGameScoreboard -{ - public InteractionBattleBanzaiScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public class InteractionBattleBanzaiScoreboard extends InteractionGameScoreboard { + public InteractionBattleBanzaiScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); } - public InteractionBattleBanzaiScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionBattleBanzaiScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java index 9862d9f5..a5452738 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiScoreboardBlue extends InteractionBattleBanzaiScoreboard -{ +public class InteractionBattleBanzaiScoreboardBlue extends InteractionBattleBanzaiScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.BLUE; - public InteractionBattleBanzaiScoreboardBlue(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiScoreboardBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java index f0f9f5d2..a42332f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiScoreboardGreen extends InteractionBattleBanzaiScoreboard -{ +public class InteractionBattleBanzaiScoreboardGreen extends InteractionBattleBanzaiScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.GREEN; - public InteractionBattleBanzaiScoreboardGreen(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiScoreboardGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java index c598b6c9..9abf0aad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiScoreboardRed extends InteractionBattleBanzaiScoreboard -{ +public class InteractionBattleBanzaiScoreboardRed extends InteractionBattleBanzaiScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.RED; - public InteractionBattleBanzaiScoreboardRed(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiScoreboardRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java index 759caa8d..6b4b8950 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiScoreboardYellow extends InteractionBattleBanzaiScoreboard -{ +public class InteractionBattleBanzaiScoreboardYellow extends InteractionBattleBanzaiScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.YELLOW; - public InteractionBattleBanzaiScoreboardYellow(ResultSet set, Item baseItem) throws SQLException - { + public InteractionBattleBanzaiScoreboardYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBattleBanzaiScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } 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 d3c5f8ea..482a3d96 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 @@ -18,99 +18,82 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootball extends InteractionPushable -{ +public class InteractionFootball extends InteractionPushable { - public InteractionFootball(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFootball(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionFootball(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootball(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public int getWalkOnVelocity(RoomUnit roomUnit, Room room) - { - if(roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) + public int getWalkOnVelocity(RoomUnit roomUnit, Room room) { + if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) return 0; return 6; } @Override - public int getWalkOffVelocity(RoomUnit roomUnit, Room room) - { + public int getWalkOffVelocity(RoomUnit roomUnit, Room room) { return 6; } @Override - public int getDragVelocity(RoomUnit roomUnit, Room room) - { - if(roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) + public int getDragVelocity(RoomUnit roomUnit, Room room) { + if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) return 0; return 1; } @Override - public int getTackleVelocity(RoomUnit roomUnit, Room room) - { + public int getTackleVelocity(RoomUnit roomUnit, Room room) { return 4; } - @Override - public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) - { + 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]; } - public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } - public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) - { + public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } - @Override - public int getNextRollDelay(int currentStep, int totalSteps) - { + public int getNextRollDelay(int currentStep, int totalSteps) { int t = 2500; - return (totalSteps == 1) ? 500 : 100*((t=t/t-1)*t*t*t*t + 1) + (currentStep * 100); + return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100); } @Override - public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) - { - switch(currentDirection) - { + public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) { + switch (currentDirection) { default: case NORTH: return RoomUserRotation.SOUTH; case NORTH_EAST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) return RoomUserRotation.NORTH_WEST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) return RoomUserRotation.SOUTH_EAST; else return RoomUserRotation.SOUTH_WEST; @@ -119,9 +102,9 @@ public class InteractionFootball extends InteractionPushable return RoomUserRotation.WEST; case SOUTH_EAST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) return RoomUserRotation.SOUTH_WEST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) return RoomUserRotation.NORTH_EAST; else return RoomUserRotation.NORTH_WEST; @@ -130,9 +113,9 @@ public class InteractionFootball extends InteractionPushable return RoomUserRotation.NORTH; case SOUTH_WEST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) return RoomUserRotation.SOUTH_EAST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) return RoomUserRotation.NORTH_WEST; else return RoomUserRotation.NORTH_EAST; @@ -141,9 +124,9 @@ public class InteractionFootball extends InteractionPushable return RoomUserRotation.EAST; case NORTH_WEST: - if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) return RoomUserRotation.NORTH_EAST; - else if(this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) return RoomUserRotation.SOUTH_WEST; else return RoomUserRotation.SOUTH_EAST; @@ -151,10 +134,8 @@ public class InteractionFootball extends InteractionPushable } - @Override - public boolean validMove(Room room, RoomTile from, RoomTile to) - { + 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()))); @@ -163,43 +144,35 @@ public class InteractionFootball extends InteractionPushable //Events @Override - public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) - { + public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { } @Override - public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) - { - FootballGame game = (FootballGame)room.getGame(FootballGame.class); + public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { + FootballGame game = (FootballGame) room.getGame(FootballGame.class); if (game == null) { - try - { - game = FootballGame.class.getDeclaredConstructor(new Class[] { Room.class }).newInstance(room); + try { + game = FootballGame.class.getDeclaredConstructor(new Class[]{Room.class}).newInstance(room); room.addGame(game); - } - catch (Exception e) - { + } catch (Exception e) { return; } } HabboItem currentTopItem = room.getTopItemAt(from.x, from.y, this); HabboItem topItem = room.getTopItemAt(to.x, to.y, this); - if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && ((topItem instanceof InteractionFootballGoal))) - { - GameTeamColors color = ((InteractionGameTeamItem)topItem).teamColor; + if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && ((topItem instanceof InteractionFootballGoal))) { + GameTeamColors color = ((InteractionGameTeamItem) topItem).teamColor; game.onScore(kicker, color); } @@ -208,28 +181,24 @@ public class InteractionFootball extends InteractionPushable } @Override - public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) - { + public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) { } @Override - public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) - { + public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) { this.setExtradata("0"); room.sendComposer(new ItemStateComposer(this).compose()); } @Override - public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) - { + public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { HabboItem topItem = room.getTopItemAt(from.x, from.y, this); return !(room.hasHabbosAt(to.x, to.y) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } 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 7f24355a..73db3741 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 @@ -19,14 +19,12 @@ import com.eu.habbo.util.figure.FigureUtil; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGate extends HabboItem -{ +public class InteractionFootballGate extends HabboItem { private static final String CACHE_KEY = "fball_gate_look"; private String figureM; private String figureF; - public InteractionFootballGate(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFootballGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); String[] bits = set.getString("extra_data").split(";"); @@ -34,8 +32,7 @@ public class InteractionFootballGate extends HabboItem this.figureF = bits.length > 1 ? bits[1] : ""; } - public InteractionFootballGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); String[] bits = extradata.split(";"); @@ -43,8 +40,39 @@ public class InteractionFootballGate extends HabboItem this.figureF = bits.length > 1 ? bits[1] : ""; } - public void setFigureM(String look) - { + @EventHandler + public static void onUserDisconnectEvent(UserDisconnectEvent event) { + if (event.habbo != null) { + removeLook(event.habbo); + } + } + + @EventHandler + public static void onUserExitRoomEvent(UserExitRoomEvent event) { + if (event.habbo != null) { + removeLook(event.habbo); + } + } + + @EventHandler + public static void onUserSavedLookEvent(UserSavedLookEvent event) { + if (event.habbo != null) { + removeLook(event.habbo); + } + } + + 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); + habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo)); + if (habbo.getHabboInfo().getCurrentRoom() != null) { + habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); + } + } + } + + public void setFigureM(String look) { this.figureM = look; this.setExtradata(this.figureM + ";" + this.figureF); @@ -52,8 +80,7 @@ public class InteractionFootballGate extends HabboItem Emulator.getThreading().run(this); } - public void setFigureF(String look) - { + public void setFigureF(String look) { this.figureF = look; this.setExtradata(this.figureM + ";" + this.figureF); @@ -61,47 +88,38 @@ public class InteractionFootballGate extends HabboItem Emulator.getThreading().run(this); } - @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.figureM + "," + this.figureF); super.serializeExtradata(serverMessage); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + 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 != null) { + if (habbo.getHabboStats().cache.containsKey(CACHE_KEY)) { + String oldlook = (String) habbo.getHabboStats().cache.get(CACHE_KEY); UserSavedLookEvent lookEvent = new UserSavedLookEvent(habbo, habbo.getHabboInfo().getGender(), oldlook); Emulator.getPluginManager().fireEvent(lookEvent); - if(!lookEvent.isCancelled()) - { + if (!lookEvent.isCancelled()) { habbo.getHabboInfo().setLook(lookEvent.newLook); Emulator.getThreading().run(habbo.getHabboInfo()); habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo)); @@ -109,15 +127,12 @@ public class InteractionFootballGate extends HabboItem } habbo.getHabboStats().cache.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" }); + } 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()) - { + if (!lookEvent.isCancelled()) { habbo.getHabboStats().cache.put(CACHE_KEY, habbo.getHabboInfo().getLook()); habbo.getHabboInfo().setLook(lookEvent.newLook); Emulator.getThreading().run(habbo.getHabboInfo()); @@ -129,45 +144,4 @@ public class InteractionFootballGate extends HabboItem super.onWalkOn(roomUnit, room, objects); } - - @EventHandler - public static void onUserDisconnectEvent(UserDisconnectEvent event) - { - if (event.habbo != null) - { - removeLook(event.habbo); - } - } - - @EventHandler - public static void onUserExitRoomEvent(UserExitRoomEvent event) - { - if (event.habbo != null) - { - removeLook(event.habbo); - } - } - - @EventHandler - public static void onUserSavedLookEvent(UserSavedLookEvent event) - { - if (event.habbo != null) - { - removeLook(event.habbo); - } - } - - 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); - habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) - { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); - } - } - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java index 49115d08..7386b365 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java @@ -10,39 +10,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGoal extends InteractionGameTeamItem -{ - public InteractionFootballGoal(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public class InteractionFootballGoal extends InteractionGameTeamItem { + public InteractionFootballGoal(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); } - public InteractionFootballGoal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionFootballGoal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java index bcd63e00..34d2b52f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGoalBlue extends InteractionFootballGoal -{ - public InteractionFootballGoalBlue(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballGoalBlue extends InteractionFootballGoal { + public InteractionFootballGoalBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.BLUE); } - public InteractionFootballGoalBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballGoalBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java index f5c5c54c..42276c9e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGoalGreen extends InteractionFootballGoal -{ - public InteractionFootballGoalGreen(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballGoalGreen extends InteractionFootballGoal { + public InteractionFootballGoalGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.GREEN); } - public InteractionFootballGoalGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballGoalGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java index 15555bbd..b4d9b5d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGoalRed extends InteractionFootballGoal -{ - public InteractionFootballGoalRed(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballGoalRed extends InteractionFootballGoal { + public InteractionFootballGoalRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.RED); } - public InteractionFootballGoalRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballGoalRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java index 11675fc1..ba725033 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGoalYellow extends InteractionFootballGoal -{ - public InteractionFootballGoalYellow(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballGoalYellow extends InteractionFootballGoal { + public InteractionFootballGoalYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.YELLOW); } - public InteractionFootballGoalYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballGoalYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); } } \ No newline at end of file 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 1839cfd0..2ef7f309 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 @@ -13,60 +13,48 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballScoreboard extends InteractionGameScoreboard -{ +public class InteractionFootballScoreboard extends InteractionGameScoreboard { private int score; - public InteractionFootballScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { + public InteractionFootballScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); - try - { + try { this.score = Integer.parseInt(this.getExtradata()); - } - catch (Exception e) - { + } catch (Exception e) { this.score = 0; } } - public InteractionFootballScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionFootballScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); - try - { + try { this.score = Integer.parseInt(extradata); - } - catch (Exception e) - { + } catch (Exception e) { this.score = 0; } } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } - public int changeScore(int amount) - { + public int changeScore(int amount) { this.score += amount; - if(this.score > 99) { + if (this.score > 99) { this.score = 0; } - if(this.score < 0) { + if (this.score < 0) { this.score = 99; } @@ -74,23 +62,25 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard this.needsUpdate(true); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { room.updateItem(this); } return this.score; } - public void setScore(int amount) - { + public int getScore() { + return this.score; + } + + public void setScore(int amount) { this.score = amount; - if(this.score > 99) { + if (this.score > 99) { this.score = 0; } - if(this.score < 0) { + if (this.score < 0) { this.score = 99; } @@ -98,36 +88,25 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard this.needsUpdate(true); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { room.updateItem(this); } } - public int getScore() - { - return this.score; - } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if(objects.length >= 1 && objects[0] instanceof Integer && client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) - { - int state = (Integer)objects[0]; + if (objects.length >= 1 && objects[0] instanceof Integer && client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) { + int state = (Integer) objects[0]; - switch (state) - { - case 1: - { + switch (state) { + case 1: { this.changeScore(1); } break; - case 2: - { + case 2: { this.changeScore(-1); } break; @@ -136,28 +115,23 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard this.setScore(0); break; } - } - else - { + } else { this.changeScore(1); } } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java index 822d55ea..1a4cd219 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballScoreboardBlue extends InteractionFootballScoreboard -{ - public InteractionFootballScoreboardBlue(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballScoreboardBlue extends InteractionFootballScoreboard { + public InteractionFootballScoreboardBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.BLUE); } - public InteractionFootballScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java index 35b18240..1f785c0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballScoreboardGreen extends InteractionFootballScoreboard -{ - public InteractionFootballScoreboardGreen(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballScoreboardGreen extends InteractionFootballScoreboard { + public InteractionFootballScoreboardGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.GREEN); } - public InteractionFootballScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java index 61f35b59..6d65b7ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballScoreboardRed extends InteractionFootballScoreboard -{ - public InteractionFootballScoreboardRed(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballScoreboardRed extends InteractionFootballScoreboard { + public InteractionFootballScoreboardRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.RED); -} + } - public InteractionFootballScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java index ae16a328..731a9e82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballScoreboardYellow extends InteractionFootballScoreboard -{ - public InteractionFootballScoreboardYellow(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFootballScoreboardYellow extends InteractionFootballScoreboard { + public InteractionFootballScoreboardYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, GameTeamColors.YELLOW); } - public InteractionFootballScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFootballScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); } } \ No newline at end of file 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 a1c97f8b..84ed5552 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 @@ -17,45 +17,37 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeBlock extends HabboItem -{ - public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFreezeBlock extends HabboItem { + public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionFreezeBlock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeBlock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { if (client == null) return; HabboItem item = null; THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); - for(HabboItem i : items) - { - if(i instanceof InteractionFreezeTile) - { - if(item == null || i.getZ() <= item.getZ()) - { + for (HabboItem i : items) { + if (i instanceof InteractionFreezeTile) { + if (item == null || i.getZ() <= item.getZ()) { item = i; } } } - if(item != null) - { + if (item != null) { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); - if(game == null) + if (game == null) return; game.throwBall(client.getHabbo(), (InteractionFreezeTile) item); @@ -63,10 +55,8 @@ public class InteractionFreezeBlock extends HabboItem } @Override - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.getExtradata().length() == 0) - { + public void serializeExtradata(ServerMessage serverMessage) { + if (this.getExtradata().length() == 0) { this.setExtradata("0"); } serverMessage.appendInt((this.isLimited() ? 256 : 0)); @@ -76,33 +66,29 @@ public class InteractionFreezeBlock extends HabboItem } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return this.isWalkable(); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return !this.getExtradata().isEmpty() && !this.getExtradata().equals("0"); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if(this.getExtradata().isEmpty() || this.getExtradata().equalsIgnoreCase("0")) + if (this.getExtradata().isEmpty() || this.getExtradata().equalsIgnoreCase("0")) return; FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); - if(game == null || !game.state.equals(GameState.RUNNING)) + if (game == null || !game.state.equals(GameState.RUNNING)) return; Habbo habbo = room.getHabbo(roomUnit); @@ -110,22 +96,20 @@ public class InteractionFreezeBlock extends HabboItem if (habbo == null || habbo.getHabboInfo().getCurrentGame() != FreezeGame.class) return; - FreezeGamePlayer player = (FreezeGamePlayer)habbo.getHabboInfo().getGamePlayer(); + FreezeGamePlayer player = (FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer(); - if(player == null) + if (player == null) return; int powerUp; try { powerUp = Integer.valueOf(this.getExtradata()) / 1000; - } - catch (NumberFormatException e){ + } catch (NumberFormatException e) { powerUp = 0; } - if(powerUp >= 2 && powerUp <= 7) - { - if(powerUp == 6 && !player.canPickupLife()) + if (powerUp >= 2 && powerUp <= 7) { + if (powerUp == 6 && !player.canPickupLife()) return; this.setExtradata((powerUp + 10) * 1000 + ""); @@ -139,8 +123,7 @@ public class InteractionFreezeBlock extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java index 0ca61680..cf07b29f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java @@ -9,47 +9,39 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeExitTile extends HabboItem -{ - public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFreezeExitTile extends HabboItem { + public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionFreezeExitTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeExitTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); 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 5f7b3de4..f8971b4f 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 @@ -15,40 +15,33 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionFreezeTile extends HabboItem -{ - public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFreezeTile extends HabboItem { + public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionFreezeTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return true; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { if (client == null) return; - if (client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY()) - { + if (client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY()) { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); if (game != null) @@ -57,14 +50,12 @@ public class InteractionFreezeTile extends HabboItem } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -72,23 +63,19 @@ public class InteractionFreezeTile extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } @Override - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) - { - for (Pair> set : itemsAtLocation) - { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { if (!set.getValue().isEmpty()) return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java index 4ba621f9..e2e91480 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java @@ -11,46 +11,38 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeTimer extends InteractionGameTimer -{ - public InteractionFreezeTimer(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionFreezeTimer extends InteractionGameTimer { + public InteractionFreezeTimer(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionFreezeTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); } @Override - public Class getGameType() - { + public Class getGameType() { return FreezeGame.class; } } 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 46ffbe68..96daf1d2 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 @@ -12,60 +12,49 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeGate extends InteractionGameGate -{ - public InteractionFreezeGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public class InteractionFreezeGate extends InteractionGameGate { + public InteractionFreezeGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); } - public InteractionFreezeGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + public InteractionFreezeGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); } @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); + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + return room.getGame(FreezeGame.class) == null || ((FreezeGame) room.getGame(FreezeGame.class)).state.equals(GameState.IDLE); } @Override - public boolean isWalkable() - { + public boolean isWalkable() { if (this.getRoomId() == 0) return false; return (this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5); - //((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null || - //!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning; + //((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null || + //!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); - if(game == null) - { + if (game == null) { game = FreezeGame.class.getDeclaredConstructor(Room.class).newInstance(room); room.addGame(game); } GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit)); - if(team != null) - { + if (team != null) { game.removeHabbo(room.getHabbo(roomUnit)); - } - else - { + } else { game.addHabbo(room.getHabbo(roomUnit), this.teamColor); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java index ae9b9370..90040250 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeGateBlue extends InteractionFreezeGate -{ +public class InteractionFreezeGateBlue extends InteractionFreezeGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.BLUE; - public InteractionFreezeGateBlue(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeGateBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java index 92fef3ac..dd62a2eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeGateGreen extends InteractionFreezeGate -{ +public class InteractionFreezeGateGreen extends InteractionFreezeGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.GREEN; - public InteractionFreezeGateGreen(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeGateGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java index aaaf3f15..7f502050 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeGateRed extends InteractionFreezeGate -{ +public class InteractionFreezeGateRed extends InteractionFreezeGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.RED; - public InteractionFreezeGateRed(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeGateRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java index dd4c9b70..418ce0ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeGateYellow extends InteractionFreezeGate -{ +public class InteractionFreezeGateYellow extends InteractionFreezeGate { public static final GameTeamColors TEAM_COLOR = GameTeamColors.YELLOW; - public InteractionFreezeGateYellow(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeGateYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java index 305928a8..2baee005 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java @@ -9,33 +9,27 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeScoreboard extends InteractionGameScoreboard -{ - InteractionFreezeScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException - { +public class InteractionFreezeScoreboard extends InteractionGameScoreboard { + InteractionFreezeScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); } - InteractionFreezeScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) - { + InteractionFreezeScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java index 6b1d3957..9c005626 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeScoreboardBlue extends InteractionFreezeScoreboard -{ +public class InteractionFreezeScoreboardBlue extends InteractionFreezeScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.BLUE; - public InteractionFreezeScoreboardBlue(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeScoreboardBlue(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java index 1be33a7f..3ce66539 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeScoreboardGreen extends InteractionFreezeScoreboard -{ +public class InteractionFreezeScoreboardGreen extends InteractionFreezeScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.GREEN; - public InteractionFreezeScoreboardGreen(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeScoreboardGreen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java index 2214b21e..9846fa55 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeScoreboardRed extends InteractionFreezeScoreboard -{ +public class InteractionFreezeScoreboardRed extends InteractionFreezeScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.RED; - public InteractionFreezeScoreboardRed(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeScoreboardRed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java index 897810ba..1c9d94e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeScoreboardYellow extends InteractionFreezeScoreboard -{ +public class InteractionFreezeScoreboardYellow extends InteractionFreezeScoreboard { public static final GameTeamColors TEAM_COLOR = GameTeamColors.YELLOW; - public InteractionFreezeScoreboardYellow(ResultSet set, Item baseItem) throws SQLException - { + public InteractionFreezeScoreboardYellow(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionFreezeScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java index cc18e744..2e97d3f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java @@ -12,62 +12,51 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionTagField extends HabboItem -{ +public abstract class InteractionTagField extends HabboItem { public Class gameClazz; - public InteractionTagField(ResultSet set, Item baseItem, Class gameClazz) throws SQLException - { + public InteractionTagField(ResultSet set, Item baseItem, Class gameClazz) throws SQLException { super(set, baseItem); this.gameClazz = gameClazz; } - public InteractionTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, Class gameClazz) - { + public InteractionTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, Class gameClazz) { super(id, userId, item, extradata, limitedStack, limitedSells); this.gameClazz = gameClazz; } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getCurrentGame() == null || habbo.getHabboInfo().getCurrentGame() == this.gameClazz; } - return false; + return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return true; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - if (habbo.getHabboInfo().getCurrentGame() == null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentGame() == null) { TagGame game = (TagGame) room.getGame(this.gameClazz); - if (game == null) - { + if (game == null) { game = (TagGame) this.gameClazz.getDeclaredConstructor(Room.class).newInstance(room); room.addGame(game); } @@ -79,14 +68,12 @@ public abstract class InteractionTagField extends HabboItem } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java index d7dd1fad..0b9598e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java @@ -9,39 +9,32 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTagPole extends HabboItem -{ - public InteractionTagPole(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionTagPole extends HabboItem { + public InteractionTagPole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) - { + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { return false; } @Override - public boolean isWalkable() - { + public boolean isWalkable() { return false; } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void serializeExtradata(ServerMessage serverMessage) - { + public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); @@ -49,8 +42,7 @@ public class InteractionTagPole extends HabboItem } @Override - public void onPickUp(Room room) - { + public void onPickUp(Room room) { this.setExtradata("0"); } } 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 540542dc..f0ce6d36 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 @@ -7,15 +7,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBunnyrunField extends InteractionTagField -{ - public InteractionBunnyrunField(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBunnyrunField extends InteractionTagField { + public InteractionBunnyrunField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, BunnyrunGame.class); } - public InteractionBunnyrunField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBunnyrunField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, BunnyrunGame.class); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java index 7b2cd035..9c0ae732 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBunnyrunPole extends InteractionTagPole -{ - public InteractionBunnyrunPole(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionBunnyrunPole extends InteractionTagPole { + public InteractionBunnyrunPole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionBunnyrunPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionBunnyrunPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } } \ No newline at end of file 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 fdab39d7..c30fe59e 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 @@ -7,15 +7,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionIceTagField extends InteractionTagField -{ - public InteractionIceTagField(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionIceTagField extends InteractionTagField { + public InteractionIceTagField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, IceTagGame.class); } - public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, IceTagGame.class); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java index 46040ec6..b2fe44c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionIceTagPole extends InteractionTagPole -{ - public InteractionIceTagPole(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionIceTagPole extends InteractionTagPole { + public InteractionIceTagPole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionIceTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionIceTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java index a84a0824..b00750d1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java @@ -7,15 +7,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionRollerskateField extends InteractionTagField -{ - public InteractionRollerskateField(ResultSet set, Item baseItem) throws SQLException - { +public class InteractionRollerskateField extends InteractionTagField { + public InteractionRollerskateField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, RollerskateGame.class); } - public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, RollerskateGame.class); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java index 53e0732b..81dd0284 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired; -public interface WiredTriggerReset -{ +public interface WiredTriggerReset { void resetTimer(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java index 1e827215..f65b7dfc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java @@ -14,29 +14,24 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionBattleBanzaiGameActive extends InteractionWiredCondition -{ +public class WiredConditionBattleBanzaiGameActive extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP; - public WiredConditionBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -51,34 +46,29 @@ public class WiredConditionBattleBanzaiGameActive extends InteractionWiredCondi } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Game game = room.getGame(BattleBanzaiGame.class); return game != null && game.state.equals(GameState.RUNNING); } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } } \ No newline at end of file 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 db8a80a3..30ba25bd 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 @@ -12,32 +12,27 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionDateRangeActive extends InteractionWiredCondition -{ +public class WiredConditionDateRangeActive extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.DATE_RANGE; private int startDate; private int endDate; - public WiredConditionDateRangeActive(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionDateRangeActive(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionDateRangeActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionDateRangeActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -54,8 +49,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.startDate = packet.readInt(); this.endDate = packet.readInt(); @@ -63,39 +57,31 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int time = Emulator.getIntUnixTimestamp(); return this.startDate < time && this.endDate >= time; } @Override - public String getWiredData() - { + public String getWiredData() { return this.startDate + "\t" + this.endDate; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if (data.length == 2) - { - try - { + if (data.length == 2) { + try { this.startDate = Integer.valueOf(data[0]); this.endDate = Integer.valueOf(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.startDate = 0; this.endDate = 0; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java index 740d5fd1..62009610 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java @@ -14,29 +14,24 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionFreezeGameActive extends InteractionWiredCondition -{ +public class WiredConditionFreezeGameActive extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP; - public WiredConditionFreezeGameActive(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionFreezeGameActive(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -51,34 +46,29 @@ public class WiredConditionFreezeGameActive extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Game game = room.getGame(FreezeGame.class); return game != null && game.state.equals(GameState.RUNNING); } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 1d3099a9..ba2b2bf7 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 @@ -15,33 +15,28 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionFurniHaveFurni extends InteractionWiredCondition -{ +public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI; private boolean all; private THashSet items; - public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredConditionFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); boolean foundSomething = false; - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { boolean found = false; THashSet stackedItems = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY())); @@ -49,29 +44,24 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition if (stackedItems == null) continue; - if(stackedItems.isEmpty() && this.all) + if (stackedItems.isEmpty() && this.all) return false; - for(HabboItem i : stackedItems) - { - if(i == item) + for (HabboItem i : stackedItems) { + if (i == item) continue; - if(i.getZ() >= item.getZ()) - { + if (i.getZ() >= item.getZ()) { found = true; foundSomething = true; } } - if(this.all) - { - if(!found) + if (this.all) { + if (!found) return false; - } - else - { - if(found) + } else { + if (found) return true; } } @@ -81,36 +71,31 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - for(HabboItem item : this.items) + for (HabboItem item : this.items) data.append(item.getId()).append(";"); return data.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); - if(data.length >= 1) - { + if (data.length >= 1) { this.all = (data[0].equals("1")); - if(data.length == 2) - { + if (data.length == 2) { String[] items = data[1].split(";"); - for (String s : items) - { + for (String s : items) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if(item != null) + if (item != null) this.items.add(item); } } @@ -118,35 +103,32 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.all = false; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); message.appendInt(1); - message.appendInt(this.all ? 1 : 0); + message.appendInt(this.all ? 1 : 0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -154,8 +136,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); int count; @@ -169,13 +150,11 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if(item != null) + if (item != null) this.items.add(item); } @@ -184,26 +163,20 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition return false; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } 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 ad4051be..304eded6 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 @@ -22,43 +22,37 @@ import java.sql.SQLException; import java.util.Collection; import java.util.Map; -public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition -{ +public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; protected boolean all; protected THashSet items; - public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredConditionFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.all = false; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); - if(this.items.isEmpty()) + if (this.items.isEmpty()) return true; THashMap> tiles = new THashMap<>(); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } @@ -66,34 +60,25 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition Collection bots = room.getCurrentBots().valueCollection(); Collection pets = room.getCurrentPets().valueCollection(); - for (Map.Entry> set : tiles.entrySet()) - { + for (Map.Entry> set : tiles.entrySet()) { boolean found = false; - for (Habbo habbo : habbos) - { - if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) - { + for (Habbo habbo : habbos) { + if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) { found = true; } } - if (!found) - { - for (Bot bot : bots) - { - if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) - { + if (!found) { + for (Bot bot : bots) { + if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) { found = true; } } } - if (!found) - { - for (Pet pet : pets) - { - if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) - { + if (!found) { + for (Pet pet : pets) { + if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) { found = true; } } @@ -106,14 +91,12 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { data.append(item.getId()).append(";"); } @@ -121,25 +104,21 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(":"); - if(data.length >= 1) - { + if (data.length >= 1) { this.all = (data[0].equals("1")); - if(data.length == 2) - { + if (data.length == 2) { String[] items = data[1].split(";"); - for (String s : items) - { + for (String s : items) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if(item != null) + if (item != null) this.items.add(item); } } @@ -147,21 +126,19 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -176,8 +153,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); int count; @@ -189,13 +165,11 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if(item != null) + if (item != null) this.items.add(item); } @@ -205,26 +179,20 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition return false; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } 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 a7cbf504..06e3cbaa 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 @@ -15,44 +15,35 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionFurniTypeMatch extends InteractionWiredCondition -{ +public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.STUFF_IS; private THashSet items = new THashSet<>(); - public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); - if(stuff != null) - { - if(stuff.length >= 1) - { - if(stuff[0] instanceof HabboItem) - { + if (stuff != null) { + if (stuff.length >= 1) { + if (stuff[0] instanceof HabboItem) { HabboItem item = (HabboItem) stuff[0]; - for(HabboItem i : this.items) - { - if(i.getBaseItem().getId() == item.getBaseItem().getId()) + for (HabboItem i : this.items) { + if (i.getBaseItem().getId() == item.getBaseItem().getId()) return true; } @@ -64,45 +55,41 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder(); - for(HabboItem item : this.items) + for (HabboItem item : this.items) data.append(item.getId()).append(";"); return data.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(";"); - for(String s : data) + for (String s : data) this.items.add(room.getHabboItem(Integer.valueOf(s))); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -116,8 +103,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); packet.readInt(); @@ -127,10 +113,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { this.items.add(room.getHabboItem(packet.readInt())); } } @@ -138,26 +122,20 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition return true; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } 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 f276f7f6..cc01ba75 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 @@ -12,24 +12,20 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionGroupMember extends InteractionWiredCondition -{ +public class WiredConditionGroupMember extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP; - public WiredConditionGroupMember(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionGroupMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionGroupMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionGroupMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(room.getGuildId() == 0) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (room.getGuildId() == 0) return false; Habbo habbo = room.getHabbo(roomUnit); @@ -38,32 +34,27 @@ public class WiredConditionGroupMember extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -78,8 +69,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } } 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 16a3dd12..b131e517 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 @@ -11,40 +11,34 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboCount extends InteractionWiredCondition -{ +public class WiredConditionHabboCount extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.USER_COUNT; private int lowerLimit = 0; private int upperLimit = 50; - public WiredConditionHabboCount(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionHabboCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int count = room.getUserCount(); return count >= this.lowerLimit && count <= this.upperLimit; } @Override - public String getWiredData() - { + public String getWiredData() { return this.lowerLimit + ":" + this.upperLimit; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); this.lowerLimit = Integer.valueOf(data[0]); @@ -52,21 +46,18 @@ public class WiredConditionHabboCount extends InteractionWiredCondition } @Override - public void onPickUp() - { + public void onPickUp() { this.lowerLimit = 0; this.upperLimit = 50; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -74,8 +65,8 @@ public class WiredConditionHabboCount extends InteractionWiredCondition message.appendInt(this.getId()); message.appendString(""); message.appendInt(2); - message.appendInt(this.lowerLimit); - message.appendInt(this.upperLimit); + message.appendInt(this.lowerLimit); + message.appendInt(this.upperLimit); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -83,8 +74,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.lowerLimit = packet.readInt(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java index 6c6e3eea..78e52e31 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasCredits extends WiredConditionHabboHasEffect -{ - public WiredConditionHabboHasCredits(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboHasCredits extends WiredConditionHabboHasEffect { + public WiredConditionHabboHasCredits(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getCredits() >= this.effectId; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java index 7edd5e96..41103b76 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasDiamonds extends WiredConditionHabboHasEffect -{ - public WiredConditionHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboHasDiamonds extends WiredConditionHabboHasEffect { + public WiredConditionHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getCurrencyAmount(5) >= this.effectId; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java index 3148e7b6..f6f7b66f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasDuckets extends WiredConditionHabboHasEffect -{ - public WiredConditionHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboHasDuckets extends WiredConditionHabboHasEffect { + public WiredConditionHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getPixels() >= this.effectId; } 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 9458f8f4..fdde8793 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 @@ -11,56 +11,47 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasEffect extends InteractionWiredCondition -{ +public class WiredConditionHabboHasEffect extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_EFFECT; protected int effectId = 0; - public WiredConditionHabboHasEffect(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (roomUnit == null) return false; return roomUnit.getEffectId() == this.effectId; } @Override - public String getWiredData() - { + public String getWiredData() { return this.effectId + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.effectId = Integer.valueOf(set.getString("wired_data")); } @Override - public void onPickUp() - { + public void onPickUp() { this.effectId = 0; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(true); message.appendInt(5); message.appendInt(0); @@ -75,8 +66,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.effectId = packet.readInt(); 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 79642c6a..ecaf88c1 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 @@ -12,31 +12,26 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasHandItem extends InteractionWiredCondition -{ +public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM; private int handItem; - public WiredConditionHabboHasHandItem(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionHabboHasHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -52,8 +47,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.handItem = packet.readInt(); @@ -62,34 +56,27 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (roomUnit == null) return false; return roomUnit.getHandItem() == this.handItem; } @Override - public String getWiredData() - { + public String getWiredData() { return this.handItem + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - try - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + try { this.handItem = Integer.valueOf(set.getString("wired_data")); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @Override - public void onPickUp() - { + public void onPickUp() { this.handItem = 0; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java index 0af8f0a2..ecf2bc01 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java @@ -9,31 +9,23 @@ import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge -{ - public WiredConditionHabboHasRank(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge { + public WiredConditionHabboHasRank(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboHasRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - try - { + if (habbo != null) { + try { return habbo.getHabboInfo().getRank().getId() == Integer.valueOf(this.badge); - } - catch (Exception e) - { + } catch (Exception e) { return false; } } @@ -42,8 +34,7 @@ public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java index 2e7a590c..ac048fd9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java @@ -9,27 +9,22 @@ import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboIsDancing extends WiredConditionGroupMember -{ - public WiredConditionHabboIsDancing(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboIsDancing extends WiredConditionGroupMember { + public WiredConditionHabboIsDancing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return roomUnit.getDanceType() != DanceType.NONE; } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java index 718de140..8364e356 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java @@ -9,31 +9,23 @@ import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge -{ - public WiredConditionHabboNotRank(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge { + public WiredConditionHabboNotRank(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboNotRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboNotRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - try - { + if (habbo != null) { + try { return habbo.getHabboInfo().getRank().getId() != Integer.valueOf(this.badge); - } - catch (Exception e) - { + } catch (Exception e) { return false; } } @@ -42,8 +34,7 @@ public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java index 0d53a17f..bd7e192a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboOwnsBadge extends WiredConditionHabboWearsBadge -{ - public WiredConditionHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionHabboOwnsBadge extends WiredConditionHabboWearsBadge { + public WiredConditionHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getInventory().getBadgesComponent().hasBadge(this.badge); } 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 841ecd6b..d2ddf27c 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 @@ -13,35 +13,27 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboWearsBadge extends InteractionWiredCondition -{ +public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_BADGE; protected String badge = ""; - public WiredConditionHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) - { - for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) - { - if (badge.getCode().equalsIgnoreCase(this.badge)) - { + if (habbo != null) { + synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) { + for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) { + if (badge.getCode().equalsIgnoreCase(this.badge)) { return true; } } @@ -51,32 +43,27 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return this.badge; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.badge = set.getString("wired_data"); } @Override - public void onPickUp() - { + public void onPickUp() { this.badge = ""; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -91,8 +78,7 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.badge = packet.readString(); 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 4c905502..95e907ed 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 @@ -12,64 +12,52 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionLessTimeElapsed extends InteractionWiredCondition -{ +public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.TIME_LESS_THAN; private int cycles; - public WiredConditionLessTimeElapsed(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionLessTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionLessTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionLessTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < this.cycles; } @Override - public String getWiredData() - { + public String getWiredData() { return this.cycles + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try - { + try { if (!data.equals("")) this.cycles = Integer.valueOf(data); - } - catch (Exception e) - { + } catch (Exception e) { } } @Override - public void onPickUp() - { + public void onPickUp() { this.cycles = 0; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -85,8 +73,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.cycles = packet.readInt(); 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 37e9b7ef..73371bab 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 @@ -16,8 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMatchStatePosition extends InteractionWiredCondition -{ +public class WiredConditionMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -26,44 +25,40 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition private boolean position; private boolean direction; - public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.settings = new THashSet<>(); } - public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.settings = new THashSet<>(); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.settings.size()); - for(WiredMatchFurniSetting item : this.settings) + for (WiredMatchFurniSetting item : this.settings) message.appendInt(item.itemId); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); message.appendInt(4); - message.appendInt(this.state ? 1 : 0); - message.appendInt(this.direction ? 1 : 0); - message.appendInt(this.position ? 1 : 0); - message.appendInt(10); + message.appendInt(this.state ? 1 : 0); + message.appendInt(this.direction ? 1 : 0); + message.appendInt(this.position ? 1 : 0); + message.appendInt(10); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -71,8 +66,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.settings.clear(); int count; @@ -86,13 +80,12 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return true; count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { int itemId = packet.readInt(); HabboItem item = room.getHabboItem(itemId); @@ -104,47 +97,37 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(this.settings.isEmpty()) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (this.settings.isEmpty()) return true; THashSet s = new THashSet<>(); - for(WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if(item != null) - { - if(this.state) - { - if(!item.getExtradata().equals(setting.state)) + if (item != null) { + if (this.state) { + if (!item.getExtradata().equals(setting.state)) return false; } - if(this.position) - { - if(!(setting.x == item.getX() && setting.y == item.getY())) + if (this.position) { + if (!(setting.x == item.getX() && setting.y == item.getY())) return false; } - if(this.direction) - { - if(setting.rotation != item.getRotation()) + if (this.direction) { + if (setting.rotation != item.getRotation()) return false; } - } - else - { + } else { s.add(setting); } } - if(!s.isEmpty()) - { - for(WiredMatchFurniSetting setting : s) - { + if (!s.isEmpty()) { + for (WiredMatchFurniSetting setting : s) { this.settings.remove(setting); } } @@ -153,16 +136,12 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder data = new StringBuilder(this.settings.size() + ":"); - if(this.settings.isEmpty()) - { + if (this.settings.isEmpty()) { data.append("\t;"); - } - else - { + } else { for (WiredMatchFurniSetting item : this.settings) data.append(item.toString()).append(";"); } @@ -173,19 +152,17 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); int itemCount = Integer.valueOf(data[0]); String[] items = data[1].split(";"); - for(int i = 0; i < itemCount; i++) - { + for (int i = 0; i < itemCount; i++) { String[] stuff = items[i].split("-"); - if(stuff.length >= 5) + if (stuff.length >= 5) this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]))); } @@ -195,33 +172,27 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public void onPickUp() - { + public void onPickUp() { this.settings.clear(); this.direction = false; this.position = false; this.state = false; } - private void refresh() - { + private void refresh() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { THashSet remove = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if (item == null) - { + if (item == null) { remove.add(setting); } } - for(WiredMatchFurniSetting setting : remove) - { + for (WiredMatchFurniSetting setting : remove) { this.settings.remove(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 72d4907c..a1fa3c5c 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 @@ -12,64 +12,52 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition -{ +public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { private static final WiredConditionType type = WiredConditionType.TIME_MORE_THAN; private int cycles; - public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionMoreTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionMoreTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > this.cycles; } @Override - public String getWiredData() - { + public String getWiredData() { return this.cycles + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try - { + try { if (!data.equals("")) this.cycles = Integer.valueOf(data); - } - catch (Exception e) - { + } catch (Exception e) { } } @Override - public void onPickUp() - { + public void onPickUp() { this.cycles = 0; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -85,8 +73,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.cycles = packet.readInt(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java index 46b2b9eb..26bd7e9e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java @@ -13,57 +13,48 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMottoContains extends InteractionWiredCondition -{ +public class WiredConditionMottoContains extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_BADGE; private String motto = ""; - public WiredConditionMottoContains(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionMottoContains(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionMottoContains(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionMottoContains(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); return habbo != null && habbo.getHabboInfo().getMotto().contains(this.motto); } @Override - public String getWiredData() - { + public String getWiredData() { return this.motto; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.motto = set.getString("wired_data"); } @Override - public void onPickUp() - { + public void onPickUp() { this.motto = ""; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -78,8 +69,7 @@ public class WiredConditionMottoContains extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.motto = packet.readString(); @@ -88,8 +78,7 @@ public class WiredConditionMottoContains extends InteractionWiredCondition } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java index 8b199fd0..06e1c102 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java @@ -14,29 +14,24 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotBattleBanzaiGameActive extends InteractionWiredCondition -{ +public class WiredConditionNotBattleBanzaiGameActive extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP; - public WiredConditionNotBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -51,34 +46,29 @@ public class WiredConditionNotBattleBanzaiGameActive extends InteractionWiredCon } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Game game = room.getGame(BattleBanzaiGame.class); return game == null || !game.state.equals(GameState.RUNNING); } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java index a6bafb34..043a5dbd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java @@ -14,29 +14,24 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotFreezeGameActive extends InteractionWiredCondition -{ +public class WiredConditionNotFreezeGameActive extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP; - public WiredConditionNotFreezeGameActive(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotFreezeGameActive(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -51,34 +46,29 @@ public class WiredConditionNotFreezeGameActive extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Game game = room.getGame(FreezeGame.class); return game == null || !game.state.equals(GameState.RUNNING); } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 6b9d488f..c64fb8b5 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 @@ -16,39 +16,33 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition -{ +public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI; private boolean all; private THashSet items; - public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredConditionNotFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); - if(this.items.isEmpty()) + if (this.items.isEmpty()) return true; - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { THashSet things = room.getItemsAt(item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); things.removeAll(this.items); - if (!things.isEmpty()) - { + if (!things.isEmpty()) { if (this.all) return false; else @@ -61,38 +55,33 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - for(HabboItem item : this.items) + for (HabboItem item : this.items) data.append(item.getId()).append(";"); return data.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(":"); - if(data.length >= 1) - { + if (data.length >= 1) { this.all = (data[0].equals("1")); - if(data.length == 2) - { + if (data.length == 2) { String[] items = data[1].split(";"); - for (String s : items) - { + for (String s : items) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if(item != null) + if (item != null) this.items.add(item); } } @@ -100,28 +89,25 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition } @Override - public void onPickUp() - { + public void onPickUp() { this.all = false; this.items.clear(); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -136,8 +122,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); int count; @@ -151,13 +136,11 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if(item != null) + if (item != null) this.items.add(item); } @@ -166,33 +149,26 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition return false; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR; } } 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 9e239958..ef61c69c 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 @@ -22,43 +22,37 @@ import java.sql.SQLException; import java.util.Collection; import java.util.Map; -public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition -{ +public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; protected boolean all; protected THashSet items; - public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.all = false; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); - if(this.items.isEmpty()) + if (this.items.isEmpty()) return true; THashMap> tiles = new THashMap<>(); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } @@ -66,36 +60,26 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition Collection bots = room.getCurrentBots().valueCollection(); Collection pets = room.getCurrentPets().valueCollection(); - for (Map.Entry> set : tiles.entrySet()) - { - if (!habbos.isEmpty()) - { - for (Habbo habbo : habbos) - { - if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) - { + for (Map.Entry> set : tiles.entrySet()) { + if (!habbos.isEmpty()) { + for (Habbo habbo : habbos) { + if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) { return false; } } } - if (!bots.isEmpty()) - { - for (Bot bot : bots) - { - if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) - { + if (!bots.isEmpty()) { + for (Bot bot : bots) { + if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) { return false; } } } - if (!pets.isEmpty()) - { - for (Pet pet : pets) - { - if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) - { + if (!pets.isEmpty()) { + for (Pet pet : pets) { + if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) { return false; } } @@ -107,14 +91,12 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { data.append(item.getId()).append(";"); } @@ -122,25 +104,21 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(":"); - if(data.length >= 1) - { + if (data.length >= 1) { this.all = (data[0].equals("1")); - if(data.length == 2) - { + if (data.length == 2) { String[] items = data[1].split(";"); - for (String s : items) - { + for (String s : items) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if(item != null) + if (item != null) this.items.add(item); } } @@ -148,21 +126,19 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -177,8 +153,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); int count; @@ -190,13 +165,11 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if(item != null) + if (item != null) this.items.add(item); } @@ -206,26 +179,20 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition return false; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } 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 fa5b4f5d..95b5d8e3 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 @@ -15,38 +15,30 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition -{ +public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS; private THashSet items = new THashSet<>(); - public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); - if(stuff != null) - { - if(stuff.length >= 1) - { - if(stuff[0] instanceof HabboItem) - { + if (stuff != null) { + if (stuff.length >= 1) { + if (stuff[0] instanceof HabboItem) { HabboItem item = (HabboItem) stuff[0]; - for(HabboItem i : this.items) - { - if(i.getBaseItem().getId() == item.getBaseItem().getId()) + for (HabboItem i : this.items) { + if (i.getBaseItem().getId() == item.getBaseItem().getId()) return false; } } @@ -57,51 +49,46 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder(); - for(HabboItem item : this.items) + for (HabboItem item : this.items) data.append(item.getId()).append(";"); return data.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(";"); - for(String s : data) + for (String s : data) this.items.add(room.getHabboItem(Integer.valueOf(s))); } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -115,8 +102,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); packet.readInt(); @@ -126,10 +112,8 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { this.items.add(room.getHabboItem(packet.readInt())); } } @@ -137,26 +121,20 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition return true; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } } 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 7380deba..194d47c1 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 @@ -11,61 +11,52 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboCount extends InteractionWiredCondition -{ +public class WiredConditionNotHabboCount extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_USER_COUNT; private int lowerLimit = 10; private int upperLimit = 20; - public WiredConditionNotHabboCount(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotHabboCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int count = room.getUserCount(); return count < this.lowerLimit || count > this.upperLimit; } @Override - public String getWiredData() - { + public String getWiredData() { return this.lowerLimit + ":" + this.upperLimit; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); this.lowerLimit = Integer.valueOf(data[0]); this.upperLimit = Integer.valueOf(data[1]); } @Override - public void onPickUp() - { + public void onPickUp() { this.upperLimit = 0; this.lowerLimit = 20; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -73,8 +64,8 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition message.appendInt(this.getId()); message.appendString(""); message.appendInt(2); - message.appendInt(this.lowerLimit); - message.appendInt(this.upperLimit); + message.appendInt(this.lowerLimit); + message.appendInt(this.upperLimit); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -82,8 +73,7 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.lowerLimit = packet.readInt(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java index 4e3a45a5..6c322788 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasCredits extends WiredConditionNotHabboHasEffect -{ - public WiredConditionNotHabboHasCredits(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionNotHabboHasCredits extends WiredConditionNotHabboHasEffect { + public WiredConditionNotHabboHasCredits(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getCredits() < this.effectId; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java index baa7cc14..ea96650f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasDiamonds extends WiredConditionNotHabboHasEffect -{ - public WiredConditionNotHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionNotHabboHasDiamonds extends WiredConditionNotHabboHasEffect { + public WiredConditionNotHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getCurrencyAmount(5) < this.effectId; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java index 9ed31cdd..98e55738 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasDuckets extends WiredConditionNotHabboHasEffect -{ - public WiredConditionNotHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionNotHabboHasDuckets extends WiredConditionNotHabboHasEffect { + public WiredConditionNotHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return habbo.getHabboInfo().getPixels() < this.effectId; } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java index 3c8e1a65..0994a2a3 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 @@ -11,56 +11,47 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition -{ +public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { private static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_EFFECT; protected int effectId; - public WiredConditionNotHabboHasEffect(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (roomUnit == null) return false; return roomUnit.getEffectId() != this.effectId; } @Override - public String getWiredData() - { + public String getWiredData() { return this.effectId + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.effectId = Integer.valueOf(set.getString("wired_data")); } @Override - public void onPickUp() - { + public void onPickUp() { this.effectId = 0; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -75,8 +66,7 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.effectId = packet.readInt(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java index fde87f6b..3a921e6a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java @@ -9,27 +9,22 @@ import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboIsDancing extends WiredConditionGroupMember -{ - public WiredConditionNotHabboIsDancing(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionNotHabboIsDancing extends WiredConditionGroupMember { + public WiredConditionNotHabboIsDancing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return roomUnit.getDanceType() == DanceType.NONE; } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java index f7b11e6b..91cb8d81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboOwnsBadge extends WiredConditionNotHabboWearsBadge -{ - public WiredConditionNotHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException - { +public class WiredConditionNotHabboOwnsBadge extends WiredConditionNotHabboWearsBadge { + public WiredConditionNotHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { return !habbo.getInventory().getBadgesComponent().hasBadge(this.badge); } 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 6abc770a..3a30238f 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 @@ -13,33 +13,26 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition -{ +public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_BADGE; protected String badge = ""; - public WiredConditionNotHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) - { - for (HabboBadge b : habbo.getInventory().getBadgesComponent().getWearingBadges()) - { + if (habbo != null) { + synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) { + for (HabboBadge b : habbo.getInventory().getBadgesComponent().getWearingBadges()) { if (b.getCode().equalsIgnoreCase(this.badge)) return false; } @@ -51,32 +44,27 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return this.badge; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.badge = set.getString("wired_data"); } @Override - public void onPickUp() - { + public void onPickUp() { this.badge = ""; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -91,8 +79,7 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.badge = packet.readString(); 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 678f22c6..520f28bf 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 @@ -12,24 +12,20 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotInGroup extends InteractionWiredCondition -{ +public class WiredConditionNotInGroup extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP; - public WiredConditionNotInGroup(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotInGroup(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotInGroup(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotInGroup(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(room.getGuildId() == 0) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (room.getGuildId() == 0) return false; Habbo habbo = room.getHabbo(roomUnit); @@ -38,32 +34,27 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -78,8 +69,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } } 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 b303bfa0..73994362 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 @@ -13,31 +13,25 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotInTeam extends InteractionWiredCondition -{ +public class WiredConditionNotInTeam extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_TEAM; private GameTeamColors teamColor = GameTeamColors.RED; - public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotInTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotInTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if(habbo.getHabboInfo().getGamePlayer() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGamePlayer() != null) { return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); } } @@ -46,42 +40,34 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return this.teamColor.type + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try - { + try { if (!data.equals("")) this.teamColor = GameTeamColors.values()[Integer.valueOf(data)]; - } - catch (Exception e) - { + } catch (Exception e) { this.teamColor = GameTeamColors.RED; } } @Override - public void onPickUp() - { + public void onPickUp() { this.teamColor = GameTeamColors.RED; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -97,8 +83,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; 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 2e977871..2f0dc9d4 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 @@ -16,8 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition -{ +public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -26,49 +25,40 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi private boolean position; private boolean rotation; - public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.settings = new THashSet<>(); } - public WiredConditionNotMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.settings = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(this.settings.isEmpty()) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (this.settings.isEmpty()) return true; THashSet s = new THashSet<>(); - for(WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if(item != null) - { + if (item != null) { boolean stateMatches = !this.state || item.getExtradata().equals(setting.state); boolean positionMatches = !this.position || (setting.x == item.getX() && setting.y == item.getY()); boolean directionMatches = !this.rotation || setting.rotation == item.getRotation(); - if(stateMatches && positionMatches && directionMatches) + if (stateMatches && positionMatches && directionMatches) return false; - } - else - { + } else { s.add(setting); } } - if(!s.isEmpty()) - { - for(WiredMatchFurniSetting setting : s) - { + if (!s.isEmpty()) { + for (WiredMatchFurniSetting setting : s) { this.settings.remove(setting); } } @@ -77,16 +67,12 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder data = new StringBuilder(this.settings.size() + ":"); - if(this.settings.isEmpty()) - { + if (this.settings.isEmpty()) { data.append("\t;"); - } - else - { + } else { for (WiredMatchFurniSetting item : this.settings) data.append(item.toString()).append(";"); } @@ -97,19 +83,17 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); int itemCount = Integer.valueOf(data[0]); String[] items = data[1].split(";"); - for(int i = 0; i < itemCount; i++) - { + for (int i = 0; i < itemCount; i++) { String[] stuff = items[i].split("-"); - if(stuff.length >= 5) + if (stuff.length >= 5) this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]))); } @@ -119,8 +103,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } @Override - public void onPickUp() - { + public void onPickUp() { this.settings.clear(); this.state = false; this.rotation = false; @@ -128,21 +111,19 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.settings.size()); - for(WiredMatchFurniSetting item : this.settings) + for (WiredMatchFurniSetting item : this.settings) message.appendInt(item.itemId); message.appendInt(this.getBaseItem().getSpriteId()); @@ -160,8 +141,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.settings.clear(); int count; @@ -175,13 +155,12 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return true; count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { int itemId = packet.readInt(); HabboItem item = room.getHabboItem(itemId); @@ -192,25 +171,20 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi return true; } - private void refresh() - { + private void refresh() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { + if (room != null) { THashSet remove = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if (item == null) - { + if (item == null) { remove.add(setting); } } - for(WiredMatchFurniSetting setting : remove) - { + for (WiredMatchFurniSetting setting : remove) { this.settings.remove(setting); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java index 6942e0b6..eb853f9c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java @@ -16,34 +16,29 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition -{ +public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI; private THashSet items = new THashSet<>(); - public WiredConditionNotTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionNotTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionNotTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (roomUnit == null) return false; this.refresh(); - if(this.items.isEmpty()) + if (this.items.isEmpty()) return true; - for(HabboItem item : this.items) - { - if(RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY())) + for (HabboItem item : this.items) { + if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY())) return false; } @@ -51,58 +46,51 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder(); - for(HabboItem item : this.items) + for (HabboItem item : this.items) data.append(item.getId()).append(";"); return data.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(";"); - for(String s : data) - { + for (String s : data) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if (item != null) - { + if (item != null) { this.items.add(item); } } } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -116,8 +104,7 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); packet.readInt(); @@ -127,14 +114,11 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if (item != null) - { + if (item != null) { this.items.add(item); } } @@ -143,19 +127,14 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition return true; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (item.getRoomId() != room.getId()) items.add(item); } 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 ffed6d12..21abe9f3 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 @@ -13,31 +13,25 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionTeamMember extends InteractionWiredCondition -{ +public class WiredConditionTeamMember extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.ACTOR_IN_TEAM; private GameTeamColors teamColor = GameTeamColors.RED; - public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionTeamMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionTeamMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if(habbo.getHabboInfo().getGamePlayer() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getGamePlayer() != null) { return habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); } } @@ -46,42 +40,34 @@ public class WiredConditionTeamMember extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { return this.teamColor.type + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try - { + try { if (!data.equals("")) this.teamColor = GameTeamColors.values()[Integer.valueOf(data)]; - } - catch (Exception e) - { + } catch (Exception e) { this.teamColor = GameTeamColors.RED; } } @Override - public void onPickUp() - { + public void onPickUp() { this.teamColor = GameTeamColors.RED; } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -97,8 +83,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; 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 7ef15bfd..5cb27d1c 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 @@ -17,35 +17,30 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionTriggerOnFurni extends InteractionWiredCondition -{ +public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI; private THashSet items = new THashSet<>(); - public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredConditionTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (roomUnit == null) return false; this.refresh(); - if(this.items.isEmpty()) + if (this.items.isEmpty()) return true; - for(HabboItem item : this.items) - { - if(RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY())) + for (HabboItem item : this.items) { + if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY())) return true; } @@ -53,14 +48,12 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder(); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { data.append(item.getId()).append(";"); } @@ -68,45 +61,39 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(";"); - for(String s : data) - { + for (String s : data) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if (item != null) - { + if (item != null) { this.items.add(item); } } } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); } @Override - public WiredConditionType getType() - { + public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -120,8 +107,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { this.items.clear(); packet.readInt(); @@ -131,14 +117,11 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null) - { - for (int i = 0; i < count; i++) - { + if (room != null) { + for (int i = 0; i < count; i++) { HabboItem item = room.getHabboItem(packet.readInt()); - if (item != null) - { + if (item != null) { this.items.add(item); } } @@ -147,19 +130,14 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition return true; } - private void refresh() - { + private void refresh() { THashSet items = new THashSet<>(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (item.getRoomId() != room.getId()) items.add(item); } @@ -169,8 +147,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition } @Override - public WiredConditionOperator operator() - { + public WiredConditionOperator operator() { return WiredConditionOperator.OR; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java index ebfb7293..14e83480 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java @@ -5,30 +5,24 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectAlert extends WiredEffectWhisper -{ - public WiredEffectAlert(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectAlert extends WiredEffectWhisper { + public WiredEffectAlert(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectAlert(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectAlert(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { habbo.alert(this.message .replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "") .replace("%username%", habbo.getHabboInfo().getUsername()) 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 8ec0b062..c49ff4a5 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 @@ -14,26 +14,22 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class WiredEffectBotClothes extends InteractionWiredEffect -{ +public class WiredEffectBotClothes extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_CLOTHES; private String botName = ""; private String botLook = ""; - public WiredEffectBotClothes(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotClothes(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotClothes(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotClothes(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -48,14 +44,12 @@ public class WiredEffectBotClothes extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - String[] data = packet.readString().split(((char) 9 ) + ""); + String[] data = packet.readString().split(((char) 9) + ""); - if(data.length == 2) - { + if (data.length == 2) { this.botName = data[0]; this.botLook = data[1]; } @@ -67,17 +61,14 @@ public class WiredEffectBotClothes extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { List bots = room.getBots(this.botName); - for(Bot bot : bots) - { + for (Bot bot : bots) { bot.setFigure(this.botLook); } @@ -85,20 +76,17 @@ public class WiredEffectBotClothes extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "" + ((char) 9) + "" + - this.botName + ((char) 9) + + this.botName + ((char) 9) + this.botLook; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(((char) 9) + ""); - if(data.length >= 3) - { + if (data.length >= 3) { this.setDelay(Integer.valueOf(data[0])); this.botName = data[1]; this.botLook = data[2]; @@ -106,30 +94,25 @@ public class WiredEffectBotClothes extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.botLook = ""; this.botName = ""; this.setDelay(0); } - public String getBotName() - { + public String getBotName() { return this.botName; } - public void setBotName(String botName) - { + public void setBotName(String botName) { this.botName = botName; } - public String getBotLook() - { + public String getBotLook() { return this.botLook; } - public void setBotLook(String botLook) - { + public void setBotLook(String botLook) { this.botLook = botLook; } } 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 3180d1a8..e7aab43c 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 @@ -18,26 +18,22 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectBotFollowHabbo extends InteractionWiredEffect -{ +public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_FOLLOW_AVATAR; private String botName = ""; private int mode = 0; - public WiredEffectBotFollowHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotFollowHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotFollowHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotFollowHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -50,36 +46,28 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.mode = packet.readInt(); @@ -90,22 +78,18 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { List bots = room.getBots(this.botName); - for(Bot bot : bots) - { - if(this.mode == 1) + for (Bot bot : bots) { + if (this.mode == 1) bot.startFollowingHabbo(habbo); else bot.stopFollowingHabbo(); @@ -118,18 +102,15 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect } @Override - public String getWiredData() - { - return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + this.botName; + public String getWiredData() { + return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + this.botName; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(((char) 9) + ""); - if(data.length == 3) - { + if (data.length == 3) { this.setDelay(Integer.valueOf(data[0])); this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0); this.botName = data[2]; @@ -137,16 +118,14 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.botName = ""; this.mode = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index 9b9253f8..d32e932a 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 @@ -21,26 +21,22 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectBotGiveHandItem extends InteractionWiredEffect -{ +public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_GIVE_HANDITEM; private String botName = ""; private int itemId; - public WiredEffectBotGiveHandItem(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotGiveHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -53,36 +49,28 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.itemId = packet.readInt(); @@ -93,27 +81,23 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { List bots = room.getBots(this.botName); - for(Bot bot : bots) - { + for (Bot bot : bots) { List tasks = new ArrayList<>(); tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId)); tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0)); Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId)); - Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null)); + Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null)); } return true; @@ -123,18 +107,15 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect } @Override - public String getWiredData() - { - return this.getDelay() + "" + ((char)9) + "" + this.itemId + "" + ((char) 9) + "" + this.botName; + public String getWiredData() { + return this.getDelay() + "" + ((char) 9) + "" + this.itemId + "" + ((char) 9) + "" + this.botName; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(((char) 9) + ""); - if(data.length == 3) - { + if (data.length == 3) { this.setDelay(Integer.valueOf(data[0])); this.itemId = Integer.valueOf(data[1]); this.botName = data[2]; @@ -142,16 +123,14 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.botName = ""; this.itemId = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java index b1b91c61..96815685 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 @@ -16,27 +16,23 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class WiredEffectBotTalk extends InteractionWiredEffect -{ +public class WiredEffectBotTalk extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_TALK; private int mode; private String botName = ""; private String message = ""; - public WiredEffectBotTalk(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotTalk(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotTalk(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotTalk(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -52,16 +48,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.mode = packet.readInt(); String[] data = packet.readString().split(((char) 9) + ""); - if(data.length == 2) - { + if (data.length == 2) { this.botName = data[0]; this.message = data[1]; } @@ -73,20 +67,17 @@ public class WiredEffectBotTalk extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { String message = this.message; Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { message = message.replace(Emulator.getTexts().getValue("wired.variable.username"), habbo.getHabboInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.credits"), habbo.getHabboInfo().getCredits() + "") .replace(Emulator.getTexts().getValue("wired.variable.pixels"), habbo.getHabboInfo().getPixels() + "") @@ -94,9 +85,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect } List bots = room.getBots(this.botName); - for(Bot bot : bots) - { - if(this.mode == 1) + for (Bot bot : bots) { + if (this.mode == 1) bot.shout(message); else bot.talk(message); @@ -105,19 +95,16 @@ public class WiredEffectBotTalk extends InteractionWiredEffect } @Override - public String getWiredData() - { - return this.getDelay() + "" + ((char)9) + "" + this.mode + "" + ((char)9) + "" + this.botName + "" + ((char)9) + "" + this.message; + public String getWiredData() { + return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String d = set.getString("wired_data"); - String[] data = d.split(((char)9) + ""); + String[] data = d.split(((char) 9) + ""); - if(data.length == 4) - { + if (data.length == 4) { this.setDelay(Integer.valueOf(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; @@ -126,47 +113,39 @@ public class WiredEffectBotTalk extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.mode = 0; this.botName = ""; this.message = ""; this.setDelay(0); } - public int getMode() - { + public int getMode() { return this.mode; } - public void setMode(int mode) - { + public void setMode(int mode) { this.mode = mode; } - public String getBotName() - { + public String getBotName() { return this.botName; } - public void setBotName(String botName) - { + public void setBotName(String botName) { this.botName = botName; } - public String getMessage() - { + public String getMessage() { return this.message; } - public void setMessage(String message) - { + public void setMessage(String message) { this.message = message; } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 500; } } 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 a620ee42..82f8ad59 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 @@ -19,27 +19,23 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect -{ +public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_TALK_TO_AVATAR; private int mode; private String botName = ""; private String message = ""; - public WiredEffectBotTalkToHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotTalkToHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotTalkToHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotTalkToHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -52,43 +48,34 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.mode = packet.readInt(); String[] data = packet.readString().split("" + ((char) 9)); - if(data.length == 2) - { + if (data.length == 2) { this.botName = data[0]; this.message = data[1]; } @@ -100,18 +87,15 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { String m = this.message; m = m.replace(Emulator.getTexts().getValue("wired.variable.username"), habbo.getHabboInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.credits"), habbo.getHabboInfo().getCredits() + "") @@ -120,14 +104,10 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect List bots = room.getBots(this.botName); - for(Bot bot : bots) - { - if(this.mode == 1) - { + for (Bot bot : bots) { + if (this.mode == 1) { bot.whisper(m, habbo); - } - else - { + } else { bot.talk(habbo.getHabboInfo().getUsername() + ": " + m); } } @@ -138,18 +118,15 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect } @Override - public String getWiredData() - { - return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9 ) + "" + this.message; + public String getWiredData() { + return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(((char) 9) + ""); - if(data.length == 4) - { + if (data.length == 4) { this.setDelay(Integer.valueOf(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; @@ -158,8 +135,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.botName = ""; this.message = ""; this.mode = 0; @@ -167,8 +143,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 711d2bbf..68a9feb6 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 @@ -19,45 +19,39 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class WiredEffectBotTeleport extends InteractionWiredEffect -{ +public class WiredEffectBotTeleport extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_TELEPORT; private THashSet items; private String botName = ""; - public WiredEffectBotTeleport(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredEffectBotTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -71,8 +65,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.botName = packet.readString(); @@ -80,8 +73,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -91,39 +83,32 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(this.items.isEmpty()) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (this.items.isEmpty()) return false; List bots = room.getBots(this.botName); - if(bots.isEmpty()) + if (bots.isEmpty()) return false; - for(Bot bot : bots) - { + for (Bot bot : bots) { int i = Emulator.getRandom().nextInt(this.items.size()) + 1; int j = 1; - for (HabboItem item : this.items) - { - if(item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) - { - if (i == j) - { + for (HabboItem item : this.items) { + if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) { + if (i == j) { int currentEffect = bot.getRoomUnit().getEffectId(); room.giveEffect(bot.getRoomUnit(), 4, -1); - Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? - 0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY); + Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY); break; - } else - { + } else { j++; } } @@ -134,16 +119,12 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t" + this.botName + ";"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { - if(item.getRoomId() != 0) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { + if (item.getRoomId() != 0) { wiredData.append(item.getId()).append(";"); } } @@ -153,22 +134,18 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 2) - { + if (wiredData.length >= 2) { this.setDelay(Integer.valueOf(wiredData[0])); String[] data = wiredData[1].split(";"); - if (data.length > 1) - { + if (data.length > 1) { this.botName = data[0]; - for (int i = 1; i < data.length; i++) - { + for (int i = 1; i < data.length; i++) { HabboItem item = room.getHabboItem(Integer.valueOf(data[i])); if (item != null) @@ -179,8 +156,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.botName = ""; this.items.clear(); this.setDelay(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 ede7c898..a5f5a0c0 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 @@ -18,45 +18,39 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class WiredEffectBotWalkToFurni extends InteractionWiredEffect -{ +public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.BOT_MOVE; private THashSet items; private String botName = ""; - public WiredEffectBotWalkToFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectBotWalkToFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -70,8 +64,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.botName = packet.readString(); @@ -79,8 +72,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -90,36 +82,32 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(this.items.isEmpty()) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (this.items.isEmpty()) return false; List bots = room.getBots(this.botName); - if(bots.isEmpty()) + if (bots.isEmpty()) return false; THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } - if(this.items.size() > 0) { + if (this.items.size() > 0) { for (Bot bot : bots) { int i = Emulator.getRandom().nextInt(this.items.size()) + 1; int j = 1; @@ -140,16 +128,12 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t" + this.botName + ";"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { - if(item.getRoomId() != 0) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { + if (item.getRoomId() != 0) { wiredData.append(item.getId()).append(";"); } } @@ -159,22 +143,18 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length > 1) - { + if (wiredData.length > 1) { this.setDelay(Integer.valueOf(wiredData[0])); String[] data = wiredData[1].split(";"); - if (data.length >= 1) - { + if (data.length >= 1) { this.botName = data[0]; - for (int i = 1; i < data.length; i++) - { + for (int i = 1; i < data.length; i++) { HabboItem item = room.getHabboItem(Integer.valueOf(data[i])); if (item != null) @@ -185,8 +165,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.botName = ""; this.setDelay(0); 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 1139ece3..dbd0907d 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 @@ -20,79 +20,67 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -public class WiredEffectChangeFurniDirection extends InteractionWiredEffect -{ +public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { public static final int ACTION_WAIT = 0; - public static final int ACTION_TURN_RIGHT_45 = 1; - public static final int ACTION_TURN_RIGHT_90 = 2; - public static final int ACTION_TURN_LEFT_45 = 3; - public static final int ACTION_TURN_LEFT_90 = 4; - public static final int ACTION_TURN_BACK = 5; - public static final int ACTION_TURN_RANDOM = 6; + public static final int ACTION_TURN_RIGHT_45 = 1; + public static final int ACTION_TURN_RIGHT_90 = 2; + public static final int ACTION_TURN_LEFT_45 = 3; + public static final int ACTION_TURN_LEFT_90 = 4; + public static final int ACTION_TURN_BACK = 5; + public static final int ACTION_TURN_RANDOM = 6; public static final WiredEffectType type = WiredEffectType.MOVE_DIRECTION; private final THashMap items = new THashMap<>(0); private RoomUserRotation startRotation = RoomUserRotation.NORTH; private int rotateAction = 0; - public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException - { + + public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectChangeFurniDirection(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectChangeFurniDirection(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet items = new THashSet<>(); - for (HabboItem item : this.items.keySet()) - { + for (HabboItem item : this.items.keySet()) { if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for (HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } if (this.items.isEmpty()) return false; - for (Map.Entry entry : this.items.entrySet()) - { + for (Map.Entry entry : this.items.entrySet()) { RoomUserRotation currentRotation = entry.getValue(); RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue()); int count = 1; - while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) - { + while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) { entry.setValue(this.nextRotation(entry.getValue())); targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue()); count++; } - if (targetTile != null && targetTile.state == RoomTileState.OPEN) - { + if (targetTile != null && targetTile.state == RoomTileState.OPEN) { boolean hasHabbos = false; - for (Habbo habbo : room.getHabbosAt(targetTile)) - { + for (Habbo habbo : room.getHabbosAt(targetTile)) { hasHabbos = true; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{entry.getKey()}); } }); } - if (!hasHabbos) - { + if (!hasHabbos) { THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getKey().getBaseItem().getWidth(), entry.getKey().getBaseItem().getLength(), entry.getKey().getRotation()); room.sendComposer(new FloorItemOnRollerComposer(entry.getKey(), null, targetTile, targetTile.getStackHeight() - entry.getKey().getZ(), room).compose()); room.getLayout().getTilesAt(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getKey().getBaseItem().getWidth(), entry.getKey().getBaseItem().getLength(), entry.getKey().getRotation()); @@ -105,12 +93,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder data = new StringBuilder(this.startRotation.getValue() + "\t" + this.rotateAction + "\t" + this.items.size()); - for (Map.Entry entry : this.items.entrySet()) - { + for (Map.Entry entry : this.items.entrySet()) { data.append("\t").append(entry.getKey().getId()).append(":").append(entry.getValue().getValue()); } @@ -118,29 +104,23 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if (data.length >= 3) - { + if (data.length >= 3) { this.startRotation = RoomUserRotation.fromValue(Integer.valueOf(data[0])); this.rotateAction = Integer.valueOf(data[1]); int itemCount = Integer.valueOf(data[2]); - if (itemCount > 0) - { - for (int i = 3; i < data.length; i++) - { + if (itemCount > 0) { + for (int i = 3; i < data.length; i++) { String[] subData = data[i].split(":"); - if (subData.length == 2) - { + if (subData.length == 2) { HabboItem item = room.getHabboItem(Integer.valueOf(subData[0])); - if (item != null) - { + if (item != null) { this.items.put(item, RoomUserRotation.fromValue(Integer.valueOf(subData[1]))); } } @@ -150,8 +130,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.setDelay(0); this.items.clear(); this.rotateAction = 0; @@ -159,19 +138,16 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for (Map.Entry item : this.items.entrySet()) - { + for (Map.Entry item : this.items.entrySet()) { message.appendInt(item.getKey().getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -187,8 +163,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { this.items.clear(); packet.readInt(); this.startRotation = RoomUserRotation.fromValue(packet.readInt()); @@ -196,22 +171,18 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect packet.readString(); int furniCount = packet.readInt(); - for (int i = 0; i < furniCount; i++) - { + for (int i = 0; i < furniCount; i++) { HabboItem item = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(packet.readInt()); - if (item != null) - { + if (item != null) { this.items.put(item, this.startRotation); } } return true; } - private RoomUserRotation nextRotation(RoomUserRotation currentRotation) - { - switch (this.rotateAction) - { + private RoomUserRotation nextRotation(RoomUserRotation currentRotation) { + switch (this.rotateAction) { case ACTION_TURN_BACK: return RoomUserRotation.fromValue(currentRotation.getValue() + 4); @@ -234,8 +205,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 495; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java index 16872319..a1c216e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java @@ -9,21 +9,17 @@ import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectForwardToRoom extends WiredEffectWhisper -{ - public WiredEffectForwardToRoom(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectForwardToRoom extends WiredEffectWhisper { + public WiredEffectForwardToRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectForwardToRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectForwardToRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); if (habbo == null) @@ -31,16 +27,13 @@ public class WiredEffectForwardToRoom extends WiredEffectWhisper int roomId; - try - { + try { roomId = Integer.valueOf(this.message); - } - catch (Exception e) - { + } catch (Exception e) { return false; } - if(roomId > 0) + if (roomId > 0) habbo.getClient().sendResponse(new ForwardToRoomComposer(roomId)); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java index aa7204cd..1a45f426 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java @@ -20,26 +20,22 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveAchievement extends WiredEffectGiveBadge -{ +public class WiredEffectGiveAchievement extends WiredEffectGiveBadge { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; public static final String DEFAULT_CONTENT = "ach_achievement:points <- Points are optional"; private String achievement = DEFAULT_CONTENT; - public WiredEffectGiveAchievement(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveAchievement(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveAchievement(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveAchievement(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(true); message.appendInt(0); message.appendInt(0); @@ -51,64 +47,50 @@ public class WiredEffectGiveAchievement extends WiredEffectGiveBadge message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.achievement = packet.readString(); int points = 1; String a = achievement; - if (a.contains(":")) - { + if (a.contains(":")) { a = achievement.split(":")[0]; - try - { + try { points = Integer.valueOf(achievement.split(":")[1]); - } catch (Exception e) - { + } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.points"), RoomChatMessageBubbles.WIRED); } } Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a); - if (ach == null) - { + if (ach == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.achievement").replace("%achievement%", a), RoomChatMessageBubbles.WIRED); } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); return false; } @@ -120,38 +102,30 @@ public class WiredEffectGiveAchievement extends WiredEffectGiveBadge } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if (!this.achievement.equals(DEFAULT_CONTENT)) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (!this.achievement.equals(DEFAULT_CONTENT)) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { int points = 1; String a = achievement; - if (a.contains(":")) - { + if (a.contains(":")) { a = achievement.split(":")[0]; - try - { + try { points = Integer.valueOf(achievement.split(":")[1]); - } catch (Exception e) - { + } catch (Exception e) { return false; } } Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a); - if (ach != null) - { + if (ach != null) { AchievementManager.progressAchievement(habbo, ach, points); } } @@ -160,20 +134,17 @@ public class WiredEffectGiveAchievement extends WiredEffectGiveBadge } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.achievement; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.achievement = DEFAULT_CONTENT; - if (data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); this.achievement = data[1]; @@ -181,15 +152,13 @@ public class WiredEffectGiveAchievement extends WiredEffectGiveBadge } @Override - public void onPickUp() - { + public void onPickUp() { this.achievement = DEFAULT_CONTENT; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java index 91644fae..1f071383 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java @@ -19,25 +19,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveBadge extends InteractionWiredEffect -{ +public class WiredEffectGiveBadge extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private String badge = ""; - public WiredEffectGiveBadge(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -49,36 +45,28 @@ public class WiredEffectGiveBadge extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.badge = packet.readString(); @@ -90,28 +78,23 @@ public class WiredEffectGiveBadge extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; if (this.badge.isEmpty()) return false; - if (habbo.getInventory().getBadgesComponent().hasBadge(this.badge)) - { + if (habbo.getInventory().getBadgesComponent().hasBadge(this.badge)) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED)); - } - else - { + } else { BadgesComponent.createBadge(this.badge, habbo); habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_BADGE)); } @@ -120,34 +103,29 @@ public class WiredEffectGiveBadge extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.badge; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); this.badge = data[1]; } } @Override - public void onPickUp() - { + public void onPickUp() { this.badge = ""; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java index 07097003..d072d671 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java @@ -17,25 +17,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveCredits extends InteractionWiredEffect -{ +public class WiredEffectGiveCredits extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int credits = 0; - public WiredEffectGiveCredits(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveCredits(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(true); message.appendInt(0); message.appendInt(0); @@ -47,44 +43,33 @@ public class WiredEffectGiveCredits extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.credits = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } @@ -95,17 +80,15 @@ public class WiredEffectGiveCredits extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; habbo.giveCredits(this.credits); @@ -114,42 +97,34 @@ public class WiredEffectGiveCredits extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.credits; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.credits = 0; - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); - try - { + try { this.credits = Integer.valueOf(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.credits = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java index 403b104a..dc15d8ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java @@ -19,26 +19,22 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveDiamonds extends InteractionWiredEffect -{ +public class WiredEffectGiveDiamonds extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int points = 0; private int pointsType = -1; - public WiredEffectGiveDiamonds(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveDiamonds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -50,44 +46,33 @@ public class WiredEffectGiveDiamonds extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.loadFromString(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } @@ -98,17 +83,15 @@ public class WiredEffectGiveDiamonds extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; habbo.getHabboInfo().addCurrencyAmount(this.pointsType == -1 ? Emulator.getConfig().getInt("seasonal.primary.type") : this.pointsType, this.points); @@ -118,58 +101,47 @@ public class WiredEffectGiveDiamonds extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.points + (this.pointsType == -1 ? "" : ":" + this.pointsType); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.points = 0; - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); - try - { + try { this.loadFromString(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.points = 0; this.setDelay(0); } - private void loadFromString(String data) - { + private void loadFromString(String data) { String[] pointsData = data.split(":"); this.pointsType = -1; - if (pointsData.length >= 1) - { + if (pointsData.length >= 1) { this.points = Integer.valueOf(pointsData[0]); } - if (pointsData.length == 2) - { + if (pointsData.length == 2) { this.pointsType = Integer.valueOf(pointsData[1]); } } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java index 4edb224a..21d82d19 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java @@ -18,25 +18,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveDuckets extends InteractionWiredEffect -{ +public class WiredEffectGiveDuckets extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int pixels = 0; - public WiredEffectGiveDuckets(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveDuckets(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -48,44 +44,33 @@ public class WiredEffectGiveDuckets extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.pixels = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } @@ -96,17 +81,15 @@ public class WiredEffectGiveDuckets extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; habbo.getHabboInfo().addCurrencyAmount(0, this.pixels); @@ -116,42 +99,34 @@ public class WiredEffectGiveDuckets extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.pixels; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.pixels = 0; - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); - try - { + try { this.pixels = Integer.valueOf(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.pixels = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 4f8635fc..5b98543e 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 @@ -7,33 +7,26 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectGiveEffect extends WiredEffectWhisper -{ - public WiredEffectGiveEffect(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectGiveEffect extends WiredEffectWhisper { + public WiredEffectGiveEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int effectId; - try - { + try { effectId = Integer.valueOf(this.message); - } catch (Exception e) - { + } catch (Exception e) { return false; } - if (effectId >= 0) - { + if (effectId >= 0) { room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE); return true; } 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 e5a24ce9..ca39a49f 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 @@ -8,34 +8,26 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectGiveHandItem extends WiredEffectWhisper -{ - public WiredEffectGiveHandItem(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectGiveHandItem extends WiredEffectWhisper { + public WiredEffectGiveHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - try - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + try { int itemId = Integer.valueOf(this.message); Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { room.giveHandItem(habbo, itemId); } - } - catch (Exception e) - { + } catch (Exception e) { } return false; } 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 aa2c8366..1a84a14d 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 @@ -19,25 +19,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEffect -{ +public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int amount = 0; - public WiredEffectGiveHotelviewBonusRarePoints(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveHotelviewBonusRarePoints(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveHotelviewBonusRarePoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveHotelviewBonusRarePoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -49,44 +45,33 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.amount = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } @@ -97,21 +82,18 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; - if(this.amount > 0) - { + if (this.amount > 0) { habbo.getHabboInfo().addCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount); habbo.getClient().sendResponse(new BonusRareComposer(habbo)); } @@ -120,40 +102,33 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.amount; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); this.amount = 0; - if(wireData.split("\t").length >= 2) - { + if (wireData.split("\t").length >= 2) { super.setDelay(Integer.valueOf(wireData.split("\t")[0])); - try - { + try { this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]); + } catch (Exception e) { } - catch (Exception e) - {} } } @Override - public void onPickUp() - { + public void onPickUp() { this.amount = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 13db516a..5bca3009 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 @@ -18,25 +18,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect -{ +public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int amount = 0; - public WiredEffectGiveHotelviewHofPoints(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveHotelviewHofPoints(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveHotelviewHofPoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveHotelviewHofPoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -48,44 +44,33 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.amount = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } packet.readInt(); @@ -95,21 +80,18 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; - if(this.amount > 0) - { + if (this.amount > 0) { habbo.getHabboStats().hofPoints += this.amount; Emulator.getThreading().run(habbo.getHabboStats()); } @@ -118,40 +100,33 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.amount; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); this.amount = 0; - if(wireData.split("\t").length >= 2) - { + if (wireData.split("\t").length >= 2) { super.setDelay(Integer.valueOf(wireData.split("\t")[0])); - try - { + try { this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]); + } catch (Exception e) { } - catch (Exception e) - {} } } @Override - public void onPickUp() - { + public void onPickUp() { this.amount = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 9ad20476..233a97e9 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 @@ -19,25 +19,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveRespect extends InteractionWiredEffect -{ +public class WiredEffectGiveRespect extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int respects = 0; - public WiredEffectGiveRespect(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveRespect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveRespect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveRespect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -49,44 +45,33 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.respects = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } @@ -97,17 +82,15 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) + if (habbo == null) return false; habbo.getHabboStats().respectPointsReceived += this.respects; @@ -117,42 +100,34 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.respects; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.respects = 0; - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); - try - { + try { this.respects = Integer.valueOf(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.respects = 0; this.setDelay(0); } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java index 04509091..a5a8c947 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 @@ -23,8 +23,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveReward extends InteractionWiredEffect -{ +public class WiredEffectGiveReward extends InteractionWiredEffect { public final static int LIMIT_ONCE = 0; public final static int LIMIT_N_DAY = 1; public final static int LIMIT_N_HOURS = 2; @@ -39,37 +38,29 @@ public class WiredEffectGiveReward extends InteractionWiredEffect public THashSet rewardItems = new THashSet<>(); - public WiredEffectGiveReward(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveReward(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveReward(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveReward(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); return habbo != null && WiredHandler.getReward(habbo, this); } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder data = new StringBuilder(this.limit + ":" + this.given + ":" + this.rewardTime + ":" + (this.uniqueRewards ? 1 : 0) + ":" + this.limitationInterval + ":" + this.getDelay() + ":"); - if(this.rewardItems.isEmpty()) - { + if (this.rewardItems.isEmpty()) { data.append("\t"); - } - else - { - for (WiredGiveRewardItem item : this.rewardItems) - { + } else { + for (WiredGiveRewardItem item : this.rewardItems) { data.append(item.toString()).append(";"); } } @@ -78,11 +69,9 @@ public class WiredEffectGiveReward extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); - if(data.length > 0) - { + if (data.length > 0) { this.limit = Integer.valueOf(data[0]); this.given = Integer.valueOf(data[1]); this.rewardTime = Integer.valueOf(data[2]); @@ -90,22 +79,17 @@ public class WiredEffectGiveReward extends InteractionWiredEffect this.limitationInterval = Integer.valueOf(data[4]); this.setDelay(Integer.valueOf(data[5])); - if(data.length > 6) - { - if(!data[6].equalsIgnoreCase("\t")) - { + if (data.length > 6) { + if (!data[6].equalsIgnoreCase("\t")) { String[] items = data[6].split(";"); this.rewardItems.clear(); - for (String s : items) - { - try - { + for (String s : items) { + try { this.rewardItems.add(new WiredGiveRewardItem(s)); + } catch (Exception e) { } - catch (Exception e) - {} } } } @@ -113,8 +97,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.limit = 0; this.limitationInterval = 0; this.given = 0; @@ -125,25 +108,21 @@ public class WiredEffectGiveReward extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client.getHabbo().hasPermission("acc_superwired")) - { + if (client.getHabbo().hasPermission("acc_superwired")) { client.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.superwired.info"), RoomChatMessageBubbles.BOT); } } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(this.rewardItems.size()); message.appendInt(0); @@ -151,52 +130,42 @@ public class WiredEffectGiveReward extends InteractionWiredEffect message.appendInt(this.getId()); StringBuilder s = new StringBuilder(); - for(WiredGiveRewardItem item : this.rewardItems) - { + for (WiredGiveRewardItem item : this.rewardItems) { s.append(item.wiredString()).append(";"); } message.appendString(s.toString()); message.appendInt(4); - message.appendInt(this.rewardTime); - message.appendInt(this.uniqueRewards); - message.appendInt(this.limit); - message.appendInt(this.limitationInterval); + message.appendInt(this.rewardTime); + message.appendInt(this.uniqueRewards); + message.appendInt(this.limit); + message.appendInt(this.limitationInterval); message.appendInt(this.limit > 0); message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { - if (gameClient.getHabbo().hasPermission("acc_superwired")) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { + if (gameClient.getHabbo().hasPermission("acc_superwired")) { packet.readInt(); this.rewardTime = packet.readInt(); @@ -212,14 +181,11 @@ public class WiredEffectGiveReward extends InteractionWiredEffect this.rewardItems.clear(); int i = 1; - for (String s : items) - { + for (String s : items) { String[] d = s.split(","); - if (d.length == 3) - { - if (!(d[1].contains(":") || d[1].contains(";"))) - { + 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]))); continue; } @@ -242,14 +208,12 @@ public class WiredEffectGiveReward extends InteractionWiredEffect } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 0; } } 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 b872fd57..91475710 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 @@ -23,8 +23,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class WiredEffectGiveScore extends InteractionWiredEffect -{ +public class WiredEffectGiveScore extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.GIVE_SCORE; private int score; @@ -32,51 +31,41 @@ public class WiredEffectGiveScore extends InteractionWiredEffect private TObjectIntMap> data = new TObjectIntHashMap<>(); - public WiredEffectGiveScore(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveScore(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectGiveScore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveScore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null && habbo.getHabboInfo().getCurrentGame() != null) - { + if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); - if(game == null) + if (game == null) return false; TObjectIntIterator> iterator = this.data.iterator(); - for(int i = this.data.size(); i-- > 0; ) - { + for (int i = this.data.size(); i-- > 0; ) { iterator.advance(); Map.Entry map = iterator.key(); - if(map.getValue() == habbo.getHabboInfo().getId()) - { - if(map.getKey() == game.getStartTime()) - { - if(iterator.value() < this.count) - { + if (map.getValue() == habbo.getHabboInfo().getId()) { + if (map.getKey() == game.getStartTime()) { + if (iterator.value() < this.count) { iterator.setValue(iterator.value() + 1); habbo.getHabboInfo().getGamePlayer().addScore(this.score); return true; } - } - else - { + } else { iterator.remove(); } } @@ -84,8 +73,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect this.data.put(new AbstractMap.SimpleEntry<>(game.getStartTime(), habbo.getHabboInfo().getId()), 1); - if (habbo.getHabboInfo().getGamePlayer() != null) - { + if (habbo.getHabboInfo().getGamePlayer() != null) { habbo.getHabboInfo().getGamePlayer().addScore(this.score); } @@ -96,18 +84,15 @@ public class WiredEffectGiveScore extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.score + ";" + this.count + ";" + this.getDelay(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(";"); - if(data.length == 3) - { + if (data.length == 3) { this.score = Integer.valueOf(data[0]); this.count = Integer.valueOf(data[1]); this.setDelay(Integer.valueOf(data[2])); @@ -115,22 +100,19 @@ public class WiredEffectGiveScore extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.score = 0; this.count = 0; this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return WiredEffectGiveScore.type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -144,36 +126,28 @@ public class WiredEffectGiveScore extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.score = packet.readInt(); @@ -186,8 +160,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 00d5910b..160e7eb1 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 @@ -17,8 +17,7 @@ import gnu.trove.map.hash.TIntIntHashMap; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect -{ +public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.GIVE_SCORE_TEAM; private int points; @@ -27,39 +26,31 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect private TIntIntHashMap startTimes = new TIntIntHashMap(); - public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - public WiredEffectGiveScoreToTeam(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectGiveScoreToTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { + if (habbo != null) { Class game = habbo.getHabboInfo().getCurrentGame(); - if(game != null) - { + if (game != null) { Game g = room.getGame(game); - if(g != null) - { + if (g != null) { int c = this.startTimes.get(g.getStartTime()); - if(c < this.count) - { + if (c < this.count) { GameTeam team = g.getTeam(this.teamColor); - if(team != null) - { + if (team != null) { team.addTeamScore(this.points); this.startTimes.put(g.getStartTime(), c++); @@ -75,18 +66,15 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.points + ";" + this.count + ";" + this.teamColor.type + ";" + this.getDelay(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(";"); - if(data.length == 4) - { + if (data.length == 4) { this.points = Integer.valueOf(data[0]); this.count = Integer.valueOf(data[1]); this.teamColor = GameTeamColors.values()[Integer.valueOf(data[2])]; @@ -95,8 +83,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.startTimes.clear(); this.points = 0; this.count = 0; @@ -105,14 +92,12 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -120,9 +105,9 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect message.appendInt(this.getId()); message.appendString(""); message.appendInt(3); - message.appendInt(this.points); - message.appendInt(this.count); - message.appendInt(this.teamColor.type + 1); + message.appendInt(this.points); + message.appendInt(this.count); + message.appendInt(this.teamColor.type + 1); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(this.getDelay()); @@ -130,8 +115,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.points = packet.readInt(); 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 0673aa0d..bebaad81 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 @@ -19,35 +19,28 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectJoinTeam extends InteractionWiredEffect -{ +public class WiredEffectJoinTeam extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.JOIN_TEAM; private GameTeamColors teamColor = GameTeamColors.RED; - public WiredEffectJoinTeam(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectJoinTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectJoinTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectJoinTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if(habbo.getHabboInfo().getGamePlayer() == null) - { - WiredGame game = (WiredGame)room.getGame(WiredGame.class); + if (habbo != null) { + if (habbo.getHabboInfo().getGamePlayer() == null) { + WiredGame game = (WiredGame) room.getGame(WiredGame.class); - if(game == null) - { + if (game == null) { game = new WiredGame(room); room.addGame(game); } @@ -60,43 +53,36 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.teamColor.type + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if (data.length >= 1) - { + if (data.length >= 1) { this.setDelay(Integer.valueOf(data[0])); - if (data.length >= 2) - { + if (data.length >= 2) { this.teamColor = GameTeamColors.values()[Integer.valueOf(data[1])]; } } } @Override - public void onPickUp() - { + public void onPickUp() { this.teamColor = GameTeamColors.RED; this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -109,36 +95,28 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; int unknownInt = packet.readInt(); @@ -149,8 +127,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 8414a41e..72897ebf 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 @@ -23,47 +23,40 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectKickHabbo extends InteractionWiredEffect -{ +public class WiredEffectKickHabbo extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.KICK_USER; private String message = ""; - public WiredEffectKickHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectKickHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectKickHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectKickHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(room == null) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (room == null) return false; Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) - { + if (habbo != null) { + if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.unkickable")); return true; } - if (habbo.getHabboInfo().getId() == room.getOwnerId()) - { + if (habbo.getHabboInfo().getId() == room.getOwnerId()) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.owner")); return true; } room.giveEffect(habbo, 4, 2); - if(!this.message.isEmpty()) + if (!this.message.isEmpty()) habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message, habbo, habbo, RoomChatMessageBubbles.ALERT))); Emulator.getThreading().run(new RoomUnitKick(habbo, room, true), 2000); @@ -75,51 +68,41 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.message; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - try - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + try { String[] data = set.getString("wired_data").split("\t"); - if (data.length >= 1) - { + if (data.length >= 1) { this.setDelay(Integer.valueOf(data[0])); - if (data.length >= 2) - { + if (data.length >= 2) { this.message = data[1]; } } - } - catch (Exception e) - { + } catch (Exception e) { this.message = ""; this.setDelay(0); } } @Override - public void onPickUp() - { + public void onPickUp() { this.message = ""; this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -131,36 +114,28 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.message = packet.readString(); packet.readInt(); @@ -170,8 +145,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } 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 e7b7d7a8..248adcda 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 @@ -19,38 +19,30 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectLeaveTeam extends InteractionWiredEffect -{ +public class WiredEffectLeaveTeam extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.LEAVE_TEAM; - public WiredEffectLeaveTeam(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectLeaveTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectLeaveTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectLeaveTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if(habbo.getHabboInfo().getCurrentGame() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentGame() != null) { Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); - if (game == null) - { + if (game == null) { game = room.getGame(WiredGame.class); } - if (game != null) - { + if (game != null) { game.removeHabbo(habbo); return true; } @@ -60,32 +52,27 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.setDelay(Integer.valueOf(set.getString("wired_data"))); } @Override - public void onPickUp() - { + public void onPickUp() { this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -97,36 +84,28 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); packet.readInt(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java index 3b40f3cb..d2b53911 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java @@ -17,43 +17,37 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectLowerFurni extends InteractionWiredEffect -{ +public class WiredEffectLowerFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TELEPORT; private THashSet items = new THashSet<>(); private int offset = 0; - public WiredEffectLowerFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectLowerFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectLowerFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectLowerFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); @@ -67,8 +61,7 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); @@ -76,8 +69,7 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -87,25 +79,20 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - for(HabboItem item : this.items) - { - if(item.getRoomId() == 0) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + for (HabboItem item : this.items) { + if (item.getRoomId() == 0) continue; - if(item.getZ() > 0) - { + if (item.getZ() > 0) { double z = (0.1) * (double) this.offset; double minZ = room.getLayout().getHeightAtSquare(item.getX(), item.getY()); - if(z < minZ) - { + if (z < minZ) { z = minZ; } @@ -119,14 +106,11 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.offset + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -135,28 +119,21 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); - if(wiredData.contains("\t")) - { + if (wiredData.contains("\t")) { String[] data = wiredData.split("\t"); - try - { + try { this.offset = Integer.valueOf(data[0]); + } catch (Exception e) { } - catch (Exception e) - {} - if (data.length >= 2) - { - if (data[1].contains(";")) - { - for (String s : data[1].split(";")) - { + if (data.length >= 2) { + if (data[1].contains(";")) { + for (String s : data[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -168,8 +145,7 @@ public class WiredEffectLowerFurni extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.offset = 0; this.items.clear(); this.setDelay(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 01fe3d8a..f542b964 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 @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -23,44 +22,34 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectMatchFurni extends InteractionWiredEffect -{ +public class WiredEffectMatchFurni extends InteractionWiredEffect { private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; - + public boolean checkForWiredResetPermission = true; private THashSet settings; - private boolean state = false; private boolean direction = false; private boolean position = false; - public boolean checkForWiredResetPermission = true; - public WiredEffectMatchFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMatchFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.settings = new THashSet<>(0); } - public WiredEffectMatchFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMatchFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.settings = new THashSet<>(0); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet tilesToUpdate = new THashSet<>(this.settings.size()); //this.refresh(); - for(WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if(item != null) - { - if(this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) - { - if(!setting.state.equals(" ")) - { + if (item != null) { + if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { + if (!setting.state.equals(" ")) { item.setExtradata(setting.state); tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } @@ -68,8 +57,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect int oldRotation = item.getRotation(); boolean slideAnimation = true; - if(this.direction) - { + if (this.direction) { item.setRotation(setting.rotation); slideAnimation = false; } @@ -77,12 +65,10 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect //room.sendComposer(new ItemStateComposer(item).compose()); room.sendComposer(new FloorItemUpdateComposer(item).compose()); - if(this.position) - { + if (this.position) { RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y); - if (t != null) - { + if (t != null) { if (t.state != RoomTileState.INVALID) { boolean canMove = true; @@ -140,30 +126,23 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { this.refresh(); StringBuilder data = new StringBuilder(this.settings.size() + ":"); - if(this.settings.isEmpty()) - { + if (this.settings.isEmpty()) { data.append(";"); - } - else - { + } else { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - for (WiredMatchFurniSetting item : this.settings) - { + for (WiredMatchFurniSetting item : this.settings) { HabboItem i; - if (room != null) - { + if (room != null) { i = room.getHabboItem(item.itemId); - if (i != null) - { + if (i != null) { data.append(item.toString(this.checkForWiredResetPermission && i.allowWiredResetState())).append(";"); } } @@ -176,29 +155,23 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split(":"); int itemCount = Integer.valueOf(data[0]); String[] items = data[1].split(";"); - for(int i = 0; i < items.length; i++) - { - try - { + for (int i = 0; i < items.length; i++) { + try { String[] stuff = items[i].split("-"); - if (stuff.length >= 5) - { + if (stuff.length >= 5) { this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]))); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -210,8 +183,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.settings.clear(); this.state = false; this.direction = false; @@ -220,30 +192,28 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { this.refresh(); message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.settings.size()); - for(WiredMatchFurniSetting item : this.settings) + for (WiredMatchFurniSetting item : this.settings) message.appendInt(item.itemId); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); message.appendInt(3); - message.appendInt(this.state ? 1 : 0); - message.appendInt(this.direction ? 1 : 0); - message.appendInt(this.position ? 1 : 0); + message.appendInt(this.state ? 1 : 0); + message.appendInt(this.direction ? 1 : 0); + message.appendInt(this.position ? 1 : 0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(this.getDelay()); @@ -251,8 +221,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { this.settings.clear(); //packet.readInt(); @@ -268,13 +237,12 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return true; count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { int itemId = packet.readInt(); HabboItem item = room.getHabboItem(itemId); @@ -287,25 +255,20 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect return true; } - private void refresh() - { + private void refresh() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room != null && room.isLoaded()) - { + if (room != null && room.isLoaded()) { THashSet remove = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) - { + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); - if (item == null) - { + if (item == null) { remove.add(setting); } } - for(WiredMatchFurniSetting setting : remove) - { + for (WiredMatchFurniSetting setting : remove) { this.settings.remove(setting); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java index 09ff5556..495c15fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.items.Item; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectMatchFurniStaff extends WiredEffectMatchFurni -{ - public WiredEffectMatchFurniStaff(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectMatchFurniStaff extends WiredEffectMatchFurni { + public WiredEffectMatchFurniStaff(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.checkForWiredResetPermission = false; } - public WiredEffectMatchFurniStaff(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMatchFurniStaff(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.checkForWiredResetPermission = false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index c9dbae13..83d32cda 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 @@ -18,61 +18,49 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectMoveFurniAway extends InteractionWiredEffect -{ +public class WiredEffectMoveFurniAway extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.FLEE; private THashSet items = new THashSet<>(); - public WiredEffectMoveFurniAway(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMoveFurniAway(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectMoveFurniAway(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMoveFurniAway(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { if (item.getRoomId() == 0) items.add(item); } this.items.removeAll(items); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); double shortest = 1000.0D; Habbo target = null; - for(Habbo habbo : room.getHabbos()) - { - if(habbo.getRoomUnit().getCurrentLocation().distance(t) <= shortest) - { + for (Habbo habbo : room.getHabbos()) { + if (habbo.getRoomUnit().getCurrentLocation().distance(t) <= shortest) { shortest = habbo.getRoomUnit().getCurrentLocation().distance(t); target = habbo; } } - if(target != null) - { - if(RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY())) - { + if (target != null) { + if (RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY())) { final Habbo finalTarget = target; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { WiredHandler.handle(WiredTriggerType.COLLISION, finalTarget.getRoomUnit(), room, new Object[]{item}); } }, 500); @@ -83,29 +71,22 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect int x = 0; int y = 0; - if(target.getRoomUnit().getX() == item.getX()) - { + if (target.getRoomUnit().getX() == item.getX()) { if (item.getY() < target.getRoomUnit().getY()) y--; else y++; - } - else if(target.getRoomUnit().getY() == item.getY()) - { + } else if (target.getRoomUnit().getY() == item.getY()) { if (item.getX() < target.getRoomUnit().getX()) x--; else x++; - } - else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) - { - if (target.getRoomUnit().getX() - item.getX() > 0 ) + } else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) { + if (target.getRoomUnit().getX() - item.getX() > 0) x--; else x++; - } - else - { + } else { if (target.getRoomUnit().getY() - item.getY() > 0) y--; else @@ -114,14 +95,11 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect RoomTile newTile = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y)); - if (newTile != null && newTile.state == RoomTileState.OPEN) - { - if (room.getLayout().tileExists(newTile.x, newTile.y)) - { + if (newTile != null && newTile.state == RoomTileState.OPEN) { + if (room.getLayout().tileExists(newTile.x, newTile.y)) { HabboItem topItem = room.getTopItemAt(newTile.x, newTile.y); - if (topItem == null || topItem.getBaseItem().allowStack()) - { + if (topItem == null || topItem.getBaseItem().allowStack()) { double offsetZ = 0; if (topItem != null) @@ -137,14 +115,11 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -153,21 +128,16 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { + if (wiredData.length >= 1) { this.setDelay(Integer.valueOf(wiredData[0])); } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -178,37 +148,32 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -222,8 +187,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); @@ -231,8 +195,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -242,8 +205,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 495; } } 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 3c5e93bb..bb7853c8 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 @@ -22,30 +22,26 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class WiredEffectMoveFurniTo extends InteractionWiredEffect -{ +public class WiredEffectMoveFurniTo extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO; private final List items = new ArrayList<>(); private int direction; private int spacing = 1; private Map indexOffset = new LinkedHashMap<>(); - public WiredEffectMoveFurniTo(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMoveFurniTo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectMoveFurniTo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMoveFurniTo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return false; this.items.clear(); @@ -58,8 +54,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect packet.readString(); int count = packet.readInt(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(room.getHabboItem(packet.readInt())); } @@ -69,96 +64,79 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { List items = new ArrayList<>(); - for (HabboItem item : this.items) - { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } - for (HabboItem item : items) - { - this.items.remove(item); - } + for (HabboItem item : items) { + this.items.remove(item); + } - if (this.items.isEmpty()) - return false; + if (this.items.isEmpty()) + return false; - if (stuff != null && stuff.length > 0) - { - for (Object object : stuff) - { - if (object instanceof HabboItem) - { - HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size())); + if (stuff != null && stuff.length > 0) { + for (Object object : stuff) { + if (object instanceof HabboItem) { + HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size())); - if (targetItem != null) - { - int indexOffset = 0; - if (!this.indexOffset.containsKey(targetItem.getId())) - { - this.indexOffset.put(targetItem.getId(), indexOffset); - } - else - { - indexOffset = this.indexOffset.get(targetItem.getId()) + this.spacing; - } + if (targetItem != null) { + int indexOffset = 0; + if (!this.indexOffset.containsKey(targetItem.getId())) { + this.indexOffset.put(targetItem.getId(), indexOffset); + } else { + indexOffset = this.indexOffset.get(targetItem.getId()) + this.spacing; + } - RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY()); + RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY()); - if (objectTile != null) - { - THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()); + if (objectTile != null) { + THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()); - RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); - if (tile == null || !tile.getAllowStack()) - { - indexOffset = 0; - tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); - } + RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); + if (tile == null || !tile.getAllowStack()) { + indexOffset = 0; + tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); + } - room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose()); - refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation())); - room.updateTiles(refreshTiles); - this.indexOffset.put(targetItem.getId(), indexOffset); - } - } - } - } - } + room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose()); + refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation())); + room.updateTiles(refreshTiles); + this.indexOffset.put(targetItem.getId(), indexOffset); + } + } + } + } + } return true; } @Override - public String getWiredData() - { + public String getWiredData() { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } StringBuilder data = new StringBuilder(this.direction + "\t" + this.spacing + "\t" + this.getDelay() + "\t"); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { data.append(item.getId()).append("\r"); } @@ -166,70 +144,60 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for (HabboItem item : this.items) - { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } - for (HabboItem item : items) - { - this.items.remove(item); - } + for (HabboItem item : items) { + this.items.remove(item); + } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.direction); - message.appendInt(this.spacing); - message.appendInt(0); - message.appendInt(this.getType().code); - message.appendInt(this.getDelay()); - message.appendInt(0); + message.appendBoolean(false); + message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + message.appendInt(this.items.size()); + for (HabboItem item : this.items) + message.appendInt(item.getId()); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(2); + message.appendInt(this.direction); + message.appendInt(this.spacing); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(this.getDelay()); + message.appendInt(0); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - this.items.clear(); + public void loadWiredData(ResultSet set, Room room) throws SQLException { + this.items.clear(); - String[] data = set.getString("wired_data").split("\t"); + String[] data = set.getString("wired_data").split("\t"); - if (data.length == 4) - { - try - { - this.direction = Integer.valueOf(data[0]); - this.spacing = Integer.valueOf(data[1]); - this.setDelay(Integer.valueOf(data[2])); - } - catch (Exception e) - { - } + if (data.length == 4) { + try { + this.direction = Integer.valueOf(data[0]); + this.spacing = Integer.valueOf(data[1]); + this.setDelay(Integer.valueOf(data[2])); + } catch (Exception e) { + } - for (String s : data[3].split("\r")) - { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + for (String s : data[3].split("\r")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if (item != null) - this.items.add(item); - } - } + if (item != null) + this.items.add(item); + } + } } @Override - public void onPickUp() - { + public void onPickUp() { this.setDelay(0); this.items.clear(); this.direction = 0; @@ -238,8 +206,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 495; } } \ No newline at end of file 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 d2f07557..f1c4166d 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 @@ -15,6 +15,7 @@ import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.threading.runnables.WiredCollissionRunnable; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -23,10 +24,10 @@ import java.util.List; /** * Wired effect: move to closest user * Confirmed as working exactly like Habbo.com 03/05/2019 04:00 + * * @author Beny. */ -public class WiredEffectMoveFurniTowards extends InteractionWiredEffect -{ +public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.CHASE; private THashSet items; @@ -34,15 +35,13 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect private THashMap lastDirections; - public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); this.lastDirections = new THashMap<>(); } - public WiredEffectMoveFurniTowards(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMoveFurniTowards(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); this.lastDirections = new THashMap<>(); @@ -54,25 +53,25 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect RoomTile currentTile = layout.getTile(item.getX(), item.getY()); - RoomUserRotation[] rotations = new RoomUserRotation[] { RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST }; + RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST}; - for(RoomUserRotation rot : rotations) { + 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.state == RoomTileState.BLOCKED || tile.state == RoomTileState.INVALID) continue; - if(!layout.tileExists(tile.x, tile.y)) + if (!layout.tileExists(tile.x, tile.y)) continue; - if(room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE) + if (room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE) continue; HabboItem topItem = room.getTopItemAt(tile.x, tile.y); - if(topItem != null && !topItem.getBaseItem().allowStack()) + if (topItem != null && !topItem.getBaseItem().allowStack()) continue; - if(tile.getAllowStack()) { + if (tile.getAllowStack()) { availableDirections.add(rot); } } @@ -81,25 +80,22 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet items = new THashSet(); - for(HabboItem item : this.items) - { - if(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } - for(HabboItem item : this.items) { + for (HabboItem item : this.items) { - if(item == null) + if (item == null) continue; // direction the furni will move in @@ -111,23 +107,23 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect RoomLayout layout = room.getLayout(); boolean collided = false; - for(int i = 0; i < 3; i++) { - if(target != null) + for (int i = 0; i < 3; i++) { + if (target != null) break; - RoomUserRotation[] rotations = new RoomUserRotation[] { RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST }; + RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST}; - for(RoomUserRotation rot : rotations) { + for (RoomUserRotation rot : rotations) { RoomTile startTile = layout.getTile(item.getX(), item.getY()); - for(int ii = 0; ii <= i; ii++) { - if(startTile == null) + for (int ii = 0; ii <= i; ii++) { + if (startTile == null) break; startTile = layout.getTileInFront(startTile, rot.getValue()); } - if(startTile != null && layout.tileExists(startTile.x, startTile.y)) { + if (startTile != null && layout.tileExists(startTile.x, startTile.y)) { THashSet habbosAtTile = room.getHabbosAt(startTile.x, startTile.y); if (habbosAtTile.size() > 0) { target = habbosAtTile.iterator().next(); @@ -141,33 +137,26 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } } - if(collided) + if (collided) continue; - if(target != null) { - if(target.getRoomUnit().getX() == item.getX()) - { + if (target != null) { + if (target.getRoomUnit().getX() == item.getX()) { if (item.getY() < target.getRoomUnit().getY()) moveDirection = RoomUserRotation.SOUTH; else moveDirection = RoomUserRotation.NORTH; - } - else if(target.getRoomUnit().getY() == item.getY()) - { + } else if (target.getRoomUnit().getY() == item.getY()) { if (item.getX() < target.getRoomUnit().getX()) moveDirection = RoomUserRotation.EAST; else moveDirection = RoomUserRotation.WEST; - } - else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) - { - if (target.getRoomUnit().getX() - item.getX() > 0 ) + } else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) { + if (target.getRoomUnit().getX() - item.getX() > 0) moveDirection = RoomUserRotation.EAST; else moveDirection = RoomUserRotation.WEST; - } - else - { + } else { if (target.getRoomUnit().getY() - item.getY() > 0) moveDirection = RoomUserRotation.SOUTH; else @@ -189,10 +178,10 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect List availableDirections = this.getAvailableDirections(item, room); - if(moveDirection != null && !availableDirections.contains(moveDirection)) + if (moveDirection != null && !availableDirections.contains(moveDirection)) moveDirection = null; - if(moveDirection == null) { + if (moveDirection == null) { if (availableDirections.size() == 0) { continue; } else if (availableDirections.size() == 1) { @@ -220,11 +209,11 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect RoomTile newTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), moveDirection.getValue()); - if(newTile != null) { + if (newTile != null) { lastDirections.put(item.getId(), moveDirection); FurnitureMovementError error = room.furnitureFitsAt(newTile, item, item.getRotation()); - if(error == FurnitureMovementError.NONE) { + if (error == FurnitureMovementError.NONE) { double offset = room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(); room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose()); } @@ -235,14 +224,11 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -251,21 +237,16 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { + if (wiredData.length >= 1) { this.setDelay(Integer.valueOf(wiredData[0])); } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -276,37 +257,32 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); @@ -320,8 +296,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); @@ -329,8 +304,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -340,8 +314,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 495; } } 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 638db8e9..caabe0e0 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 @@ -23,70 +23,54 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -public class WiredEffectMoveRotateFurni extends InteractionWiredEffect -{ +public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { 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 final THashSet items = new THashSet<>(WiredHandler.MAXIMUM_FURNI_SELECTION / 2); - public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet items = new THashSet<>(this.items.size()); THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10)); - - for (HabboItem item : this.items) - { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - for (HabboItem item : items) - { - this.items.remove(item); - } + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } - for (HabboItem item : this.items) - { + for (HabboItem item : items) { + this.items.remove(item); + } + + for (HabboItem item : this.items) { //Handle rotation int rotationToAdd = 0; - if (this.rotation > 0) - { - tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - if (this.rotation == 1) - { + if (this.rotation > 0) { + tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + if (this.rotation == 1) { rotationToAdd = 2; - } - else if (this.rotation == 2) - { + } else if (this.rotation == 2) { rotationToAdd = 6; - } + } //Random rotation - else if (this.rotation == 3) - { - if (Emulator.getRandom().nextInt(2) == 1) - { + else if (this.rotation == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { rotationToAdd = 2; - } - else - { + } else { rotationToAdd = 6; - } - } + } + } - } + } int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); @@ -95,58 +79,45 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { item.setRotation(newRotation); - if (this.direction == 0) - { + if (this.direction == 0) { tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); room.sendComposer(new FloorItemUpdateComposer(item).compose()); } } - if (this.direction > 0) - { + if (this.direction > 0) { int nextDirectionOffset = 0; RoomUserRotation startMoveDirection = RoomUserRotation.NORTH; RoomUserRotation moveDirection = null; - if (this.direction == 1) - { + if (this.direction == 1) { startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; nextDirectionOffset = 2; - } else if (this.direction == 2) - { - if (Emulator.getRandom().nextInt(2) == 1) - { + } else if (this.direction == 2) { + if (Emulator.getRandom().nextInt(2) == 1) { startMoveDirection = RoomUserRotation.EAST; nextDirectionOffset = 4; - } else - { + } else { startMoveDirection = RoomUserRotation.WEST; nextDirectionOffset = 4; } - } else if (this.direction == 3) - { - if (Emulator.getRandom().nextInt(2) == 1) - { + } else if (this.direction == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { startMoveDirection = RoomUserRotation.NORTH; nextDirectionOffset = 4; - } else - { + } else { startMoveDirection = RoomUserRotation.SOUTH; nextDirectionOffset = 4; } - } else if (this.direction == 4) - { + } else if (this.direction == 4) { startMoveDirection = RoomUserRotation.SOUTH; nextDirectionOffset = 8; - } else if (this.direction == 5) - { + } else if (this.direction == 5) { startMoveDirection = RoomUserRotation.EAST; nextDirectionOffset = 8; - } else if (this.direction == 6) - { + } else if (this.direction == 6) { startMoveDirection = RoomUserRotation.NORTH; nextDirectionOffset = 8; - } else if (this.direction == 7) - { + } else if (this.direction == 7) { startMoveDirection = RoomUserRotation.WEST; nextDirectionOffset = 8; } @@ -155,11 +126,9 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect int count = 0; int maxCount = 8 / nextDirectionOffset; - while (moveDirection != startMoveDirection && !validMove && count < maxCount) - { + while (moveDirection != startMoveDirection && !validMove && count < maxCount) { count++; - if (moveDirection == null) - { + if (moveDirection == null) { moveDirection = startMoveDirection; } RoomLayout layout = room.getLayout(); @@ -170,17 +139,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) ); - if (newTile != null) - { + if (newTile != null) { boolean hasHabbos = false; - for (Habbo habbo : room.getHabbosAt(newTile)) - { + for (Habbo habbo : room.getHabbosAt(newTile)) { hasHabbos = true; WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); } - if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) - { + if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { java.awt.Rectangle rectangle = new Rectangle(newTile.x, newTile.y, item.getBaseItem().getWidth(), @@ -188,67 +154,56 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect double offset = -Short.MAX_VALUE; validMove = true; - for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) - { - if (!validMove) - { + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + if (!validMove) { break; } - for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) - { + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { RoomTile tile = layout.getTile(x, y); - if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) - { + if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) { validMove = false; break; } THashSet itemsAtNewTile = room.getItemsAt(tile); - if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) - { + if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { validMove = false; break; } java.util.List tileItems = new ArrayList>>(rectangle.width * rectangle.height); tileItems.add(Pair.create(tile, itemsAtNewTile)); - if (!item.canStackAt(room, tileItems)) - { + if (!item.canStackAt(room, tileItems)) { validMove = false; break; } HabboItem i = room.getTopItemAt(x, y, item); - if (i == null || i == item || i.getBaseItem().allowStack()) - { + if (i == null || i == item || i.getBaseItem().allowStack()) { offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); } tilesToUpdate.add(tile); } } - if (item.getZ() + offset > 40) - { + if (item.getZ() + offset > 40) { offset = 40 - item.getZ(); } - if (validMove) - { + if (validMove) { room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose()); } } } - if (!validMove) - { + if (!validMove) { moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset); } } } - } + } - if (!tilesToUpdate.isEmpty()) - { + if (!tilesToUpdate.isEmpty()) { room.updateTiles(tilesToUpdate); } @@ -256,20 +211,17 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { THashSet items = new THashSet<>(this.items.size() / 2); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null)) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null)) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } @@ -277,8 +229,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect this.rotation + "\t" + this.getDelay() + "\t"); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { data.append(item.getId()).append("\r"); } @@ -286,37 +237,30 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - this.items.clear(); + public void loadWiredData(ResultSet set, Room room) throws SQLException { + this.items.clear(); - String[] data = set.getString("wired_data").split("\t"); + String[] data = set.getString("wired_data").split("\t"); - if (data.length == 4) - { - try - { - this.direction = Integer.valueOf(data[0]); - this.rotation = Integer.valueOf(data[1]); - this.setDelay(Integer.valueOf(data[2])); - } - catch (Exception e) - { - } + if (data.length == 4) { + try { + this.direction = Integer.valueOf(data[0]); + this.rotation = Integer.valueOf(data[1]); + this.setDelay(Integer.valueOf(data[2])); + } catch (Exception e) { + } - for (String s : data[3].split("\r")) - { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + for (String s : data[3].split("\r")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if (item != null) - this.items.add(item); - } - } + if (item != null) + this.items.add(item); + } + } } @Override - public void onPickUp() - { + public void onPickUp() { this.direction = 0; this.rotation = 0; this.items.clear(); @@ -324,50 +268,45 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(this.items.size() / 2); - for (HabboItem item : this.items) - { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } - for (HabboItem item : items) - { - this.items.remove(item); - } + for (HabboItem item : items) { + this.items.remove(item); + } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.direction); - message.appendInt(this.rotation); - message.appendInt(0); - message.appendInt(this.getType().code); - message.appendInt(this.getDelay()); - message.appendInt(0); + message.appendBoolean(false); + message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + message.appendInt(this.items.size()); + for (HabboItem item : this.items) + message.appendInt(item.getId()); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(2); + message.appendInt(this.direction); + message.appendInt(this.rotation); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(this.getDelay()); + message.appendInt(0); } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if(room == null) + if (room == null) return false; packet.readInt(); @@ -379,11 +318,10 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect int count = packet.readInt(); - this.items.clear(); - for (int i = 0; i < count; i++) - { - this.items.add(room.getHabboItem(packet.readInt())); - } + this.items.clear(); + for (int i = 0; i < count; i++) { + this.items.add(room.getHabboItem(packet.readInt())); + } this.setDelay(packet.readInt()); @@ -391,8 +329,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 100; } } 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 07a9f8b2..27a1d2b3 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 @@ -17,26 +17,22 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectMuteHabbo extends InteractionWiredEffect -{ +public class WiredEffectMuteHabbo extends InteractionWiredEffect { private static final WiredEffectType type = WiredEffectType.MUTE_TRIGGER; private int length = 5; private String message = ""; - public WiredEffectMuteHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectMuteHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectMuteHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectMuteHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -52,8 +48,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.length = packet.readInt(); this.message = packet.readString(); @@ -64,15 +59,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(roomUnit == null) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (roomUnit == null) return true; Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { if (room.hasRights(habbo)) return false; @@ -85,46 +78,38 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.length + "\t" + this.message; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if (data.length >= 3) - { - try - { + if (data.length >= 3) { + try { this.setDelay(Integer.valueOf(data[0])); this.length = Integer.valueOf(data[1]); this.message = data[2]; + } catch (Exception e) { } - catch (Exception e) - {} } } @Override - public void onPickUp() - { + public void onPickUp() { this.setDelay(0); this.message = ""; this.length = 0; } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java index 8d8363cc..fe399daa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java @@ -9,25 +9,20 @@ import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectOpenHabboPages extends WiredEffectWhisper -{ - public WiredEffectOpenHabboPages(ResultSet set, Item baseItem) throws SQLException - { +public class WiredEffectOpenHabboPages extends WiredEffectWhisper { + public WiredEffectOpenHabboPages(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectOpenHabboPages(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectOpenHabboPages(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new NuxAlertComposer(this.message)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java index 4e669dbb..76baea9d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java @@ -17,43 +17,37 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectRaiseFurni extends InteractionWiredEffect -{ +public class WiredEffectRaiseFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TELEPORT; private THashSet items = new THashSet<>(); private int offset = 0; - public WiredEffectRaiseFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectRaiseFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectRaiseFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectRaiseFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) + for (HabboItem item : this.items) message.appendInt(item.getId()); message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); @@ -67,8 +61,7 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); @@ -76,8 +69,7 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -87,20 +79,17 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - for(HabboItem item : this.items) - { - if(item.getRoomId() == 0) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + for (HabboItem item : this.items) { + if (item.getRoomId() == 0) continue; - double offsetZ = (((0.1) * this.offset)) % 127; + double offsetZ = (((0.1) * this.offset)) % 127; room.sendComposer(new FloorItemOnRollerComposer(item, null, room.getLayout().getTile(item.getX(), item.getY()), offsetZ, room).compose()); room.updateHabbosAt(item.getX(), item.getY()); } @@ -109,14 +98,11 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.offset + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -125,28 +111,21 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); - if(wiredData.contains("\t")) - { + if (wiredData.contains("\t")) { String[] data = wiredData.split("\t"); - try - { + try { this.offset = Integer.valueOf(data[0]); + } catch (Exception e) { } - catch (Exception e) - {} - if (data.length >= 2) - { - if (data[1].contains(";")) - { - for (String s : data[1].split(";")) - { + if (data.length >= 2) { + if (data[1].contains(";")) { + for (String s : data[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -158,8 +137,7 @@ public class WiredEffectRaiseFurni extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.offset = 0; this.items.clear(); this.setDelay(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 7bcd4c72..5d6f6cfe 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 @@ -18,25 +18,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectResetTimers extends InteractionWiredEffect -{ +public class WiredEffectResetTimers extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.RESET_TIMERS; private int delay = 0; - public WiredEffectResetTimers(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectResetTimers(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectResetTimers(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectResetTimers(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -49,36 +45,28 @@ public class WiredEffectResetTimers extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); packet.readInt(); @@ -89,46 +77,38 @@ public class WiredEffectResetTimers extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Emulator.getThreading().run(new WiredResetTimers(room), this.delay); return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.delay + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try - { + try { if (!data.equals("")) this.delay = Integer.valueOf(data); - } - catch (Exception e) - { + } catch (Exception e) { } this.setDelay(this.delay); } @Override - public void onPickUp() - { + public void onPickUp() { this.delay = 0; this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java index 545a29c4..fd089c22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java @@ -16,25 +16,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectRollerSpeed extends InteractionWiredEffect -{ +public class WiredEffectRollerSpeed extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; private int speed = 4; - public WiredEffectRollerSpeed(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectRollerSpeed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectRollerSpeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectRollerSpeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -46,44 +42,33 @@ public class WiredEffectRollerSpeed extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - try - { + try { this.speed = Integer.valueOf(packet.readString()); - } - catch (Exception e) - { + } catch (Exception e) { return false; } packet.readInt(); @@ -93,49 +78,40 @@ public class WiredEffectRollerSpeed extends InteractionWiredEffect } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { room.setRollerSpeed(this.speed); return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.speed; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); String[] data = wireData.split("\t"); this.speed = 0; - if(data.length >= 2) - { + if (data.length >= 2) { super.setDelay(Integer.valueOf(data[0])); - try - { + try { this.speed = Integer.valueOf(data[1]); - } - catch (Exception e) - { + } catch (Exception e) { } } } @Override - public void onPickUp() - { + public void onPickUp() { this.speed = 4; this.setDelay(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index dcfa0198..81456f98 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 @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; @@ -27,99 +26,21 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class WiredEffectTeleport extends InteractionWiredEffect -{ +public class WiredEffectTeleport extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TELEPORT; protected List items; - public WiredEffectTeleport(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new ArrayList<>(); } - public WiredEffectTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new ArrayList<>(); } - @Override - public void serializeWiredData(ServerMessage message, Room room) - { - THashSet items = new THashSet<>(); - - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for(HabboItem item : items) - { - this.items.remove(item); - } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for(HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().code); - message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { - @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { - invalidTriggers.add(object.getId()); - } - return true; - } - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { - message.appendInt(i); - } - } - else - { - message.appendInt(0); - } - } - - @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { - packet.readInt(); - packet.readString(); - - this.items.clear(); - - int count = packet.readInt(); - - for(int i = 0; i < count; i++) - { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); - } - - this.setDelay(packet.readInt()); - - return true; - } - public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { if (roomUnit == null || tile == null) return; @@ -153,29 +74,87 @@ public class WiredEffectTeleport extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { + this.items.remove(item); + } + message.appendBoolean(false); + message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + message.appendInt(this.items.size()); + for (HabboItem item : this.items) + message.appendInt(item.getId()); + + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(0); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(this.getDelay()); + if (this.requiresTriggeringUser()) { + List invalidTriggers = new ArrayList<>(); + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { + @Override + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getId()); + } + return true; + } + }); + message.appendInt(invalidTriggers.size()); + for (Integer i : invalidTriggers) { + message.appendInt(i); + } + } else { + message.appendInt(0); + } + } + + @Override + public boolean saveData(ClientMessage packet, GameClient gameClient) { + packet.readInt(); + packet.readString(); + + this.items.clear(); + + int count = packet.readInt(); + + for (int i = 0; i < count; i++) { + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + } + + this.setDelay(packet.readInt()); + + return true; + } + + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + THashSet items = new THashSet<>(); + + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } + + for (HabboItem item : items) { this.items.remove(item); } - if(!this.items.isEmpty()) - { + if (!this.items.isEmpty()) { int i = Emulator.getRandom().nextInt(this.items.size()) + 1; int j = 1; int tryCount = 0; - while (tryCount < this.items.size()) - { + while (tryCount < this.items.size()) { tryCount++; HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size()); @@ -190,14 +169,11 @@ public class WiredEffectTeleport extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -206,21 +182,16 @@ public class WiredEffectTeleport extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new ArrayList<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { + if (wiredData.length >= 1) { this.setDelay(Integer.valueOf(wiredData[0])); } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -231,27 +202,23 @@ public class WiredEffectTeleport extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 0; } } 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 1f2d95ad..0e3232ed 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 @@ -25,101 +25,85 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectToggleFurni extends InteractionWiredEffect -{ +public class WiredEffectToggleFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE; private final THashSet items; - public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredEffectToggleFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectToggleFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { - THashSet items = new THashSet<>(); + public void serializeWiredData(ServerMessage message, Room room) { + THashSet items = new THashSet<>(); - for (HabboItem item : this.items) - { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } - for (HabboItem item : items) - { - this.items.remove(item); - } + for (HabboItem item : items) { + this.items.remove(item); + } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().code); - message.appendInt(this.getDelay()); + message.appendBoolean(false); + message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + message.appendInt(this.items.size()); + for (HabboItem item : this.items) { + message.appendInt(item.getId()); + } + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(0); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { - @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - } - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { - message.appendInt(i); - } - } - else - { - message.appendInt(0); - } + if (this.requiresTriggeringUser()) { + List invalidTriggers = new ArrayList<>(); + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { + @Override + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); + } + return true; + } + }); + message.appendInt(invalidTriggers.size()); + for (Integer i : invalidTriggers) { + message.appendInt(i); + } + } else { + message.appendInt(0); + } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); - this.items.clear(); + this.items.clear(); - int count = packet.readInt(); + int count = packet.readInt(); - for (int i = 0; i < count; i++) - { - HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()); + for (int i = 0; i < count; i++) { + HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()); - if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) - continue; + if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) + continue; - this.items.add(item); - } + this.items.add(item); + } this.setDelay(packet.readInt()); @@ -127,101 +111,84 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - Habbo habbo = room.getHabbo(roomUnit); + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + Habbo habbo = room.getHabbo(roomUnit); - HabboItem triggerItem = null; + HabboItem triggerItem = null; - THashSet itemsToRemove = new THashSet<>(); - for (HabboItem item : this.items) - { - if (item == null || item.getRoomId() == 0 || item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile) - { - itemsToRemove.add(item); - continue; - } + THashSet itemsToRemove = new THashSet<>(); + for (HabboItem item : this.items) { + if (item == null || item.getRoomId() == 0 || item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile) { + itemsToRemove.add(item); + continue; + } - try - { - if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer) - { - int state = 0; - if (!item.getExtradata().isEmpty()) { - try { - state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. - } catch (NumberFormatException ignored) { + try { + if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer) { + int state = 0; + if (!item.getExtradata().isEmpty()) { + try { + state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. + } catch (NumberFormatException ignored) { - } - } - item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); - } - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - } + } + } + item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); + } + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } + + this.items.removeAll(itemsToRemove); - this.items.removeAll(itemsToRemove); - return true; } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { - wiredData.append(item.getId()).append(";"); - } - } + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { + wiredData.append(item.getId()).append(";"); + } + } return wiredData.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - this.items.clear(); - String[] wiredData = set.getString("wired_data").split("\t"); + public void loadWiredData(ResultSet set, Room room) throws SQLException { + this.items.clear(); + String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { - this.setDelay(Integer.valueOf(wiredData[0])); - } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (wiredData.length >= 1) { + this.setDelay(Integer.valueOf(wiredData[0])); + } + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); - if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) - continue; + if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) + continue; - if (item != null) - this.items.add(item); - } - } - } + if (item != null) + this.items.add(item); + } + } + } } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } } 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 979656ea..c570f378 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 @@ -23,43 +23,36 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectToggleRandom extends InteractionWiredEffect -{ +public class WiredEffectToggleRandom extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TOGGLE_RANDOM; - private final THashSet items = new THashSet<>(); + private final THashSet items = new THashSet<>(); - public WiredEffectToggleRandom(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectToggleRandom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectToggleRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectToggleRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -70,78 +63,63 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { - packet.readInt(); - packet.readString(); + public boolean saveData(ClientMessage packet, GameClient gameClient) { + packet.readInt(); + packet.readString(); - this.items.clear(); + this.items.clear(); - int count = packet.readInt(); + int count = packet.readInt(); - for (int i = 0; i < count; i++) - { - HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()); + for (int i = 0; i < count; i++) { + HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()); - if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) - continue; + if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) + continue; - this.items.add(item); - } + this.items.add(item); + } - this.setDelay(packet.readInt()); + this.setDelay(packet.readInt()); return true; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { THashSet items = this.items; - for(HabboItem item : items) - { - if(item.getRoomId() == 0) - { + for (HabboItem item : items) { + if (item.getRoomId() == 0) { this.items.remove(item); continue; } - try - { + try { item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); room.updateItem(item); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -149,14 +127,11 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(!this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (!this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -165,21 +140,16 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { + if (wiredData.length >= 1) { this.setDelay(Integer.valueOf(wiredData[0])); } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) @@ -193,15 +163,13 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } } 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 675495c5..6016e7ab 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 @@ -21,44 +21,37 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectTriggerStacks extends InteractionWiredEffect -{ +public class WiredEffectTriggerStacks extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.CALL_STACKS; private THashSet items; - public WiredEffectTriggerStacks(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectTriggerStacks(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredEffectTriggerStacks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectTriggerStacks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -69,36 +62,28 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect message.appendInt(this.getType().code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); packet.readString(); @@ -106,8 +91,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -117,10 +101,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if (stuff != null && stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff != null && stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks) { return false; } @@ -128,22 +110,18 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect boolean found; - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { //if(item instanceof InteractionWiredTrigger) { found = false; - for(RoomTile tile : usedTiles) - { - if(tile.x == item.getX() && tile.y == item.getY()) - { + for (RoomTile tile : usedTiles) { + if (tile.x == item.getX() && tile.y == item.getY()) { found = true; break; } } - if(!found) - { + if (!found) { usedTiles.add(room.getLayout().getTile(item.getX(), item.getY())); } } @@ -158,14 +136,11 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - if(this.items != null && !this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null && !this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -174,21 +149,16 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String[] wiredData = set.getString("wired_data").split("\t"); - if (wiredData.length >= 1) - { + if (wiredData.length >= 1) { this.setDelay(Integer.valueOf(wiredData[0])); } - if (wiredData.length == 2) - { - if (wiredData[1].contains(";")) - { - for (String s : wiredData[1].split(";")) - { + if (wiredData.length == 2) { + if (wiredData[1].contains(";")) { + for (String s : wiredData[1].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -199,21 +169,18 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - protected long requiredCooldown() - { + protected long requiredCooldown() { return 250; } } 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 64f81fe5..f43834ba 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 @@ -21,25 +21,21 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectWhisper extends InteractionWiredEffect -{ +public class WiredEffectWhisper extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; protected String message = ""; - public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException - { + public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectWhisper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredEffectWhisper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(0); message.appendInt(0); @@ -51,41 +47,32 @@ public class WiredEffectWhisper extends InteractionWiredEffect message.appendInt(type.code); message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) - { + if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredTrigger object) - { - if (!object.isTriggeredByRoomUnit()) - { + public boolean execute(InteractionWiredTrigger object) { + if (!object.isTriggeredByRoomUnit()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) - { + public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); this.message = Emulator.getGameEnvironment().getWordFilter().filter(packet.readString(), null); - if (this.message.length() > 100) - { + if (this.message.length() > 100) { this.message = ""; } packet.readInt(); @@ -94,24 +81,17 @@ public class WiredEffectWhisper extends InteractionWiredEffect } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(this.message.length() > 0) - { - if(roomUnit != null) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (this.message.length() > 0) { + if (roomUnit != null) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); return true; } - } - else - { - for(Habbo h : room.getHabbos()) - { + } else { + for (Habbo h : room.getHabbos()) { h.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); } @@ -122,40 +102,34 @@ public class WiredEffectWhisper extends InteractionWiredEffect } @Override - public String getWiredData() - { + public String getWiredData() { return this.getDelay() + "\t" + this.message; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String wireData = set.getString("wired_data"); this.message = ""; - if(wireData.split("\t").length >= 2) - { + if (wireData.split("\t").length >= 2) { super.setDelay(Integer.valueOf(wireData.split("\t")[0])); this.message = wireData.split("\t")[1]; } } @Override - public void onPickUp() - { + public void onPickUp() { this.message = ""; this.setDelay(0); } @Override - public WiredEffectType getType() - { + public WiredEffectType getType() { return type; } @Override - public boolean requiresTriggeringUser() - { + public boolean requiresTriggeringUser() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java index ee1675f0..55e8ca96 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 @@ -13,33 +13,26 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredBlob extends InteractionDefault -{ - public WiredBlob(ResultSet set, Item baseItem) throws SQLException - { +public class WiredBlob extends InteractionDefault { + public WiredBlob(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata().equals("0")) - { + if (this.getExtradata().equals("0")) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) - { + if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { int points = Emulator.getConfig().getInt("hotel.item.wiredblob." + this.getBaseItem().getName()); - if (points == 0) - { + if (points == 0) { Emulator.getConfig().register("hotel.item.wiredblob." + this.getBaseItem().getName(), "3000"); points = 1; } @@ -47,28 +40,23 @@ public class WiredBlob extends InteractionDefault boolean triggered = false; Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); - if (game != null) - { + if (game != null) { GameTeam team = game.getTeamForHabbo(habbo); - if (team != null) - { + if (team != null) { team.addTeamScore(points); triggered = true; - } else - { + } else { GamePlayer player = habbo.getHabboInfo().getGamePlayer(); - if (player != null) - { + if (player != null) { player.addScore(points); triggered = true; } } } - if (triggered) - { + if (triggered) { this.setExtradata("1"); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java index af93ed1c..b8d8e3bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java @@ -9,51 +9,42 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredExtraRandom extends InteractionWiredExtra -{ - public WiredExtraRandom(ResultSet set, Item baseItem) throws SQLException - { +public class WiredExtraRandom extends InteractionWiredExtra { + public WiredExtraRandom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredExtraRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredExtraRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return false; } @Override - public String getWiredData() - { + public String getWiredData() { return null; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java index 0850a558..a7b04568 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java @@ -13,91 +13,73 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredExtraUnseen extends InteractionWiredExtra -{ +public class WiredExtraUnseen extends InteractionWiredExtra { public List seenList = new ArrayList<>(); - public WiredExtraUnseen(ResultSet set, Item baseItem) throws SQLException - { + public WiredExtraUnseen(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredExtraUnseen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredExtraUnseen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return false; } @Override - public String getWiredData() - { + public String getWiredData() { return null; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { this.seenList.clear(); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); this.seenList.clear(); } - public InteractionWiredEffect getUnseenEffect(List effects) - { + public InteractionWiredEffect getUnseenEffect(List effects) { List unseenEffects = new ArrayList<>(); - for (InteractionWiredEffect effect : effects) - { - if (!this.seenList.contains(effect.getId())) - { + for (InteractionWiredEffect effect : effects) { + if (!this.seenList.contains(effect.getId())) { unseenEffects.add(effect); } } InteractionWiredEffect effect = null; - if (!unseenEffects.isEmpty()) - { + if (!unseenEffects.isEmpty()) { effect = unseenEffects.get(0); - } - else - { + } else { this.seenList.clear(); - if (!effects.isEmpty()) - { + if (!effects.isEmpty()) { effect = effects.get(0); } } - if (effect != null) - { + if (effect != null) { this.seenList.add(effect.getId()); } return effect; 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 c4c2770b..414412eb 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 @@ -18,45 +18,37 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements WiredTriggerReset -{ +public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements WiredTriggerReset { public final static WiredTriggerType type = WiredTriggerType.AT_GIVEN_TIME; public int executeTime; public int taskId; - public WiredTriggerAtSetTime(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerAtSetTime(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerAtSetTime(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerAtSetTime(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.executeTime + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - if(set.getString("wired_data").length() >= 1) - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + if (set.getString("wired_data").length() >= 1) { this.executeTime = (Integer.valueOf(set.getString("wired_data"))); } - if(this.executeTime < 500) - { + if (this.executeTime < 500) { this.executeTime = 20 * 500; } this.taskId = 1; @@ -64,21 +56,18 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public void onPickUp() - { + public void onPickUp() { this.executeTime = 0; this.taskId = 0; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -90,36 +79,28 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi message.appendInt(1); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.executeTime = packet.readInt() * 500; @@ -129,8 +110,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public void resetTimer() - { + public void resetTimer() { this.taskId++; Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); 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 ce3426c7..4bcec897 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 @@ -18,45 +18,36 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements WiredTriggerReset -{ +public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements WiredTriggerReset { private static final WiredTriggerType type = WiredTriggerType.AT_GIVEN_TIME; - - private int executeTime; public int taskId; + private int executeTime; - public WiredTriggerAtTimeLong(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerAtTimeLong(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerAtTimeLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerAtTimeLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.executeTime + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - if(set.getString("wired_data").length() >= 1) - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + if (set.getString("wired_data").length() >= 1) { this.executeTime = (Integer.valueOf(set.getString("wired_data"))); } - if(this.executeTime < 500) - { + if (this.executeTime < 500) { this.executeTime = 20 * 500; } this.taskId = 1; @@ -64,21 +55,18 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public void onPickUp() - { + public void onPickUp() { this.executeTime = 0; this.taskId = 0; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -90,36 +78,28 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W message.appendInt(1); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.executeTime = packet.readInt() * 500; @@ -128,8 +108,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public void resetTimer() - { + public void resetTimer() { this.taskId++; Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); 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 f74360ae..a40dd95a 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 @@ -20,59 +20,48 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger -{ +public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_STF; private THashSet items; private String botName = ""; - public WiredTriggerBotReachedFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerBotReachedFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredTriggerBotReachedFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerBotReachedFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - if(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) - { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -82,36 +71,28 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger message.appendInt(0); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.botName = packet.readString(); @@ -120,8 +101,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -129,17 +109,13 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { List bots = room.getBots(this.botName); - for(Bot bot : bots) - { - if(bot.getRoomUnit().equals(roomUnit)) - { - for(Object o : stuff) - { - if(this.items.contains(o)) + for (Bot bot : bots) { + if (bot.getRoomUnit().equals(roomUnit)) { + for (Object o : stuff) { + if (this.items.contains(o)) return true; } } @@ -149,14 +125,11 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(this.botName + ":"); - if(!this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (!this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } @@ -165,33 +138,25 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String[] data = set.getString("wired_data").split(":"); - if(data.length == 1) - { + if (data.length == 1) { this.botName = data[0]; - } - else if(data.length == 2) - { + } else if (data.length == 2) { this.botName = data[0]; String[] items = data[1].split(";"); - for(int i = 0; i < items.length; i++) - { - try - { + for (int i = 0; i < items.length; i++) { + try { HabboItem item = room.getHabboItem(Integer.valueOf(items[i])); if (item != null) this.items.add(item); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -199,8 +164,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.botName = ""; } 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 91cc7483..7da199f7 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 @@ -13,31 +13,26 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger -{ +public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_AVTR; private String botName = ""; - public WiredTriggerBotReachedHabbo(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerBotReachedHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerBotReachedHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerBotReachedHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -52,8 +47,7 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.botName = packet.readString(); @@ -62,42 +56,36 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(stuff.length == 0) + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff.length == 0) return false; List bots = room.getBots(this.botName); - for(Bot bot : bots) - { - if(bot.getRoomUnit().equals(stuff[0])) + for (Bot bot : bots) { + if (bot.getRoomUnit().equals(stuff[0])) return true; } return false; } @Override - public String getWiredData() - { + public String getWiredData() { return this.botName; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.botName = set.getString("wired_data"); } @Override - public void onPickUp() - { + public void onPickUp() { this.botName = ""; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 462ed640..4e446609 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 @@ -13,53 +13,44 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerCollision extends InteractionWiredTrigger -{ +public class WiredTriggerCollision extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.COLLISION; - public WiredTriggerCollision(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerCollision(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerCollision(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerCollision(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return stuff.length > 0 && stuff[0] instanceof HabboItem; } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(0); @@ -74,14 +65,12 @@ public class WiredTriggerCollision extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 973f6e6d..c31b571a 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 @@ -17,44 +17,35 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger -{ +public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED; private THashSet items; private String message = ""; - public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredTriggerFurniStateToggled(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerFurniStateToggled(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(stuff.length >= 1) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff.length >= 1) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) - { - for (Object object : stuff) - { - if (object instanceof WiredEffectType) - { + if (habbo != null) { + for (Object object : stuff) { + if (object instanceof WiredEffectType) { return false; } } - - if (stuff[0] instanceof HabboItem) - { + + if (stuff[0] instanceof HabboItem) { return this.items.contains(stuff[0]); } } @@ -63,16 +54,12 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - if(this.items != null) - { - if (!this.items.isEmpty()) - { - for (HabboItem item : this.items) - { + if (this.items != null) { + if (!this.items.isEmpty()) { + for (HabboItem item : this.items) { wiredData.append(item.getId()).append(";"); } } else @@ -83,19 +70,15 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); - if(wiredData.split(":").length >= 3) - { + if (wiredData.split(":").length >= 3) { super.setDelay(Integer.valueOf(wiredData.split(":")[0])); this.message = wiredData.split(":")[1]; - if (!wiredData.split(":")[2].equals("\t")) - { - for (String s : wiredData.split(":")[2].split(";")) - { + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) @@ -106,47 +89,39 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.message = ""; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - for(HabboItem item : this.items) - { - if(item.getRoomId() != this.getRoomId()) - { + for (HabboItem item : this.items) { + if (item.getRoomId() != this.getRoomId()) { items.add(item); continue; } - if (room.getHabboItem(item.getId()) == null) - { + if (room.getHabboItem(item.getId()) == null) { items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -159,8 +134,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); packet.readString(); @@ -168,8 +142,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -177,8 +150,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 7b16168a..abb84177 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 @@ -15,52 +15,43 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerGameEnds extends InteractionWiredTrigger -{ +public class WiredTriggerGameEnds extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.GAME_ENDS; - public WiredTriggerGameEnds(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerGameEnds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerGameEnds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerGameEnds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -71,36 +62,28 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger message.appendInt(0); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } } 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 37c66b75..5631cb46 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 @@ -15,52 +15,43 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerGameStarts extends InteractionWiredTrigger -{ +public class WiredTriggerGameStarts extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.GAME_STARTS; - public WiredTriggerGameStarts(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerGameStarts(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerGameStarts(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerGameStarts(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -71,36 +62,28 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger message.appendInt(0); message.appendInt(this.type.code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } } 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 a63e0cc2..69175e52 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 @@ -12,31 +12,25 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger -{ +public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { public static final WiredTriggerType type = WiredTriggerType.ENTER_ROOM; private String username = ""; - public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboEntersRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboEntersRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if(this.username.length() > 0) - { + if (habbo != null) { + if (this.username.length() > 0) { return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.username); } @@ -46,32 +40,27 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { return this.username; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.username = set.getString("wired_data"); } @Override - public void onPickUp() - { + public void onPickUp() { this.username = ""; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -86,8 +75,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.username = packet.readString(); @@ -95,8 +83,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java index 297fbd5f..e1e96145 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java @@ -13,53 +13,44 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboIdle extends InteractionWiredTrigger -{ +public class WiredTriggerHabboIdle extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.IDLES; - public WiredTriggerHabboIdle(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboIdle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboIdle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboIdle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return stuff.length > 0 && stuff[0] instanceof Habbo; } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(0); @@ -74,14 +65,12 @@ public class WiredTriggerHabboIdle extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java index 5efdbf6a..c0cc60d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java @@ -15,36 +15,28 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger -{ +public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.SAY_COMMAND; private boolean ownerOnly = false; private String key = ""; - public WiredTriggerHabboSaysCommand(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboSaysCommand(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboSaysCommand(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboSaysCommand(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if (this.key.length() > 0) - { - if (stuff[0] instanceof String) - { - if (((String) stuff[0]).replace(":", "").startsWith(this.key + " ")) - { + if (habbo != null) { + if (this.key.length() > 0) { + if (stuff[0] instanceof String) { + if (((String) stuff[0]).replace(":", "").startsWith(this.key + " ")) { if (this.ownerOnly && room.getOwnerId() != habbo.getHabboInfo().getId()) return false; @@ -59,39 +51,33 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { return (this.ownerOnly ? "1" : "0") + "\t" + this.key; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if(data.length == 2) - { + if (data.length == 2) { this.ownerOnly = data[0].equalsIgnoreCase("1"); this.setKey(data[1]); } } @Override - public void onPickUp() - { + public void onPickUp() { this.ownerOnly = false; this.key = ""; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -106,8 +92,7 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.ownerOnly = packet.readInt() == 1; setKey(packet.readString()); @@ -116,10 +101,8 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger return true; } - private void setKey(String key) - { - if (key.contains(":")) - { + private void setKey(String key) { + if (key.contains(":")) { key = key.replaceAll(":", ""); } @@ -127,8 +110,7 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 86f7d2c1..9a98f41c 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 @@ -12,36 +12,28 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger -{ +public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.SAY_SOMETHING; private boolean ownerOnly = false; private String key = ""; - public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo != null) - { - if (this.key.length() > 0) - { - if (stuff[0] instanceof String) - { - if (((String) stuff[0]).toLowerCase().contains(this.key.toLowerCase())) - { + if (habbo != null) { + if (this.key.length() > 0) { + if (stuff[0] instanceof String) { + if (((String) stuff[0]).toLowerCase().contains(this.key.toLowerCase())) { return !this.ownerOnly || room.getOwnerId() == habbo.getHabboInfo().getId(); } } @@ -51,39 +43,33 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { return (this.ownerOnly ? "1" : "0") + "\t" + this.key; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { String[] data = set.getString("wired_data").split("\t"); - if(data.length == 2) - { + if (data.length == 2) { this.ownerOnly = data[0].equalsIgnoreCase("1"); this.key = data[1]; } } @Override - public void onPickUp() - { + public void onPickUp() { this.ownerOnly = false; this.key = ""; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -98,8 +84,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.ownerOnly = packet.readInt() == 1; this.key = packet.readString(); @@ -108,8 +93,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java index 78ff2b8b..f3622f82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java @@ -8,27 +8,22 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboStartsDancing extends WiredTriggerCollision -{ - public WiredTriggerHabboStartsDancing(ResultSet set, Item baseItem) throws SQLException - { +public class WiredTriggerHabboStartsDancing extends WiredTriggerCollision { + public WiredTriggerHabboStartsDancing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboStartsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboStartsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return WiredTriggerType.STARTS_DANCING; } - + @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java index 5e21ea86..cea8333c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java @@ -8,27 +8,22 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboStopsDancing extends WiredTriggerCollision -{ - public WiredTriggerHabboStopsDancing(ResultSet set, Item baseItem) throws SQLException - { +public class WiredTriggerHabboStopsDancing extends WiredTriggerCollision { + public WiredTriggerHabboStopsDancing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboStopsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboStopsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return WiredTriggerType.STOPS_DANCING; } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java index f93f9388..2ed298fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java @@ -13,53 +13,44 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboUnidle extends InteractionWiredTrigger -{ +public class WiredTriggerHabboUnidle extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.IDLES; - public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboUnidle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboUnidle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return stuff.length > 0 && stuff[0] instanceof Habbo; } @Override - public String getWiredData() - { + public String getWiredData() { return ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { } @Override - public void onPickUp() - { + public void onPickUp() { } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(0); @@ -74,14 +65,12 @@ public class WiredTriggerHabboUnidle extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { return true; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } \ No newline at end of file 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 4fcca920..0e05ba01 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 @@ -17,32 +17,26 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger -{ +public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI; private THashSet items; private String message = ""; - public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredTriggerHabboWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(stuff.length >= 1) - { - if (stuff[0] instanceof HabboItem) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff.length >= 1) { + if (stuff[0] instanceof HabboItem) { return this.items.contains(stuff[0]); } } @@ -50,59 +44,45 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - if(!this.items.isEmpty()) - { + if (!this.items.isEmpty()) { List toRemove = new ArrayList<>(0); - for (HabboItem item : this.items) - { - if (item.getRoomId() == this.getRoomId()) - { + for (HabboItem item : this.items) { + if (item.getRoomId() == this.getRoomId()) { wiredData.append(item.getId()).append(";"); - } - else - { + } else { toRemove.add(item); } } this.items.removeAll(toRemove); - } - else + } else wiredData.append("\t"); return wiredData.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); - if(wiredData.split(":").length >= 3) - { + if (wiredData.split(":").length >= 3) { super.setDelay(Integer.valueOf(wiredData.split(":")[0])); this.message = wiredData.split(":")[1]; - if (!wiredData.split(":")[2].equals("\t")) - { - for (String s : wiredData.split(":")[2].split(";")) - { - if(s.isEmpty()) + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) continue; - try - { + try { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) this.items.add(item); - } - catch (Exception e) - { + } catch (Exception e) { } } } @@ -111,46 +91,37 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.message = ""; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - if(room == null) - { + if (room == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (room.getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -164,8 +135,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); packet.readString(); @@ -173,8 +143,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -182,8 +151,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 62403d61..1ebad4c9 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 @@ -17,32 +17,26 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger -{ +public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { public static final WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI; private THashSet items; private String message = ""; - public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); } - public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.items = new THashSet<>(); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if(stuff.length >= 1) - { - if (stuff[0] instanceof HabboItem) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff.length >= 1) { + if (stuff[0] instanceof HabboItem) { return this.items.contains(stuff[0]); } } @@ -50,39 +44,31 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { THashSet items = new THashSet<>(); - if(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) - { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) { items.addAll(this.items); - } - else - { - for (HabboItem item : this.items) - { + } else { + for (HabboItem item : this.items) { if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) items.add(item); } } - for(HabboItem item : items) - { + for (HabboItem item : items) { this.items.remove(item); } message.appendBoolean(false); message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); message.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { message.appendInt(item.getId()); } message.appendInt(this.getBaseItem().getSpriteId()); @@ -96,8 +82,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); packet.readString(); @@ -105,8 +90,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger int count = packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); } @@ -114,59 +98,45 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - if(!this.items.isEmpty()) - { + if (!this.items.isEmpty()) { List toRemove = new ArrayList<>(0); - for (HabboItem item : this.items) - { - if (item.getRoomId() == this.getRoomId()) - { + for (HabboItem item : this.items) { + if (item.getRoomId() == this.getRoomId()) { wiredData.append(item.getId()).append(";"); - } - else - { + } else { toRemove.add(item); } } this.items.removeAll(toRemove); - } - else + } else wiredData.append("\t"); return wiredData.toString(); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); - if(wiredData.split(":").length >= 3) - { + if (wiredData.split(":").length >= 3) { super.setDelay(Integer.valueOf(wiredData.split(":")[0])); this.message = wiredData.split(":")[1]; - if (!wiredData.split(":")[2].equals("\t")) - { - for (String s : wiredData.split(":")[2].split(";")) - { - if(s.isEmpty()) + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) continue; - try - { + try { HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) this.items.add(item); - } - catch (Exception e) - { + } catch (Exception e) { } } } @@ -174,15 +144,13 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger } @Override - public void onPickUp() - { + public void onPickUp() { this.items.clear(); this.message = ""; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } 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 f5be7c01..4476c515 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 @@ -17,66 +17,55 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable -{ +public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable { public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY; public static final int DEFAULT_DELAY = 20 * 500; protected int repeatTime = DEFAULT_DELAY; protected int counter = 0; - public WiredTriggerRepeater(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerRepeater(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerRepeater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerRepeater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.repeatTime + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - if(set.getString("wired_data").length() >= 1) - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + if (set.getString("wired_data").length() >= 1) { this.repeatTime = (Integer.valueOf(set.getString("wired_data"))); } - if(this.repeatTime < 500) - { + if (this.repeatTime < 500) { this.repeatTime = 20 * 500; } } @Override - public void onPickUp() - { + public void onPickUp() { this.repeatTime = DEFAULT_DELAY; this.counter = 0; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -88,43 +77,34 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy message.appendInt(0); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.repeatTime = packet.readInt() * 500; this.counter = 0; - if (this.repeatTime < 500) - { + if (this.repeatTime < 500) { this.repeatTime = 500; } @@ -132,16 +112,12 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public void cycle(Room room) - { + public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) - { + if (this.counter >= this.repeatTime) { this.counter = 0; - if (this.getRoomId() != 0) - { - if (room.isLoaded()) - { + if (this.getRoomId() != 0) { + if (room.isLoaded()) { WiredHandler.handle(this, null, room, new Object[]{this}); } } 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 9598575d..5a0df5a1 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 @@ -17,64 +17,53 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable -{ - private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG; +public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable { public static final int DEFAULT_DELAY = 20 * 5000; + private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG; private int repeatTime = DEFAULT_DELAY; private int counter = 0; - public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerRepeaterLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerRepeaterLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return true; } @Override - public String getWiredData() - { + public String getWiredData() { return this.repeatTime + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - if(set.getString("wired_data").length() >= 1) - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + if (set.getString("wired_data").length() >= 1) { this.repeatTime = (Integer.valueOf(set.getString("wired_data"))); } - if(this.repeatTime < 5000) - { + if (this.repeatTime < 5000) { this.repeatTime = 20 * 5000; } } @Override - public void onPickUp() - { + public void onPickUp() { this.repeatTime = DEFAULT_DELAY; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -86,36 +75,28 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements message.appendInt(0); message.appendInt(this.getType().code); - if (!this.isTriggeredByRoomUnit()) - { + if (!this.isTriggeredByRoomUnit()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() - { + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { @Override - public boolean execute(InteractionWiredEffect object) - { - if (object.requiresTriggeringUser()) - { + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { invalidTriggers.add(object.getBaseItem().getSpriteId()); } return true; } }); message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) - { + for (Integer i : invalidTriggers) { message.appendInt(i); } - } - else - { + } else { message.appendInt(0); } } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.repeatTime = packet.readInt() * 5000; @@ -125,16 +106,12 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override - public void cycle(Room room) - { + public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) - { + if (this.counter >= this.repeatTime) { this.counter = 0; - if (this.getRoomId() != 0) - { - if (room.isLoaded()) - { + if (this.getRoomId() != 0) { + if (room.isLoaded()) { WiredHandler.handle(this, null, room, new Object[]{this}); } } 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 198c0214..b8fc74dd 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 @@ -11,28 +11,23 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerScoreAchieved extends InteractionWiredTrigger -{ +public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.SCORE_ACHIEVED; private int score = 0; - public WiredTriggerScoreAchieved(ResultSet set, Item baseItem) throws SQLException - { + public WiredTriggerScoreAchieved(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerScoreAchieved(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerScoreAchieved(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) - { - if (stuff.length >= 2) - { - int points = (Integer)stuff[0]; - int amountAdded = (Integer)stuff[1]; + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if (stuff.length >= 2) { + int points = (Integer) stuff[0]; + int amountAdded = (Integer) stuff[1]; return points - amountAdded < this.score && points >= this.score; } @@ -41,36 +36,30 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger } @Override - public String getWiredData() - { + public String getWiredData() { return this.score + ""; } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException - { - try - { + public void loadWiredData(ResultSet set, Room room) throws SQLException { + try { this.score = Integer.valueOf(set.getString("wired_data")); + } catch (Exception e) { } - catch (Exception e){} } @Override - public void onPickUp() - { + public void onPickUp() { this.score = 0; } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) - { + public void serializeWiredData(ServerMessage message, Room room) { message.appendBoolean(false); message.appendInt(5); message.appendInt(0); @@ -86,16 +75,14 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger } @Override - public boolean saveData(ClientMessage packet) - { + public boolean saveData(ClientMessage packet) { packet.readInt(); this.score = packet.readInt(); return true; } @Override - public boolean isTriggeredByRoomUnit() - { + public boolean isTriggeredByRoomUnit() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java index c9af9c5e..feee2674 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java @@ -6,21 +6,17 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerTeamLoses extends WiredTriggerGameStarts -{ - public WiredTriggerTeamLoses(ResultSet set, Item baseItem) throws SQLException - { +public class WiredTriggerTeamLoses extends WiredTriggerGameStarts { + public WiredTriggerTeamLoses(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerTeamLoses(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerTeamLoses(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return WiredTriggerType.CUSTOM; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java index 7f69d515..afe8124c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java @@ -6,21 +6,17 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerTeamWins extends WiredTriggerGameStarts -{ - public WiredTriggerTeamWins(ResultSet set, Item baseItem) throws SQLException - { +public class WiredTriggerTeamWins extends WiredTriggerGameStarts { + public WiredTriggerTeamWins(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerTeamWins(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public WiredTriggerTeamWins(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override - public WiredTriggerType getType() - { + public WiredTriggerType getType() { return WiredTriggerType.CUSTOM; } } \ No newline at end of file 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 fb57d26b..705fdae2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/FriendRequest.java @@ -3,38 +3,32 @@ package com.eu.habbo.habbohotel.messenger; import java.sql.ResultSet; import java.sql.SQLException; -public class FriendRequest -{ +public class FriendRequest { private int id; private String username; private String look; - public FriendRequest(ResultSet set) throws SQLException - { + public FriendRequest(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.username = set.getString("username"); this.look = set.getString("look"); } - public FriendRequest(int id, String username, String look) - { + public FriendRequest(int id, String username, String look) { this.id = id; this.username = username; this.look = look; } - public int getId() - { + public int getId() { return this.id; } - public String getUsername() - { + public String getUsername() { return this.username; } - public String getLook() - { + 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 165575d4..8953c439 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java @@ -6,15 +6,13 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class Message implements Runnable -{ +public class Message implements Runnable { private final int fromId; private final int toId; - private String message; private final int timestamp; + private String message; - public Message(int fromId, int toId, String message) - { + public Message(int fromId, int toId, String message) { this.fromId = fromId; this.toId = toId; this.message = message; @@ -23,28 +21,22 @@ public class Message implements Runnable } @Override - public void run() - { + public void run() { //TODO Turn into scheduler - if(Messenger.SAVE_PRIVATE_CHATS) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO chatlogs_private (user_from_id, user_to_id, message, timestamp) VALUES (?, ?, ?, ?)")) - { + if (Messenger.SAVE_PRIVATE_CHATS) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO chatlogs_private (user_from_id, user_to_id, message, timestamp) VALUES (?, ?, ?, ?)")) { statement.setInt(1, this.fromId); statement.setInt(2, this.toId); statement.setString(3, this.message); statement.setInt(4, this.timestamp); statement.execute(); - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public int getToId() - { + public int getToId() { return this.toId; } @@ -56,8 +48,7 @@ public class Message implements Runnable return this.message; } - public void setMessage(String message) - { + public void setMessage(String message) { this.message = message; } 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 5f4c1f48..06d4e37d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -19,8 +19,7 @@ import java.sql.SQLException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class Messenger -{ +public class Messenger { //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_PRIVATE_CHATS = false; public static int MAXIMUM_FRIENDS = 200; @@ -29,176 +28,271 @@ public class Messenger private final ConcurrentHashMap friends; private final THashSet friendRequests; - public Messenger() - { + public Messenger() { this.friends = new ConcurrentHashMap<>(); this.friendRequests = new THashSet<>(); } - public void loadFriends(Habbo habbo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("SELECT " + - "users.id, " + - "users.username, " + - "users.gender, " + - "users.online, " + - "users.look, " + - "users.motto, " + - "messenger_friendships.* FROM messenger_friendships INNER JOIN users ON messenger_friendships.user_two_id = users.id WHERE user_one_id = ?")) - { - statement.setInt(1, habbo.getHabboInfo().getId()); - - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - this.friends.putIfAbsent(set.getInt("id"), new MessengerBuddy(set)); - } - } - } - catch(SQLException e) - { + public static void unfriend(int userOne, int userTwo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendships WHERE (user_one_id = ? AND user_two_id = ?) OR (user_one_id = ? AND user_two_id = ?)")) { + statement.setInt(1, userOne); + statement.setInt(2, userTwo); + statement.setInt(3, userTwo); + statement.setInt(4, userOne); + statement.execute(); + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public MessengerBuddy loadFriend(Habbo habbo, int userId) - { + public static THashSet searchUsers(String username) { + THashSet users = new THashSet<>(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username LIKE ? ORDER BY username ASC LIMIT " + Emulator.getConfig().getInt("hotel.messenger.search.maxresults"))) { + statement.setString(1, username + "%"); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + users.add(new MessengerBuddy(set, false)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + return users; + } + + public static boolean canFriendRequest(Habbo habbo, String friend) { + Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(friend); + HabboInfo habboInfo; + + if (user != null) { + habboInfo = user.getHabboInfo(); + } else { + habboInfo = HabboManager.getOfflineHabboInfo(friend); + } + + if (habboInfo == null) { + return false; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_friendrequests WHERE (user_to_id = ? AND user_from_id = ?) OR (user_to_id = ? AND user_from_id = ?) LIMIT 1")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + statement.setInt(2, habboInfo.getId()); + statement.setInt(3, habboInfo.getId()); + statement.setInt(4, habbo.getHabboInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + if (!set.next()) { + return true; + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return false; + } + + public static boolean friendRequested(int userFrom, int userTo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_friendrequests WHERE user_to_id = ? AND user_from_id = ? LIMIT 1")) { + statement.setInt(1, userFrom); + statement.setInt(2, userTo); + + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + return true; + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return false; + } + + public static void makeFriendRequest(int userFrom, int userTo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO messenger_friendrequests (user_to_id, user_from_id) VALUES (?, ?)")) { + statement.setInt(1, userTo); + statement.setInt(2, userFrom); + statement.executeUpdate(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public static int getFriendCount(int userId) { + Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(userId); + + if (habbo != null) + return habbo.getMessenger().getFriends().size(); + + int count = 0; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT count(id) as count FROM messenger_friendships WHERE user_one_id = ?")) { + statement.setInt(1, userId); + try (ResultSet set = statement.executeQuery()) { + if (set.next()) + count = set.getInt("count"); + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return count; + } + + public static THashMap> getFriends(int userId) { + THashMap> map = new THashMap<>(); + map.put(1, new THashSet<>()); + map.put(2, new THashSet<>()); + map.put(3, new THashSet<>()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.id, users.look, users.username, messenger_friendships.relation FROM messenger_friendships INNER JOIN users ON users.id = messenger_friendships.user_two_id WHERE user_one_id = ? ORDER BY RAND() LIMIT 50")) { + statement.setInt(1, userId); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (set.getInt("relation") == 0) + continue; + + MessengerBuddy buddy = new MessengerBuddy(set.getInt("id"), set.getString("username"), set.getString("look"), (short) set.getInt("relation"), userId); + map.get((int) buddy.getRelation()).add(buddy); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + return map; + } + + public static int friendLimit(Habbo habbo) { + if (habbo.hasPermission("acc_infinite_friends")) { + return Integer.MAX_VALUE; + } + + if (habbo.getHabboStats().hasActiveClub()) { + return MAXIMUM_FRIENDS_HC; + } + + return MAXIMUM_FRIENDS; + } + + public static void checkFriendSizeProgress(Habbo habbo) { + int progress = habbo.getHabboStats().getAchievementProgress(Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize")); + + int toProgress = 1; + + Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize"); + + if (achievement == null) + return; + + if (progress > 0) { + toProgress = habbo.getMessenger().getFriends().size() - progress; + + if (toProgress < 0) { + return; + } + } + + AchievementManager.progressAchievement(habbo, achievement, toProgress); + } + + public void loadFriends(Habbo habbo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT " + + "users.id, " + + "users.username, " + + "users.gender, " + + "users.online, " + + "users.look, " + + "users.motto, " + + "messenger_friendships.* FROM messenger_friendships INNER JOIN users ON messenger_friendships.user_two_id = users.id WHERE user_one_id = ?")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.friends.putIfAbsent(set.getInt("id"), new MessengerBuddy(set)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public MessengerBuddy loadFriend(Habbo habbo, int userId) { MessengerBuddy buddy = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT " + - "users.id, " + - "users.username, " + - "users.gender, " + - "users.online, " + - "users.look, " + - "users.motto, " + - "messenger_friendships.* FROM messenger_friendships INNER JOIN users ON messenger_friendships.user_two_id = users.id WHERE user_one_id = ? AND user_two_id = ? LIMIT 1")) - { + "users.id, " + + "users.username, " + + "users.gender, " + + "users.online, " + + "users.look, " + + "users.motto, " + + "messenger_friendships.* FROM messenger_friendships INNER JOIN users ON messenger_friendships.user_two_id = users.id WHERE user_one_id = ? AND user_two_id = ? LIMIT 1")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, userId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { buddy = new MessengerBuddy(set); this.friends.putIfAbsent(set.getInt("id"), buddy); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return buddy; } - public void loadFriendRequests(Habbo habbo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.id, users.username, users.look FROM messenger_friendrequests INNER JOIN users ON user_from_id = users.id WHERE user_to_id = ?")) - { + public void loadFriendRequests(Habbo habbo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.id, users.username, users.look FROM messenger_friendrequests INNER JOIN users ON user_from_id = users.id WHERE user_to_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while(set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.friendRequests.add(new FriendRequest(set)); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void removeBuddy(int id) - { + public void removeBuddy(int id) { this.friends.remove(id); } - public void removeBuddy(Habbo habbo) - { + public void removeBuddy(Habbo habbo) { this.friends.remove(habbo.getHabboInfo().getId()); } - public void addBuddy(MessengerBuddy buddy) - { + public void addBuddy(MessengerBuddy buddy) { this.friends.put(buddy.getId(), buddy); } - public static void unfriend(int userOne, int userTwo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendships WHERE (user_one_id = ? AND user_two_id = ?) OR (user_one_id = ? AND user_two_id = ?)")) - { - statement.setInt(1, userOne); - statement.setInt(2, userTwo); - statement.setInt(3, userTwo); - statement.setInt(4, userOne); - statement.execute(); - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - } - - public THashSet getFriends(String username) - { + public THashSet getFriends(String username) { THashSet users = new THashSet<>(); - for(Map.Entry map : this.friends.entrySet()) - { - if(StringUtils.containsIgnoreCase(map.getValue().getUsername(), username)) - { + for (Map.Entry map : this.friends.entrySet()) { + if (StringUtils.containsIgnoreCase(map.getValue().getUsername(), username)) { users.add(map.getValue()); } } return users; } - public static THashSet searchUsers(String username) - { - THashSet users = new THashSet<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username LIKE ? ORDER BY username ASC LIMIT " + Emulator.getConfig().getInt("hotel.messenger.search.maxresults"))) - { - statement.setString(1, username + "%"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - users.add(new MessengerBuddy(set, false)); - } - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - return users; - } - public void connectionChanged(Habbo owner, boolean online, boolean inRoom) - { - if(owner != null) - { - for (Map.Entry map : this.getFriends().entrySet()) - { + public void connectionChanged(Habbo owner, boolean online, boolean inRoom) { + if (owner != null) { + for (Map.Entry map : this.getFriends().entrySet()) { if (map.getValue().getOnline() == 0) continue; Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(map.getKey()); - if (habbo != null) - { - if (habbo.getMessenger() != null) - { + if (habbo != null) { + if (habbo.getMessenger() != null) { MessengerBuddy buddy = habbo.getMessenger().getFriend(owner.getHabboInfo().getId()); - if (buddy != null) - { + if (buddy != null) { buddy.setOnline(online); buddy.inRoom(inRoom); buddy.setLook(owner.getHabboInfo().getLook()); @@ -212,45 +306,35 @@ public class Messenger } } - public void deleteAllFriendRequests(int userTo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendrequests WHERE user_to_id = ?")) - { + public void deleteAllFriendRequests(int userTo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendrequests WHERE user_to_id = ?")) { statement.setInt(1, userTo); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public int deleteFriendRequests(int userFrom, int userTo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendrequests WHERE (user_to_id = ? AND user_from_id = ?) OR (user_to_id = ? AND user_from_id = ?)")) - { + public int deleteFriendRequests(int userFrom, int userTo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendrequests WHERE (user_to_id = ? AND user_from_id = ?) OR (user_to_id = ? AND user_from_id = ?)")) { statement.setInt(1, userTo); statement.setInt(2, userFrom); statement.setInt(4, userTo); statement.setInt(3, userFrom); return statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return 0; } + //TODO Needs redesign. userFrom is redundant. - public void acceptFriendRequest(int userFrom, int userTo) - { + public void acceptFriendRequest(int userFrom, int userTo) { int count = this.deleteFriendRequests(userFrom, userTo); - if(count > 0) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO messenger_friendships (user_one_id, user_two_id, friends_since) VALUES (?, ?, ?)")) - { + if (count > 0) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO messenger_friendships (user_one_id, user_two_id, friends_since) VALUES (?, ?, ?)")) { statement.setInt(1, userFrom); statement.setInt(2, userTo); statement.setInt(3, Emulator.getIntUnixTimestamp()); @@ -260,17 +344,14 @@ public class Messenger statement.setInt(2, userFrom); statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } Habbo habboTo = Emulator.getGameServer().getGameClientManager().getHabbo(userTo); Habbo habboFrom = Emulator.getGameServer().getGameClientManager().getHabbo(userFrom); - if(habboTo != null && habboFrom != null) - { + if (habboTo != null && habboFrom != null) { MessengerBuddy to = new MessengerBuddy(habboFrom, habboTo.getHabboInfo().getId()); MessengerBuddy from = new MessengerBuddy(habboTo, habboFrom.getHabboInfo().getId()); @@ -278,180 +359,35 @@ public class Messenger habboTo.getMessenger().friends.putIfAbsent(habboFrom.getHabboInfo().getId(), to); habboFrom.getMessenger().friends.putIfAbsent(habboTo.getHabboInfo().getId(), from); - if(Emulator.getPluginManager().fireEvent(new UserAcceptFriendRequestEvent(habboTo, from)).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(new UserAcceptFriendRequestEvent(habboTo, from)).isCancelled()) { this.removeBuddy(userTo); return; } habboTo.getClient().sendResponse(new UpdateFriendComposer(to)); habboFrom.getClient().sendResponse(new UpdateFriendComposer(from)); - } - else if (habboTo != null) - { + } else if (habboTo != null) { habboTo.getClient().sendResponse(new UpdateFriendComposer(this.loadFriend(habboTo, userFrom))); - } - else if (habboFrom != null) - { + } else if (habboFrom != null) { habboFrom.getClient().sendResponse(new UpdateFriendComposer(this.loadFriend(habboFrom, userTo))); } } } - public static boolean canFriendRequest(Habbo habbo, String friend) - { - Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(friend); - HabboInfo habboInfo; - - if(user != null) - { - habboInfo = user.getHabboInfo(); - } - else - { - habboInfo = HabboManager.getOfflineHabboInfo(friend); - } - - if(habboInfo == null) - { - return false; - } - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_friendrequests WHERE (user_to_id = ? AND user_from_id = ?) OR (user_to_id = ? AND user_from_id = ?) LIMIT 1")) - { - statement.setInt(1, habbo.getHabboInfo().getId()); - statement.setInt(2, habboInfo.getId()); - statement.setInt(3, habboInfo.getId()); - statement.setInt(4, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - if (!set.next()) - { - return true; - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return false; - } - - public static boolean friendRequested(int userFrom, int userTo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_friendrequests WHERE user_to_id = ? AND user_from_id = ? LIMIT 1")) - { - statement.setInt(1, userFrom); - statement.setInt(2, userTo); - - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - return true; - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return false; - } - - public static void makeFriendRequest(int userFrom, int userTo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO messenger_friendrequests (user_to_id, user_from_id) VALUES (?, ?)")) - { - statement.setInt(1, userTo); - statement.setInt(2, userFrom); - statement.executeUpdate(); - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - } - - public static int getFriendCount(int userId) - { - Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(userId); - - if(habbo != null) - return habbo.getMessenger().getFriends().size(); - - int count = 0; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT count(id) as count FROM messenger_friendships WHERE user_one_id = ?")) - { - statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - count = set.getInt("count"); - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return count; - } - - public static THashMap> getFriends(int userId) - { - THashMap> map = new THashMap<>(); - map.put(1, new THashSet<>()); - map.put(2, new THashSet<>()); - map.put(3, new THashSet<>()); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.id, users.look, users.username, messenger_friendships.relation FROM messenger_friendships INNER JOIN users ON users.id = messenger_friendships.user_two_id WHERE user_one_id = ? ORDER BY RAND() LIMIT 50")) - { - statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - if (set.getInt("relation") == 0) - continue; - - MessengerBuddy buddy = new MessengerBuddy(set.getInt("id"), set.getString("username"), set.getString("look"), (short) set.getInt("relation"), userId); - map.get((int) buddy.getRelation()).add(buddy); - } - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - return map; - } - - public ConcurrentHashMap getFriends() - { + public ConcurrentHashMap getFriends() { return this.friends; } - public THashSet getFriendRequests() - { - synchronized (this.friendRequests) - { + public THashSet getFriendRequests() { + synchronized (this.friendRequests) { return this.friendRequests; } } - public FriendRequest findFriendRequest(String username) - { - synchronized (this.friendRequests) - { - for (FriendRequest friendRequest : this.friendRequests) - { - if (friendRequest.getUsername().equalsIgnoreCase(username)) - { + public FriendRequest findFriendRequest(String username) { + synchronized (this.friendRequests) { + for (FriendRequest friendRequest : this.friendRequests) { + if (friendRequest.getUsername().equalsIgnoreCase(username)) { return friendRequest; } } @@ -460,60 +396,17 @@ public class Messenger return null; } - public MessengerBuddy getFriend(int id) - { + public MessengerBuddy getFriend(int id) { return this.friends.get(id); } - public void dispose() - { - synchronized (this.friends) - { - this.friends.clear(); - } - - synchronized (this.friendRequests) - { - this.friendRequests.clear(); - } - } - - public static int friendLimit(Habbo habbo) - { - if (habbo.hasPermission("acc_infinite_friends")) - { - return Integer.MAX_VALUE; + public void dispose() { + synchronized (this.friends) { + this.friends.clear(); } - if (habbo.getHabboStats().hasActiveClub()) - { - return MAXIMUM_FRIENDS_HC; + synchronized (this.friendRequests) { + this.friendRequests.clear(); } - - return MAXIMUM_FRIENDS; - } - - public static void checkFriendSizeProgress(Habbo habbo) - { - int progress = habbo.getHabboStats().getAchievementProgress(Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize")); - - int toProgress = 1; - - Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize"); - - if(achievement == null) - return; - - if (progress > 0) - { - toProgress = habbo.getMessenger().getFriends().size() - progress; - - if(toProgress < 0) - { - return; - } - } - - AchievementManager.progressAchievement(habbo, achievement, toProgress); } } 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 30999fa1..7489fd23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -25,10 +25,8 @@ public class MessengerBuddy implements Runnable, ISerialize { private boolean inRoom; private int userOne = 0; - public MessengerBuddy(ResultSet set) - { - try - { + public MessengerBuddy(ResultSet set) { + try { this.id = set.getInt("id"); this.username = set.getString("username"); this.gender = HabboGender.valueOf(set.getString("gender")); @@ -38,39 +36,30 @@ public class MessengerBuddy implements Runnable, ISerialize { this.relation = (short) set.getInt("relation"); this.userOne = set.getInt("user_one_id"); this.inRoom = false; - if(this.online == 1) - { + if (this.online == 1) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(this.username); - if(habbo != null) - { + if (habbo != null) { this.inRoom = habbo.getHabboInfo().getCurrentRoom() != null; } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public MessengerBuddy(ResultSet set, boolean value) - { - try - { + public MessengerBuddy(ResultSet set, boolean value) { + try { this.id = set.getInt("id"); this.username = set.getString("username"); this.relation = 0; this.userOne = 0; - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public MessengerBuddy(int id, String username, String look, Short relation, int userOne) - { + public MessengerBuddy(int id, String username, String look, Short relation, int userOne) { this.id = id; this.username = username; this.gender = HabboGender.M; @@ -81,8 +70,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.userOne = userOne; } - public MessengerBuddy(Habbo habbo, int userOne) - { + public MessengerBuddy(Habbo habbo, int userOne) { this.id = habbo.getHabboInfo().getId(); this.username = habbo.getHabboInfo().getUsername(); this.gender = habbo.getHabboInfo().getGender(); @@ -94,89 +82,72 @@ public class MessengerBuddy implements Runnable, ISerialize { this.inRoom = habbo.getHabboInfo().getCurrentRoom() != null; } - public void setRelation(int relation) - { - this.relation = (short)relation; - Emulator.getThreading().run(this); - } - - public int getId() - { + public int getId() { return this.id; } - public String getUsername() - { + public String getUsername() { return this.username; } - public void setUsername(String username) - { + public void setUsername(String username) { this.username = username; } - public HabboGender getGender() - { + public HabboGender getGender() { return this.gender; } - public void setGender(HabboGender gender) - { + public void setGender(HabboGender gender) { this.gender = gender; } - public int getOnline() - { + public int getOnline() { return this.online; } - public String getLook() - { + public void setOnline(boolean value) { + this.online = (value ? 1 : 0); + } + + public String getLook() { return this.look; } - public void setLook(String look) - { + public void setLook(String look) { this.look = look; } - public String getMotto() - { + public String getMotto() { return this.motto; } - public short getRelation() - { + public short getRelation() { return this.relation; } - public boolean inRoom() - { + public void setRelation(int relation) { + this.relation = (short) relation; + Emulator.getThreading().run(this); + } + + public boolean inRoom() { return this.inRoom; } - public void inRoom(boolean value) - { + public void inRoom(boolean value) { this.inRoom = value; } - public void setOnline(boolean value) - { - this.online = (value ? 1 : 0); - } - @Override public void run() { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE messenger_friendships SET relation = ? WHERE user_one_id = ? AND user_two_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE messenger_friendships SET relation = ? WHERE user_one_id = ? AND user_two_id = ?")) { statement.setInt(1, this.relation); statement.setInt(2, this.userOne); statement.setInt(3, this.id); statement.execute(); - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -184,14 +155,13 @@ public class MessengerBuddy implements Runnable, ISerialize { public void onMessageReceived(Habbo from, String message) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(this.id); - if(habbo == null) + if (habbo == null) return; Message chatMessage = new Message(from.getHabboInfo().getId(), this.id, message); Emulator.getThreading().run(chatMessage); - if (WordFilter.ENABLED_FRIENDCHAT) - { + if (WordFilter.ENABLED_FRIENDCHAT) { chatMessage.setMessage(Emulator.getGameEnvironment().getWordFilter().filter(chatMessage.getMessage(), from)); } 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 507b1584..2c6f95d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhActionType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.modtool; -public enum CfhActionType -{ +public enum CfhActionType { MODS(0), AUTO_REPLY(1), AUTO_IGNORE(2), @@ -9,21 +8,12 @@ public enum CfhActionType public final int type; - CfhActionType(int type) - { + CfhActionType(int type) { this.type = type; } - @Override - public String toString() - { - return this.name().toLowerCase(); - } - - public static CfhActionType get(String name) - { - switch(name) - { + public static CfhActionType get(String name) { + switch (name) { case "auto_reply": return CfhActionType.AUTO_REPLY; @@ -36,4 +26,9 @@ public enum CfhActionType return CfhActionType.MODS; } + + @Override + public String toString() { + return this.name().toLowerCase(); + } } \ No newline at end of file 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 0bf95135..dfb196da 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhCategory.java @@ -4,31 +4,26 @@ import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -public class CfhCategory -{ +public class CfhCategory { private final int id; private final String name; private final TIntObjectMap topics; - public CfhCategory(int id, String name) - { + public CfhCategory(int id, String name) { this.id = id; this.name = name; this.topics = TCollections.synchronizedMap(new TIntObjectHashMap<>()); } - public void addTopic(CfhTopic topic) - { + public void addTopic(CfhTopic topic) { this.topics.put(topic.id, topic); } - public TIntObjectMap getTopics() - { + public TIntObjectMap getTopics() { return this.topics; } - public String getName() - { + 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 3db7f132..1a7f3bed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/CfhTopic.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.modtool; import java.sql.ResultSet; import java.sql.SQLException; -public class CfhTopic -{ +public class CfhTopic { public final int id; public final String name; public final CfhActionType action; @@ -12,8 +11,7 @@ public class CfhTopic public final String reply; public final ModToolPreset defaultSanction; - public CfhTopic(ResultSet set, ModToolPreset defaultSanction) throws SQLException - { + public CfhTopic(ResultSet set, ModToolPreset defaultSanction) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name_internal"); this.action = CfhActionType.get(set.getString("action")); 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 f5f50a5f..1fc72341 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java @@ -8,8 +8,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; -public class ModToolBan implements Runnable -{ +public class ModToolBan implements Runnable { public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public int userId; public String ip; @@ -23,41 +22,36 @@ public class ModToolBan implements Runnable private boolean needsInsert; - public ModToolBan(ResultSet set) throws SQLException - { - this.userId = set.getInt("user_id"); - this.ip = set.getString("ip"); - this.machineId = set.getString("machine_id"); - this.staffId = set.getInt("user_staff_id"); - this.timestamp = set.getInt("timestamp"); - this.expireDate = set.getInt("ban_expire"); - this.reason = set.getString("ban_reason"); - this.type = ModToolBanType.fromString(set.getString("type")); - this.cfhTopic = set.getInt("cfh_topic"); + public ModToolBan(ResultSet set) throws SQLException { + this.userId = set.getInt("user_id"); + this.ip = set.getString("ip"); + this.machineId = set.getString("machine_id"); + this.staffId = set.getInt("user_staff_id"); + this.timestamp = set.getInt("timestamp"); + this.expireDate = set.getInt("ban_expire"); + this.reason = set.getString("ban_reason"); + this.type = ModToolBanType.fromString(set.getString("type")); + this.cfhTopic = set.getInt("cfh_topic"); this.needsInsert = false; } - public ModToolBan(int userId, String ip, String machineId, int staffId, int expireDate, String reason, ModToolBanType type, int cfhTopic) - { - this.userId = userId; - this.staffId = staffId; - this.timestamp = Emulator.getIntUnixTimestamp(); - this.expireDate = expireDate; - this.reason = reason; - this.ip = ip; - this.machineId = machineId; - this.type = type; - this.cfhTopic = cfhTopic; + public ModToolBan(int userId, String ip, String machineId, int staffId, int expireDate, String reason, ModToolBanType type, int cfhTopic) { + this.userId = userId; + this.staffId = staffId; + this.timestamp = Emulator.getIntUnixTimestamp(); + this.expireDate = expireDate; + this.reason = reason; + this.ip = ip; + this.machineId = machineId; + this.type = type; + this.cfhTopic = cfhTopic; this.needsInsert = true; } @Override - public void run() - { - if(this.needsInsert) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bans (user_id, ip, machine_id, user_staff_id, timestamp, ban_expire, ban_reason, type, cfh_topic) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) - { + public void run() { + if (this.needsInsert) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bans (user_id, ip, machine_id, user_staff_id, timestamp, ban_expire, ban_reason, type, cfh_topic) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { statement.setInt(1, this.userId); statement.setString(2, this.ip); statement.setString(3, this.machineId); @@ -68,16 +62,13 @@ public class ModToolBan implements Runnable statement.setString(8, this.type.getType()); statement.setInt(9, this.cfhTopic); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public String listInfo() - { + public String listInfo() { return "Banned User Id: " + this.userId + "\r" + "Type: " + this.type.getType() + "\r" + "Reason: " + "" + this.reason + "" + "\r" + 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 e9a1c70f..76c0142e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBanType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.modtool; -public enum ModToolBanType -{ +public enum ModToolBanType { ACCOUNT("account"), MACHINE("machine"), SUPER("super"), @@ -10,26 +9,21 @@ public enum ModToolBanType private final String type; - ModToolBanType(String type) - { + ModToolBanType(String type) { this.type = type; } - public String getType() - { - return this.type; - } - - public static ModToolBanType fromString(String type) - { - for (ModToolBanType t : ModToolBanType.values()) - { - if (t.type.equalsIgnoreCase(type)) - { + public static ModToolBanType fromString(String type) { + for (ModToolBanType t : ModToolBanType.values()) { + if (t.type.equalsIgnoreCase(type)) { return t; } } 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 a693acb8..10e28a84 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolCategory.java @@ -4,29 +4,24 @@ import gnu.trove.TCollections; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -public class ModToolCategory -{ +public class ModToolCategory { private final String name; private final TIntObjectMap presets; - public ModToolCategory(String name) - { + public ModToolCategory(String name) { this.name = name; this.presets = TCollections.synchronizedMap(new TIntObjectHashMap<>()); } - public void addPreset(ModToolPreset preset) - { + public void addPreset(ModToolPreset preset) { this.presets.put(preset.id, preset); } - public TIntObjectMap getPresets() - { + public TIntObjectMap getPresets() { return this.presets; } - public String getName() - { + 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 03a99689..8663e27d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java @@ -1,14 +1,12 @@ package com.eu.habbo.habbohotel.modtool; -public class ModToolChatLog implements Comparable -{ +public class ModToolChatLog implements Comparable { public final int timestamp; public final int habboId; public final String username; public final String message; - public ModToolChatLog(int timestamp, int habboId, String username, String message) - { + public ModToolChatLog(int timestamp, int habboId, String username, String message) { this.timestamp = timestamp; this.habboId = habboId; this.username = username; @@ -16,8 +14,7 @@ public class ModToolChatLog implements Comparable } @Override - public int compareTo(ModToolChatLog o) - { + public int compareTo(ModToolChatLog o) { return o.timestamp - this.timestamp; } } 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 488688ff..45a8db9f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java @@ -2,8 +2,7 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.messages.ServerMessage; -public enum ModToolChatRecordDataContext -{ +public enum ModToolChatRecordDataContext { ROOM_NAME("roomName", 2), ROOM_ID("roomId", 1), GROUP_ID("groupId", 1), @@ -13,14 +12,12 @@ public enum ModToolChatRecordDataContext public final String key; public final int type; - ModToolChatRecordDataContext(String key, int type) - { + ModToolChatRecordDataContext(String key, int type) { this.key = key; this.type = type; } - public void append(final ServerMessage message) - { + public void append(final ServerMessage message) { message.appendString(this.key); message.appendByte(this.type); } 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 12013a54..8d08a88f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.modtool; -public enum ModToolChatRecordDataType -{ +public enum ModToolChatRecordDataType { UNKNOWN(0), ROOM_TOOL(1), IM_SESSION(2), @@ -12,8 +11,7 @@ public enum ModToolChatRecordDataType public final int type; - ModToolChatRecordDataType(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 1ce3cbe4..b3cac442 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatlogType.java @@ -1,15 +1,13 @@ package com.eu.habbo.habbohotel.modtool; -public enum ModToolChatlogType -{ +public enum ModToolChatlogType { BOT_PET(0), YELLOW(1), BLUE(2); public final int type; - ModToolChatlogType(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 d13a6c3e..5e73e86c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -9,8 +9,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -public class ModToolIssue implements ISerialize -{ +public class ModToolIssue implements ISerialize { public int id; public volatile ModToolTicketState state; public volatile ModToolTicketType type; @@ -27,8 +26,7 @@ public class ModToolIssue implements ISerialize public String message; public ArrayList chatLogs = null; - public ModToolIssue(ResultSet set) throws SQLException - { + public ModToolIssue(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.state = ModToolTicketState.getState(set.getInt("state")); this.timestamp = set.getInt("timestamp"); @@ -43,15 +41,13 @@ public class ModToolIssue implements ISerialize this.type = ModToolTicketType.values()[set.getInt("type") - 1]; this.category = set.getInt("category"); - if(this.modId <= 0) - { + if (this.modId <= 0) { this.modName = ""; this.state = ModToolTicketState.OPEN; } } - public ModToolIssue(int senderId, String senderUserName, int reportedId, String reportedUsername, int reportedRoomId, String message, ModToolTicketType type) - { + public ModToolIssue(int senderId, String senderUserName, int reportedId, String reportedUsername, int reportedRoomId, String message, ModToolTicketType type) { this.state = ModToolTicketState.OPEN; this.timestamp = Emulator.getIntUnixTimestamp(); this.priority = 0; @@ -66,8 +62,7 @@ public class ModToolIssue implements ISerialize } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.id); //ID message.appendInt(this.state.getState()); //STATE message.appendInt(this.type.getType()); //TYPE @@ -84,24 +79,19 @@ public class ModToolIssue implements ISerialize message.appendString(this.message); message.appendInt(0); - if (this.chatLogs != null) - { + if (this.chatLogs != null) { message.appendInt(this.chatLogs.size()); - for (ModToolChatLog chatLog : this.chatLogs) - { + for (ModToolChatLog chatLog : this.chatLogs) { message.appendString(chatLog.message); message.appendInt(0); message.appendInt(chatLog.message.length()); } - } - else - { + } else { message.appendInt(0); } } - public void updateInDatabase() - { + public void updateInDatabase() { Emulator.getThreading().run(new UpdateModToolIssue(this)); } } 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 081d35b1..18f546b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -28,111 +28,104 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class ModToolManager -{ - private final TIntObjectMap category; +public class ModToolManager { + private final TIntObjectMap category; private final THashMap> presets; - private final THashMap tickets; - private final TIntObjectMap cfhCategories; + private final THashMap tickets; + private final TIntObjectMap cfhCategories; - public ModToolManager() - { - long millis = System.currentTimeMillis(); + public ModToolManager() { + long millis = System.currentTimeMillis(); this.category = TCollections.synchronizedMap(new TIntObjectHashMap<>()); - this.presets = new THashMap<>(); - this.tickets = new THashMap<>(); + this.presets = new THashMap<>(); + this.tickets = new THashMap<>(); this.cfhCategories = new TIntObjectHashMap<>(); this.loadModTool(); Emulator.getLogging().logStart("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public synchronized void loadModTool() - { - this.category.clear(); - this.presets.clear(); - this.cfhCategories.clear(); + public static void requestUserInfo(GameClient client, ClientMessage packet) { + int userId = packet.readInt(); - this.presets.put("user", new THashSet<>()); - this.presets.put("room", new THashSet<>()); + if (userId <= 0) + return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - this.loadCategory(connection); - this.loadPresets(connection); - this.loadTickets(connection); - this.loadCfhCategories(connection); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.*, users_settings.*, permissions.rank_name, permissions.id as rank_id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id INNER JOIN permissions ON permissions.id = users.rank WHERE users.id = ? LIMIT 1")) { + statement.setInt(1, userId); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + client.sendResponse(new ModToolUserInfoComposer(set)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } } - private void loadCategory(Connection connection) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM support_issue_categories")) - { - while(set.next()) - { + public synchronized void loadModTool() { + this.category.clear(); + this.presets.clear(); + this.cfhCategories.clear(); + + this.presets.put("user", new THashSet<>()); + this.presets.put("room", new THashSet<>()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + this.loadCategory(connection); + this.loadPresets(connection); + this.loadTickets(connection); + this.loadCfhCategories(connection); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + private void loadCategory(Connection connection) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM support_issue_categories")) { + while (set.next()) { this.category.put(set.getInt("id"), new ModToolCategory(set.getString("name"))); - try (PreparedStatement settings = connection.prepareStatement("SELECT * FROM support_issue_presets WHERE category = ?")) - { + try (PreparedStatement settings = connection.prepareStatement("SELECT * FROM support_issue_presets WHERE category = ?")) { settings.setInt(1, set.getInt("id")); - try (ResultSet presets = settings.executeQuery()) - { - while (presets.next()) - { + try (ResultSet presets = settings.executeQuery()) { + while (presets.next()) { this.category.get(set.getInt("id")).addPreset(new ModToolPreset(presets)); } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadPresets(Connection connection) - { - synchronized (this.presets) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM support_presets")) - { - while (set.next()) - { + private void loadPresets(Connection connection) { + synchronized (this.presets) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM support_presets")) { + while (set.next()) { this.presets.get(set.getString("type")).add(set.getString("preset")); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - private void loadTickets(Connection connection) - { - synchronized (this.tickets) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT S.username as sender_username, R.username AS reported_username, M.username as mod_username, support_tickets.* FROM support_tickets INNER JOIN users as S ON S.id = sender_id INNER JOIN users AS R ON R.id = reported_id INNER JOIN users AS M ON M.id = mod_id WHERE state != 0")) - { - while(set.next()) - { + private void loadTickets(Connection connection) { + synchronized (this.tickets) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT S.username as sender_username, R.username AS reported_username, M.username as mod_username, support_tickets.* FROM support_tickets INNER JOIN users as S ON S.id = sender_id INNER JOIN users AS R ON R.id = reported_id INNER JOIN users AS M ON M.id = mod_id WHERE state != 0")) { + while (set.next()) { this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - private void loadCfhCategories(Connection connection) - { + private void loadCfhCategories(Connection connection) { try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT " + "support_cfh_topics.id, " + "support_cfh_topics.category_id, " + @@ -144,32 +137,23 @@ public class ModToolManager "support_cfh_categories.id AS support_cfh_category_id, " + "support_cfh_topics.default_sanction AS default_sanction " + "FROM support_cfh_topics " + - "LEFT JOIN support_cfh_categories ON support_cfh_categories.id = support_cfh_topics.category_id")) - { - while(set.next()) - { - if (!this.cfhCategories.containsKey(set.getInt("support_cfh_category_id"))) - { + "LEFT JOIN support_cfh_categories ON support_cfh_categories.id = support_cfh_topics.category_id")) { + while (set.next()) { + if (!this.cfhCategories.containsKey(set.getInt("support_cfh_category_id"))) { this.cfhCategories.put(set.getInt("support_cfh_category_id"), new CfhCategory(set.getInt("id"), set.getString("category_name_internal"))); } this.cfhCategories.get(set.getInt("support_cfh_category_id")).addTopic(new CfhTopic(set, this.getIssuePreset(set.getInt("default_sanction")))); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public CfhTopic getCfhTopic(int topicId) - { - for(CfhCategory category : this.getCfhCategories().valueCollection()) - { - for(CfhTopic topic : category.getTopics().valueCollection()) - { - if(topic.id == topicId) - { + public CfhTopic getCfhTopic(int topicId) { + for (CfhCategory category : this.getCfhCategories().valueCollection()) { + for (CfhTopic topic : category.getTopics().valueCollection()) { + if (topic.id == topicId) { return topic; } } @@ -178,17 +162,14 @@ public class ModToolManager return null; } - public ModToolPreset getIssuePreset(int id) - { + public ModToolPreset getIssuePreset(int id) { if (id == 0) return null; final ModToolPreset[] preset = {null}; - this.category.forEachValue(new TObjectProcedure() - { + this.category.forEachValue(new TObjectProcedure() { @Override - public boolean execute(ModToolCategory object) - { + public boolean execute(ModToolCategory object) { preset[0] = object.getPresets().get(id); return preset[0] == null; } @@ -197,8 +178,7 @@ public class ModToolManager return preset[0]; } - public void quickTicket(Habbo reported, String reason, String message) - { + public void quickTicket(Habbo reported, String reason, String message) { ModToolIssue issue = new ModToolIssue(0, reason, reported.getHabboInfo().getId(), reported.getHabboInfo().getUsername(), 0, message, ModToolTicketType.AUTOMATIC); if (Emulator.getPluginManager().fireEvent(new SupportTicketEvent(null, issue)).isCancelled()) return; @@ -207,131 +187,78 @@ public class ModToolManager Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); } - public static void requestUserInfo(GameClient client, ClientMessage packet) - { - int userId = packet.readInt(); - - if(userId <= 0) - return; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.*, users_settings.*, permissions.rank_name, permissions.id as rank_id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id INNER JOIN permissions ON permissions.id = users.rank WHERE users.id = ? LIMIT 1")) - { - statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - client.sendResponse(new ModToolUserInfoComposer(set)); - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - } - - public ArrayList getRoomChatlog(int roomId) - { + public ArrayList getRoomChatlog(int roomId) { ArrayList chatlogs = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE room_id = ? ORDER BY timestamp DESC LIMIT 150")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE room_id = ? ORDER BY timestamp DESC LIMIT 150")) { statement.setInt(1, roomId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { chatlogs.add(new ModToolChatLog(set.getInt("timestamp"), set.getInt("id"), set.getString("username"), set.getString("message"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return chatlogs; } - public ArrayList getUserChatlog(int userId) - { + public ArrayList getUserChatlog(int userId) { ArrayList chatlogs = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY timestamp DESC LIMIT 150")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY timestamp DESC LIMIT 150")) { statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { chatlogs.add(new ModToolChatLog(set.getInt("timestamp"), set.getInt("id"), set.getString("username"), set.getString("message"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return chatlogs; } - public ArrayList getMessengerChatlog(int userOneId, int userTwoId) - { + public ArrayList getMessengerChatlog(int userOneId, int userTwoId) { ArrayList chatLogs = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY timestamp DESC LIMIT 50")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY timestamp DESC LIMIT 50")) { statement.setInt(1, userOneId); statement.setInt(2, userTwoId); statement.setInt(3, userTwoId); statement.setInt(4, userOneId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { chatLogs.add(new ModToolChatLog(set.getInt("timestamp"), set.getInt("chatlogs_private.user_from_id"), set.getString("users.username"), set.getString("message"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return chatLogs; } - public ArrayList getUserRoomVisitsAndChatlogs(int userId) - { + public ArrayList getUserRoomVisitsAndChatlogs(int userId) { ArrayList chatlogs = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, users.username, room_enter_log.timestamp AS enter_timestamp, room_enter_log.exit_timestamp, chatlogs_room.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id INNER JOIN users ON room_enter_log.user_id = users.id LEFT JOIN chatlogs_room ON room_enter_log.user_id = chatlogs_room.user_from_id AND room_enter_log.room_id = chatlogs_room.room_id AND chatlogs_room.timestamp >= room_enter_log.timestamp AND chatlogs_room.timestamp < room_enter_log.exit_timestamp WHERE chatlogs_room.user_from_id = ? ORDER BY room_enter_log.timestamp DESC LIMIT 500")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, users.username, room_enter_log.timestamp AS enter_timestamp, room_enter_log.exit_timestamp, chatlogs_room.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id INNER JOIN users ON room_enter_log.user_id = users.id LEFT JOIN chatlogs_room ON room_enter_log.user_id = chatlogs_room.user_from_id AND room_enter_log.room_id = chatlogs_room.room_id AND chatlogs_room.timestamp >= room_enter_log.timestamp AND chatlogs_room.timestamp < room_enter_log.exit_timestamp WHERE chatlogs_room.user_from_id = ? ORDER BY room_enter_log.timestamp DESC LIMIT 500")) { statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { int userid = 0; String username = "unknown"; - while (set.next()) - { + while (set.next()) { ModToolRoomVisit visit = null; - for (ModToolRoomVisit v : chatlogs) - { - if (v.timestamp == set.getInt("enter_timestamp") && v.exitTimestamp == set.getInt("exit_timestamp")) - { + for (ModToolRoomVisit v : chatlogs) { + if (v.timestamp == set.getInt("enter_timestamp") && v.exitTimestamp == set.getInt("exit_timestamp")) { visit = v; } } - if (visit == null) - { + if (visit == null) { visit = new ModToolRoomVisit(set.getInt("room_id"), set.getString("name"), set.getInt("enter_timestamp"), set.getInt("exit_timestamp")); chatlogs.add(visit); } @@ -344,46 +271,36 @@ public class ModToolManager username = set.getString("username"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return chatlogs; } - public THashSet requestUserRoomVisits(Habbo habbo) - { + public THashSet requestUserRoomVisits(Habbo habbo) { THashSet roomVisits = new THashSet<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? AND timestamp >= ? ORDER BY timestamp DESC LIMIT 50")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? AND timestamp >= ? ORDER BY timestamp DESC LIMIT 50")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getIntUnixTimestamp() - 84600); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { roomVisits.add(new ModToolRoomVisit(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return roomVisits; } - public THashSet getVisitsForRoom(Room room, int amount, boolean groupUser, int fromTimestamp, int toTimestamp) - { + public THashSet getVisitsForRoom(Room room, int amount, boolean groupUser, int fromTimestamp, int toTimestamp) { return this.getVisitsForRoom(room, amount, groupUser, fromTimestamp, toTimestamp, ""); } - public THashSet getVisitsForRoom(Room room, int amount, boolean groupUser, int fromTimestamp, int toTimestamp, String excludeUsername) - { + public THashSet getVisitsForRoom(Room room, int amount, boolean groupUser, int fromTimestamp, int toTimestamp, String excludeUsername) { THashSet roomVisits = new THashSet<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM (" + @@ -405,47 +322,40 @@ public class ModToolManager "timestamp " + "DESC LIMIT ?) x " + (groupUser ? "GROUP BY user_id" : "") + - ";")) - { + ";")) { statement.setInt(1, room.getId()); - if(fromTimestamp > 0) + if (fromTimestamp > 0) statement.setInt(2, fromTimestamp); - if(toTimestamp > 0) + if (toTimestamp > 0) statement.setInt((fromTimestamp > 0 ? 3 : 2), toTimestamp); statement.setString((toTimestamp > 0 ? fromTimestamp > 0 ? 4 : 3 : 2), excludeUsername); int columnAmount = 3; - if(fromTimestamp > 0) + if (fromTimestamp > 0) columnAmount++; - if(toTimestamp > 0) + if (toTimestamp > 0) columnAmount++; statement.setInt(columnAmount, amount); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { roomVisits.add(new ModToolRoomVisit(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return roomVisits; } - public ModToolBan createOfflineUserBan(int userId, int staffId, int duration, String reason, ModToolBanType type) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bans (user_id, ip, machine_id, user_staff_id, ban_expire, ban_reason, type) VALUES (?, (SELECT ip_current FROM users WHERE id = ?), (SELECT machine_id FROM users WHERE id = ?), ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + public ModToolBan createOfflineUserBan(int userId, int staffId, int duration, String reason, ModToolBanType type) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bans (user_id, ip, machine_id, user_staff_id, ban_expire, ban_reason, type) VALUES (?, (SELECT ip_current FROM users WHERE id = ?), (SELECT machine_id FROM users WHERE id = ?), ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userId); statement.setInt(2, userId); statement.setInt(3, userId); @@ -454,41 +364,32 @@ public class ModToolManager statement.setString(6, reason); statement.setString(7, type.getType()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - try (PreparedStatement selectBanStatement = connection.prepareStatement("SELECT * FROM bans WHERE id = ? LIMIT 1")) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + try (PreparedStatement selectBanStatement = connection.prepareStatement("SELECT * FROM bans WHERE id = ? LIMIT 1")) { selectBanStatement.setInt(1, set.getInt(1)); - try (ResultSet selectSet = selectBanStatement.executeQuery()) - { - if (selectSet.next()) - { + try (ResultSet selectSet = selectBanStatement.executeQuery()) { + if (selectSet.next()) { return new ModToolBan(selectSet); } } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return null; } - public void alert(Habbo moderator, Habbo target, String message) - { + public void alert(Habbo moderator, Habbo target, String message) { alert(moderator, target, message, SupportUserAlertedReason.ALERT); } - public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) - { - if(!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) { + public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) { + if (!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) { ScripterManager.scripterDetected(moderator.getClient(), Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message)); return; } @@ -498,24 +399,20 @@ public class ModToolManager if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled()) return; - if(target != null) + if (target != null) alertedEvent.target.getClient().sendResponse(new ModToolIssueHandledComposer(alertedEvent.message)); } - public void kick(Habbo moderator, Habbo target, String message) - { - if (moderator.hasPermission(Permission.ACC_SUPPORTTOOL) && !target.hasPermission(Permission.ACC_UNKICKABLE)) - { - if (target.getHabboInfo().getCurrentRoom() != null) - { + public void kick(Habbo moderator, Habbo target, String message) { + if (moderator.hasPermission(Permission.ACC_SUPPORTTOOL) && !target.hasPermission(Permission.ACC_UNKICKABLE)) { + if (target.getHabboInfo().getCurrentRoom() != null) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getHabboInfo().getCurrentRoom()); } this.alert(moderator, target, message, SupportUserAlertedReason.KICKED); } } - public List ban(int targetUserId, Habbo moderator, String reason, int duration, ModToolBanType type, int cfhTopic) - { + public List ban(int targetUserId, Habbo moderator, String reason, int duration, ModToolBanType type, int cfhTopic) { if (moderator == null) return null; @@ -523,8 +420,7 @@ public class ModToolManager Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(targetUserId); HabboInfo offlineInfo = target != null ? target.getHabboInfo() : HabboManager.getOfflineHabboInfo(targetUserId); - if (moderator.getHabboInfo().getRank().getId() < offlineInfo.getRank().getId()) - { + if (moderator.getHabboInfo().getRank().getId() < offlineInfo.getRank().getId()) { return bans; } @@ -533,15 +429,12 @@ public class ModToolManager Emulator.getThreading().run(ban); bans.add(ban); - if (target != null) - { + if (target != null) { 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.ip.equals("offline")) { + for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(ban.ip)) { 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); @@ -552,10 +445,8 @@ 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.machineId.equals("offline")) { + for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithMachineId(ban.machineId)) { 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); @@ -569,194 +460,154 @@ public class ModToolManager return bans; } - public void roomAction(Room room, Habbo moderator, boolean kickUsers, boolean lockDoor, boolean changeTitle) - { + public void roomAction(Room room, Habbo moderator, boolean kickUsers, boolean lockDoor, boolean changeTitle) { SupportRoomActionEvent roomActionEvent = new SupportRoomActionEvent(moderator, room, kickUsers, lockDoor, changeTitle); Emulator.getPluginManager().fireEvent(roomActionEvent); - if (roomActionEvent.changeTitle) - { + if (roomActionEvent.changeTitle) { room.setName(Emulator.getTexts().getValue("hotel.room.inappropriate.title")); room.setNeedsUpdate(true); } - if (roomActionEvent.lockDoor) - { + if (roomActionEvent.lockDoor) { room.setState(RoomState.LOCKED); room.setNeedsUpdate(true); } - if (roomActionEvent.kickUsers) - { - for (Habbo habbo : room.getHabbos()) - { - if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) - { + if (roomActionEvent.kickUsers) { + for (Habbo habbo : room.getHabbos()) { + if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { room.kickHabbo(habbo, false); } } } } - public ModToolBan checkForBan(int userId) - { + public ModToolBan checkForBan(int userId) { ModToolBan ban = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE user_id = ? AND ban_expire >= ? AND (type = 'account' OR type = 'super') ORDER BY timestamp LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE user_id = ? AND ban_expire >= ? AND (type = 'account' OR type = 'super') ORDER BY timestamp LIMIT 1")) { statement.setInt(1, userId); statement.setInt(2, Emulator.getIntUnixTimestamp()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { ban = new ModToolBan(set); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return ban; } - public boolean hasIPBan(Channel habbo) - { + public boolean hasIPBan(Channel habbo) { if (habbo == null) return false; - if (habbo.remoteAddress() == null || ((InetSocketAddress)habbo.remoteAddress()).getAddress() == null) + if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null) return false; boolean banned = false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) { statement.setString(1, ((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress()); statement.setInt(2, Emulator.getIntUnixTimestamp()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { banned = true; } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return banned; } - public boolean hasMACBan(GameClient habbo) - { + public boolean hasMACBan(GameClient habbo) { if (habbo == null) return false; - if (habbo.getMachineId().isEmpty()) - { + if (habbo.getMachineId().isEmpty()) { return false; } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE machine_id = ? AND (type = 'machine' OR type = 'super') AND ban_expire > ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE machine_id = ? AND (type = 'machine' OR type = 'super') AND ban_expire > ? LIMIT 1")) { statement.setString(1, habbo.getMachineId()); statement.setInt(2, Emulator.getIntUnixTimestamp()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { return true; } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return false; } - public boolean unban(String username) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bans INNER JOIN users ON bans.user_id = users.id SET ban_expire = ?, ban_reason = CONCAT('" + Emulator.getTexts().getValue("unbanned") + ": ', ban_reason) WHERE users.username LIKE ? AND ban_expire > ?")) - { + public boolean unban(String username) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bans INNER JOIN users ON bans.user_id = users.id SET ban_expire = ?, ban_reason = CONCAT('" + Emulator.getTexts().getValue("unbanned") + ": ', ban_reason) WHERE users.username LIKE ? AND ban_expire > ?")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.setString(2, username); statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); return statement.getUpdateCount() > 0; - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return false; } - public void pickTicket(ModToolIssue issue, Habbo habbo) - { - issue.modId = habbo.getHabboInfo().getId(); + public void pickTicket(ModToolIssue issue, Habbo habbo) { + issue.modId = habbo.getHabboInfo().getId(); issue.modName = habbo.getHabboInfo().getUsername(); - issue.state = ModToolTicketState.PICKED; + issue.state = ModToolTicketState.PICKED; this.updateTicketToMods(issue); issue.updateInDatabase(); } - public void updateTicketToMods(ModToolIssue issue) - { + public void updateTicketToMods(ModToolIssue issue) { SupportTicketStatusChangedEvent event = new SupportTicketStatusChangedEvent(null, issue); - if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { Emulator.getGameEnvironment().getHabboManager().sendPacketToHabbosWithPermission(new ModToolIssueInfoComposer(issue).compose(), Permission.ACC_SUPPORTTOOL); } } - public void addTicket(ModToolIssue issue) - { + public void addTicket(ModToolIssue issue) { if (Emulator.getPluginManager().fireEvent(new SupportTicketEvent(null, issue)).isCancelled()) return; - if (issue.id == 0) - { + if (issue.id == 0) { new InsertModToolIssue(issue).run(); } - synchronized (this.tickets) - { + synchronized (this.tickets) { this.tickets.put(issue.id, issue); } } - public void removeTicket(ModToolIssue issue) - { + public void removeTicket(ModToolIssue issue) { this.removeTicket(issue.id); } - public void removeTicket(int issueId) - { - synchronized (this.tickets) - { + public void removeTicket(int issueId) { + synchronized (this.tickets) { this.tickets.remove(issueId); } } - public void closeTicketAsUseless(ModToolIssue issue, Habbo sender) - { + public void closeTicketAsUseless(ModToolIssue issue, Habbo sender) { issue.state = ModToolTicketState.CLOSED; issue.updateInDatabase(); - if(sender != null) - { + if (sender != null) { sender.getClient().sendResponse(new ModToolIssueHandledComposer(ModToolIssueHandledComposer.USELESS)); } @@ -765,12 +616,10 @@ public class ModToolManager this.removeTicket(issue); } - public void closeTicketAsAbusive(ModToolIssue issue, Habbo sender) - { + public void closeTicketAsAbusive(ModToolIssue issue, Habbo sender) { issue.state = ModToolTicketState.CLOSED; issue.updateInDatabase(); - if(sender != null) - { + if (sender != null) { sender.getClient().sendResponse(new ModToolIssueHandledComposer(ModToolIssueHandledComposer.ABUSIVE)); } @@ -779,13 +628,11 @@ public class ModToolManager this.removeTicket(issue); } - public void closeTicketAsHandled(ModToolIssue issue, Habbo sender) - { + public void closeTicketAsHandled(ModToolIssue issue, Habbo sender) { issue.state = ModToolTicketState.CLOSED; issue.updateInDatabase(); - if(sender != null) - { + if (sender != null) { sender.getClient().sendResponse(new ModToolIssueHandledComposer(ModToolIssueHandledComposer.HANDLED)); } @@ -794,13 +641,10 @@ public class ModToolManager this.removeTicket(issue); } - public boolean hasPendingTickets(int userId) - { - synchronized (this.tickets) - { - for(Map.Entry map : this.tickets.entrySet()) - { - if(map.getValue().senderId == userId) + public boolean hasPendingTickets(int userId) { + synchronized (this.tickets) { + for (Map.Entry map : this.tickets.entrySet()) { + if (map.getValue().senderId == userId) return true; } } @@ -808,70 +652,53 @@ public class ModToolManager return false; } - public int totalBans(int userId) - { + public int totalBans(int userId) { int total = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as total FROM bans WHERE user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as total FROM bans WHERE user_id = ?")) { statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { total = set.getInt("total"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return total; } - public TIntObjectMap getCategory() - { + public TIntObjectMap getCategory() { return this.category; } - public ModToolCategory getCategory(int id) - { + public ModToolCategory getCategory(int id) { return this.category.get(id); } - public THashMap> getPresets() - { + public THashMap> getPresets() { return this.presets; } - public THashMap getTickets() - { + public THashMap getTickets() { return this.tickets; } - public ModToolIssue getTicket(int ticketId) - { + public ModToolIssue getTicket(int ticketId) { return this.tickets.get(ticketId); } - public TIntObjectMap getCfhCategories() - { + public TIntObjectMap getCfhCategories() { return this.cfhCategories; } - public List openTicketsForHabbo(Habbo habbo) - { + public List openTicketsForHabbo(Habbo habbo) { List issues = new ArrayList<>(); - synchronized (this.tickets) - { - this.tickets.forEachValue(new TObjectProcedure() - { + synchronized (this.tickets) { + this.tickets.forEachValue(new TObjectProcedure() { @Override - public boolean execute(ModToolIssue object) - { - if (object.senderId == habbo.getHabboInfo().getId() && object.state == ModToolTicketState.OPEN) - { + public boolean execute(ModToolIssue object) { + if (object.senderId == habbo.getHabboInfo().getId() && object.state == ModToolTicketState.OPEN) { issues.add(object); } 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 e5d92fe5..2b4208c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolPreset.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.modtool; import java.sql.ResultSet; import java.sql.SQLException; -public class ModToolPreset -{ +public class ModToolPreset { public final int id; public final String name; public final String message; @@ -12,8 +11,7 @@ public class ModToolPreset public final int banLength; public final int muteLength; - public ModToolPreset(ResultSet set) throws SQLException - { + public ModToolPreset(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.message = set.getString("message"); 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 de9cb859..0ccabbdb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolRoomVisit.java @@ -5,23 +5,20 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class ModToolRoomVisit implements Comparable -{ +public class ModToolRoomVisit implements Comparable { public int roomId; public String roomName; public int timestamp; public int exitTimestamp; public THashSet chat; - public ModToolRoomVisit(ResultSet set) throws SQLException - { + public ModToolRoomVisit(ResultSet set) throws SQLException { this.roomId = set.getInt("room_id"); this.roomName = set.getString("name"); this.timestamp = set.getInt("timestamp"); } - public ModToolRoomVisit(int roomId, String roomName, int timestamp, int exitTimestamp) - { + public ModToolRoomVisit(int roomId, String roomName, int timestamp, int exitTimestamp) { this.roomId = roomId; this.roomName = roomName; this.timestamp = timestamp; @@ -30,8 +27,7 @@ public class ModToolRoomVisit implements Comparable } @Override - public int compareTo(ModToolRoomVisit o) - { + public int compareTo(ModToolRoomVisit o) { return o.timestamp - this.timestamp; } } 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 a6bb4994..4bba6c84 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketState.java @@ -1,31 +1,26 @@ package com.eu.habbo.habbohotel.modtool; -public enum ModToolTicketState -{ +public enum ModToolTicketState { CLOSED(0), OPEN(1), PICKED(2); private final int state; - ModToolTicketState(int state) - { + ModToolTicketState(int state) { this.state = state; } - public int getState() - { - return this.state; - } - - public static ModToolTicketState getState(int number) - { - for(ModToolTicketState s : ModToolTicketState.values()) - { - if(s.state == number) + public static ModToolTicketState getState(int number) { + for (ModToolTicketState s : ModToolTicketState.values()) { + if (s.state == number) return s; } 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 00b3b9b6..4eb8aace 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolTicketType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.modtool; -public enum ModToolTicketType -{ +public enum ModToolTicketType { NORMAL(1), NORMAL_UNKNOWN(2), AUTOMATIC(3), @@ -20,13 +19,11 @@ public enum ModToolTicketType private final int type; - ModToolTicketType(int type) - { + ModToolTicketType(int type) { this.type = type; } - public int getType() - { + public int getType() { return this.type; } } 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 9082a13b..b000c0b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -17,46 +17,43 @@ import java.sql.Statement; import java.text.Normalizer; import java.util.regex.Pattern; -public class WordFilter -{ +public class WordFilter { + private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+"); //Configuration. Loaded from database & updated accordingly. public static boolean ENABLED_FRIENDCHAT = true; public static String DEFAULT_REPLACEMENT = "bobba"; - protected THashSet autoReportWords = new THashSet<>(); protected THashSet hideMessageWords = new THashSet<>(); protected THashSet words = new THashSet<>(); - public WordFilter() - { + public WordFilter() { long start = System.currentTimeMillis(); this.reload(); Emulator.getLogging().logStart("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); } - public synchronized void reload() - { - if(!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled")) + private static String stripDiacritics(String str) { + str = Normalizer.normalize(str, Normalizer.Form.NFD); + str = DIACRITICS_AND_FRIENDS.matcher(str).replaceAll(""); + return str; + } + + public synchronized void reload() { + if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled")) return; this.autoReportWords.clear(); this.hideMessageWords.clear(); this.words.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) - { - try (ResultSet set = statement.executeQuery("SELECT * FROM wordfilter")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) { + try (ResultSet set = statement.executeQuery("SELECT * FROM wordfilter")) { + while (set.next()) { WordFilterWord word; - try - { + try { word = new WordFilterWord(set); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); continue; } @@ -69,37 +66,28 @@ public class WordFilter this.words.add(word); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - - public String normalise(String message) - { + public String normalise(String message) { return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD).replaceAll("[,.;:'\"]", "").replace("I", "l") - .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", "").replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i").replace("2", "z").replace("3", "e").replace("4","a").replace("5", "s").replace("8", "b").replace("0", "o").replace(" ", "").replace("$", "s").replace("ß", "b").trim()).replaceAll(""); + .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", "").replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i").replace("2", "z").replace("3", "e").replace("4", "a").replace("5", "s").replace("8", "b").replace("0", "o").replace(" ", "").replace("$", "s").replace("ß", "b").trim()).replaceAll(""); } - - public boolean autoReportCheck(RoomChatMessage roomChatMessage) - { + public boolean autoReportCheck(RoomChatMessage roomChatMessage) { String message = this.normalise(roomChatMessage.getMessage()).toLowerCase(); TObjectHashIterator iterator = this.autoReportWords.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { WordFilterWord word = (WordFilterWord) iterator.next(); - if (message.contains(word.key)) - { + if (message.contains(word.key)) { Emulator.getGameEnvironment().getModToolManager().quickTicket(roomChatMessage.getHabbo(), "Automatic WordFilter", roomChatMessage.getMessage()); - if(Emulator.getConfig().getBoolean("notify.staff.chat.auto.report")) - { + if (Emulator.getConfig().getBoolean("notify.staff.chat.auto.report")) { Emulator.getGameEnvironment().getHabboManager().sendPacketToHabbosWithPermission(new FriendChatMessageComposer(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"); } return true; @@ -109,18 +97,15 @@ public class WordFilter return false; } - public boolean hideMessageCheck(String message) - { + public boolean hideMessageCheck(String message) { message = this.normalise(message).toLowerCase(); TObjectHashIterator iterator = this.hideMessageWords.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { WordFilterWord word = (WordFilterWord) iterator.next(); - if (message.contains(word.key)) - { + if (message.contains(word.key)) { return true; } } @@ -128,21 +113,17 @@ public class WordFilter return false; } - public String[] filter(String[] messages) - { - for(int i = 0; i < messages.length; i++) - { + public String[] filter(String[] messages) { + for (int i = 0; i < messages.length; i++) { messages[i] = this.filter(messages[i], null); } return messages; } - public String filter(String message, Habbo habbo) - { + public String filter(String message, Habbo habbo) { String filteredMessage = message; - if(Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) - { + if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) { filteredMessage = this.normalise(filteredMessage); } @@ -150,55 +131,45 @@ public class WordFilter boolean foundShit = false; - while(iterator.hasNext()) - { + while (iterator.hasNext()) { WordFilterWord word = (WordFilterWord) iterator.next(); - if(StringUtils.containsIgnoreCase(filteredMessage, word.key)) - { - if(habbo != null) - { - if(Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) + if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) { + if (habbo != null) { + if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } filteredMessage = filteredMessage.replaceAll("(?i)" + word.key, word.replacement); foundShit = true; - if (habbo != null && word.muteTime > 0) - { + if (habbo != null && word.muteTime > 0) { habbo.mute(word.muteTime); } } } - if (!foundShit) - { + if (!foundShit) { return message; } return filteredMessage; } - public void filter (RoomChatMessage roomChatMessage, Habbo habbo) - { + public void filter(RoomChatMessage roomChatMessage, Habbo habbo) { String message = roomChatMessage.getMessage().toLowerCase(); - if(Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) - { + if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) { message = this.normalise(message); } TObjectHashIterator iterator = this.words.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { WordFilterWord word = (WordFilterWord) iterator.next(); - if(StringUtils.containsIgnoreCase(message, word.key)) - { - if(habbo != null) - { - if(Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) + if (StringUtils.containsIgnoreCase(message, word.key)) { + if (habbo != null) { + if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } @@ -207,22 +178,12 @@ public class WordFilter } } - if (roomChatMessage.filtered) - { + if (roomChatMessage.filtered) { roomChatMessage.setMessage(message); } } - private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+"); - - private static String stripDiacritics(String str) { - str = Normalizer.normalize(str, Normalizer.Form.NFD); - str = DIACRITICS_AND_FRIENDS.matcher(str).replaceAll(""); - return str; - } - - public void addWord(WordFilterWord word) - { + public void addWord(WordFilterWord word) { this.words.add(word); } } 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 64be198d..0f8420a3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilterWord.java @@ -3,29 +3,26 @@ package com.eu.habbo.habbohotel.modtool; import java.sql.ResultSet; import java.sql.SQLException; -public class WordFilterWord -{ +public class WordFilterWord { public final String key; public final String replacement; public final boolean hideMessage; public final boolean autoReport; public final int muteTime; - public WordFilterWord(ResultSet set) throws SQLException - { - this.key = set.getString("key"); + public WordFilterWord(ResultSet set) throws SQLException { + this.key = set.getString("key"); this.replacement = set.getString("replacement"); this.hideMessage = set.getInt("hide") == 1; - this.autoReport = set.getInt("report") == 1; - this.muteTime = set.getInt("mute"); + this.autoReport = set.getInt("report") == 1; + this.muteTime = set.getInt("mute"); } - public WordFilterWord(String key, String replacement) - { - this.key = key; + public WordFilterWord(String key, String replacement) { + this.key = key; this.replacement = replacement; this.hideMessage = false; - this.autoReport = false; - this.muteTime = 0; + this.autoReport = false; + this.muteTime = 0; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayMode.java b/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayMode.java index ba5d3868..f4b9dbbe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayMode.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayMode.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.navigation; -public enum DisplayMode -{ +public enum DisplayMode { VISIBLE, COLLAPSED } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayOrder.java b/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayOrder.java index af0fd588..12d8cbb2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayOrder.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/DisplayOrder.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.navigation; -public enum DisplayOrder -{ +public enum DisplayOrder { ORDER_NUM, ACTIVITY } \ No newline at end of file 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 63d1dc16..cf4e50b0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/ListMode.java @@ -1,24 +1,19 @@ package com.eu.habbo.habbohotel.navigation; -public enum ListMode -{ +public enum ListMode { LIST(0), THUMBNAILS(1), FORCED_THUNBNAILS(2); public final int type; - ListMode(int type) - { + ListMode(int type) { this.type = type; } - public static ListMode fromType(int type) - { - for (ListMode m : ListMode.values()) - { - if (m.type == type) - { + public static ListMode fromType(int type) { + for (ListMode m : ListMode.values()) { + if (m.type == type) { return m; } } 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 c8894f7e..942860b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java @@ -8,18 +8,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class NavigatorFavoriteFilter extends NavigatorFilter -{ +public class NavigatorFavoriteFilter extends NavigatorFilter { public final static String name = "favorites"; - public NavigatorFavoriteFilter() - { + public NavigatorFavoriteFilter() { super(name); } @Override - public List getResult(Habbo habbo) - { + public List getResult(Habbo habbo) { List resultLists = new ArrayList<>(); List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo); Collections.sort(rooms); 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 77594360..bcc9767e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java @@ -9,34 +9,26 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -public abstract class NavigatorFilter -{ +public abstract class NavigatorFilter { public final String viewName; - public NavigatorFilter(String viewName) - { + public NavigatorFilter(String viewName) { this.viewName = viewName; } - public void filter(Method method, Object value, List collection) - { - if (method == null) - { + public void filter(Method method, Object value, List collection) { + if (method == null) { return; } - if (value instanceof String) - { - if (((String) value).isEmpty()) - { + if (value instanceof String) { + if (((String) value).isEmpty()) { return; } } - for (SearchResultList result : collection) - { - if (!result.filter) - { + for (SearchResultList result : collection) { + if (!result.filter) { continue; } @@ -44,74 +36,52 @@ public abstract class NavigatorFilter } } - public void filterRooms(Method method, Object value, List result) - { - if (method == null) - { + public void filterRooms(Method method, Object value, List result) { + if (method == null) { return; } - if (value instanceof String) - { - if (((String) value).isEmpty()) - { + if (value instanceof String) { + if (((String) value).isEmpty()) { return; } } List toRemove = new ArrayList<>(); - try - { + try { method.setAccessible(true); - for (Room room : result) - { + for (Room room : result) { Object o = method.invoke(room); - if (o.getClass() == value.getClass()) - { - if (o instanceof String) - { + if (o.getClass() == value.getClass()) { + if (o instanceof String) { NavigatorFilterComparator comparator = Emulator.getGameEnvironment().getNavigatorManager().comperatorForField(method); - if (comparator != null) - { - if (!this.applies(comparator, (String) o, (String) value)) - { + if (comparator != null) { + if (!this.applies(comparator, (String) o, (String) value)) { toRemove.add(room); } - } - else - { + } else { toRemove.add(room); } - } - else if (o instanceof String[]) - { - for (String s : (String[]) o) - { + } else if (o instanceof String[]) { + for (String s : (String[]) o) { NavigatorFilterComparator comparator = Emulator.getGameEnvironment().getNavigatorManager().comperatorForField(method); - if (comparator != null) - { - if (!this.applies(comparator, s, (String) value)) - { + if (comparator != null) { + if (!this.applies(comparator, s, (String) value)) { toRemove.add(room); } } } - } - else - { - if (o != value) - { + } else { + if (o != value) { toRemove.add(room); } } } } - } - catch (Exception e) - { + } catch (Exception e) { } result.removeAll(toRemove); @@ -120,33 +90,27 @@ public abstract class NavigatorFilter public abstract List getResult(Habbo habbo); - public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) - { + public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) { return this.getResult(habbo); } - private boolean applies(NavigatorFilterComparator comparator, String o, String value) - { - switch (comparator) - { + private boolean applies(NavigatorFilterComparator comparator, String o, String value) { + switch (comparator) { case CONTAINS: if (StringUtils.containsIgnoreCase(o, - value)) - { + value)) { return true; } break; case EQUALS: - if (o.equals(value)) - { + if (o.equals(value)) { return true; } break; case EQUALS_IGNORE_CASE: - if (o.equalsIgnoreCase(value)) - { + if (o.equalsIgnoreCase(value)) { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterComparator.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterComparator.java index 81ab3804..a4923940 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterComparator.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterComparator.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.navigation; -public enum NavigatorFilterComparator -{ +public enum NavigatorFilterComparator { EQUALS, EQUALS_IGNORE_CASE, CONTAINS 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 1c4ce670..e7a717c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilterField.java @@ -2,15 +2,13 @@ package com.eu.habbo.habbohotel.navigation; import java.lang.reflect.Method; -public class NavigatorFilterField -{ +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) - { + public NavigatorFilterField(String key, Method field, String databaseQuery, NavigatorFilterComparator comparator) { this.key = key; this.field = field; this.databaseQuery = databaseQuery; 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 5f0f6c16..a5f171e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java @@ -10,31 +10,25 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class NavigatorHotelFilter extends NavigatorFilter -{ +public class NavigatorHotelFilter extends NavigatorFilter { public final static String name = "hotel_view"; - public NavigatorHotelFilter() - { + public NavigatorHotelFilter() { super(name); } @Override - public List getResult(Habbo habbo) - { + public List getResult(Habbo habbo) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); 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().getRoomManager().getPopularRooms(Emulator.getConfig().getInt("hotel.navigator.popular.amount")), 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()) - { + 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) - { + 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())); } i++; @@ -45,22 +39,17 @@ public class NavigatorHotelFilter extends NavigatorFilter } @Override - public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) - { + public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); - if (!filterField.databaseQuery.isEmpty()) - { + if (!filterField.databaseQuery.isEmpty()) { List resultLists = new ArrayList<>(); int i = 0; - for (Map.Entry> set : Emulator.getGameEnvironment().getRoomManager().findRooms(filterField, value, roomCategory, showInvisible).entrySet()) - { - if (!set.getValue().isEmpty()) - { + for (Map.Entry> set : Emulator.getGameEnvironment().getRoomManager().findRooms(filterField, value, roomCategory, showInvisible).entrySet()) { + if (!set.getValue().isEmpty()) { RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getKey()); - if (category != null) - { + 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())); } i++; @@ -68,9 +57,7 @@ public class NavigatorHotelFilter extends NavigatorFilter } return resultLists; - } - else - { + } else { return this.getResult(habbo); } } 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 9f289c91..db49d051 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -13,8 +13,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class NavigatorManager -{ +public class NavigatorManager { public static int MAXIMUM_RESULTS_PER_PAGE = 10; @@ -25,8 +24,7 @@ public class NavigatorManager public final ConcurrentHashMap filterSettings = new ConcurrentHashMap<>(); public final THashMap filters = new THashMap<>(); - public NavigatorManager() - { + public NavigatorManager() { long millis = System.currentTimeMillis(); this.filters.put(NavigatorPublicFilter.name, new NavigatorPublicFilter()); @@ -38,105 +36,72 @@ public class NavigatorManager Emulator.getLogging().logStart("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void loadNavigator() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - synchronized (this.publicCategories) - { + public void loadNavigator() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + synchronized (this.publicCategories) { this.publicCategories.clear(); - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publiccats WHERE visible = '1'")) - { - while(set.next()) - { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publiccats WHERE visible = '1'")) { + while (set.next()) { this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) - { - while (set.next()) - { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) { + while (set.next()) { NavigatorPublicCategory category = this.publicCategories.get(set.getInt("public_cat_id")); - if (category != null) - { + if (category != null) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(set.getInt("room_id")); - if (room != null) - { + if (room != null) { category.addRoom(room); - } - else - { + } else { Emulator.getLogging().logErrorLine("Public room (ID: " + set.getInt("room_id") + " defined in navigator_publics does not exist!"); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - synchronized (this.filterSettings) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_filter")) - { - while(set.next()) - { + synchronized (this.filterSettings) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_filter")) { + while (set.next()) { Method field = null; Class clazz = Room.class; - if (set.getString("field").contains(".")) - { - for (String s : (set.getString("field")).split(".")) - { - try - { + if (set.getString("field").contains(".")) { + for (String s : (set.getString("field")).split(".")) { + try { field = clazz.getDeclaredMethod(s); clazz = field.getReturnType(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); break; } } - } - else - { - try - { + } else { + try { field = clazz.getDeclaredMethod(set.getString("field")); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); continue; } } - if (field != null) - { + if (field != null) { this.filterSettings.put(set.getString("key"), new NavigatorFilterField(set.getString("key"), field, set.getString("database_query"), NavigatorFilterComparator.valueOf(set.getString("compare").toUpperCase()))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -147,12 +112,9 @@ public class NavigatorManager } } - public NavigatorFilterComparator comperatorForField(Method field) - { - for (Map.Entry set : this.filterSettings.entrySet()) - { - if (set.getValue().field == field) - { + public NavigatorFilterComparator comperatorForField(Method field) { + for (Map.Entry set : this.filterSettings.entrySet()) { + if (set.getValue().field == field) { return set.getValue().comparator; } } 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 0ea6f029..23d4de4d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java @@ -7,16 +7,14 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class NavigatorPublicCategory -{ +public class NavigatorPublicCategory { public final int id; public final String name; public final List rooms; public final ListMode image; public final int order; - public NavigatorPublicCategory(ResultSet set) throws SQLException - { + public NavigatorPublicCategory(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.image = set.getString("image").equals("1") ? ListMode.THUMBNAILS : ListMode.LIST; @@ -24,14 +22,12 @@ public class NavigatorPublicCategory this.rooms = new ArrayList<>(); } - public void addRoom(Room room) - { + public void addRoom(Room room) { room.preventUncaching = true; this.rooms.add(room); } - public void removeRoom(Room room) - { + public void removeRoom(Room room) { this.rooms.remove(room); room.preventUncaching = room.isPublicRoom(); } 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 1f71258d..7f59ac12 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java @@ -7,27 +7,22 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; import java.util.List; -public class NavigatorPublicFilter extends NavigatorFilter -{ +public class NavigatorPublicFilter extends NavigatorFilter { public final static String name = "official_view"; - public NavigatorPublicFilter() - { + public NavigatorPublicFilter() { super(name); } @Override - public List getResult(Habbo habbo) - { + public List getResult(Habbo habbo) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); 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().getRoomManager().getPublicRooms(), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); i++; - for (NavigatorPublicCategory category : Emulator.getGameEnvironment().getNavigatorManager().publicCategories.values()) - { - if (!category.rooms.isEmpty()) - { + 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.ACTIVITY, category.order)); 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 0c21bdf0..d11ec3f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java @@ -7,18 +7,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; import java.util.List; -public class NavigatorRoomAdsFilter extends NavigatorFilter -{ +public class NavigatorRoomAdsFilter extends NavigatorFilter { public final static String name = "roomads_view"; - public NavigatorRoomAdsFilter() - { + public NavigatorRoomAdsFilter() { super(name); } @Override - public List getResult(Habbo habbo) - { + public List getResult(Habbo habbo) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || 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().getRoomManager().getRoomsPromoted(), false, showInvisible, DisplayOrder.ACTIVITY, 0)); 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 e59cc1f0..2c4e9416 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java @@ -8,18 +8,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class NavigatorUserFilter extends NavigatorFilter -{ +public class NavigatorUserFilter extends NavigatorFilter { public final static String name = "myworld_view"; - public NavigatorUserFilter() - { + public NavigatorUserFilter() { super(name); } @Override - public List getResult(Habbo habbo) - { + public List getResult(Habbo habbo) { int i = 0; List resultLists = new ArrayList<>(); List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo); @@ -29,30 +26,26 @@ public class NavigatorUserFilter extends NavigatorFilter List favoriteRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo); - if (!favoriteRooms.isEmpty()) - { + if (!favoriteRooms.isEmpty()) { Collections.sort(favoriteRooms); 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)); i++; } List frequentlyVisited = Emulator.getGameEnvironment().getRoomManager().getRoomsVisited(habbo, false, 10); - if (!frequentlyVisited.isEmpty()) - { + 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)); i++; } List groupRooms = Emulator.getGameEnvironment().getRoomManager().getGroupRooms(habbo, 25); - if (!groupRooms.isEmpty()) - { + 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)); i++; } List rightRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(habbo); - if (!rightRooms.isEmpty()) - { + 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)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchAction.java b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchAction.java index 12c7e08c..299d00a3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchAction.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchAction.java @@ -1,15 +1,13 @@ package com.eu.habbo.habbohotel.navigation; -public enum SearchAction -{ +public enum SearchAction { NONE(0), MORE(1), BACK(2); public final int type; - SearchAction(int type) - { + SearchAction(int type) { this.type = type; } } \ No newline at end of file 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 424cb7c7..00feccd7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java @@ -9,8 +9,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class SearchResultList implements ISerialize, Comparable -{ +public class SearchResultList implements ISerialize, Comparable { public final int order; public final String code; public final String query; @@ -23,8 +22,7 @@ public class SearchResultList implements ISerialize, Comparable rooms, boolean filter, boolean showInvisible, DisplayOrder displayOrder, 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; @@ -39,23 +37,18 @@ public class SearchResultList implements ISerialize, Comparable toRemove = new ArrayList<>(); - for (Room room : this.rooms) - { - if (room.getState() == RoomState.INVISIBLE) - { + for (Room room : this.rooms) { + if (room.getState() == RoomState.INVISIBLE) { toRemove.add(room); } } @@ -66,20 +59,16 @@ public class SearchResultList implements ISerialize, Comparable ranks; private final TIntIntHashMap enables; private final THashMap> badges; - public PermissionsManager() - { - long millis = System.currentTimeMillis(); - this.ranks = new TIntObjectHashMap<>(); + public PermissionsManager() { + long millis = System.currentTimeMillis(); + this.ranks = new TIntObjectHashMap<>(); this.enables = new TIntIntHashMap(); this.badges = new THashMap>(); @@ -30,37 +28,28 @@ public class PermissionsManager Emulator.getLogging().logStart("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void reload() - { + public void reload() { this.loadPermissions(); this.loadEnables(); } - private void loadPermissions() - { + 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()) - { + 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"))) - { + if (!this.ranks.containsKey(set.getInt("id"))) { rank = new Rank(set); this.ranks.put(set.getInt("id"), rank); - } else - { + } else { rank = this.ranks.get(set.getInt("id")); rank.load(set); } - if (rank != null && !rank.getBadge().isEmpty()) - { - if (!this.badges.containsKey(rank.getBadge())) - { + if (rank != null && !rank.getBadge().isEmpty()) { + if (!this.badges.containsKey(rank.getBadge())) { this.badges.put(rank.getBadge(), new ArrayList()); } @@ -68,50 +57,38 @@ public class PermissionsManager } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadEnables() - { - synchronized (this.enables) - { + private void loadEnables() { + synchronized (this.enables) { this.enables.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM special_enables")) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM special_enables")) { + while (set.next()) { this.enables.put(set.getInt("effect_id"), set.getInt("min_rank")); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public boolean rankExists(int rankId) - { + public boolean rankExists(int rankId) { return this.ranks.containsKey(rankId); } - public Rank getRank(int rankId) - { + public Rank getRank(int rankId) { return this.ranks.get(rankId); } - public Rank getRankByName(String rankName) - { - for (Rank rank : this.ranks.valueCollection()) - { + public Rank getRankByName(String rankName) { + for (Rank rank : this.ranks.valueCollection()) { if (rank.getName().equalsIgnoreCase(rankName)) return rank; } @@ -120,26 +97,20 @@ public class PermissionsManager } - public boolean isEffectBlocked(int effectId, int rank) - { + public boolean isEffectBlocked(int effectId, int rank) { return this.enables.contains(effectId) && this.enables.get(effectId) > rank; } - public boolean hasPermission(Habbo habbo, String permission) - { + public boolean hasPermission(Habbo habbo, String permission) { return this.hasPermission(habbo, permission, false); } - public boolean hasPermission(Habbo habbo, String permission, boolean withRoomRights) - { - if (!this.hasPermission(habbo.getHabboInfo().getRank(), permission, withRoomRights)) - { - for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins()) - { - if(plugin.hasPermission(habbo, permission)) - { + public boolean hasPermission(Habbo habbo, String permission, boolean withRoomRights) { + if (!this.hasPermission(habbo.getHabboInfo().getRank(), permission, withRoomRights)) { + for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins()) { + if (plugin.hasPermission(habbo, permission)) { return true; } } @@ -151,18 +122,15 @@ public class PermissionsManager } - public boolean hasPermission(Rank rank, String permission, boolean withRoomRights) - { + public boolean hasPermission(Rank rank, String permission, boolean withRoomRights) { return rank.hasPermission(permission, withRoomRights); } - public Set getStaffBadges() - { + public Set getStaffBadges() { return this.badges.keySet(); } - public List getRanksByBadgeCode(String code) - { + public List getRanksByBadgeCode(String code) { return this.badges.get(code); } 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 47f8c16b..068f050e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java @@ -6,27 +6,16 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; -public class Rank -{ +public class Rank { private final int id; private final int level; - - - private String name; - - - private String badge; - - private final THashMap permissions; - - private final THashMap variables; - - + private String name; + private String badge; private int roomEffect; @@ -41,8 +30,7 @@ public class Rank private boolean hasPrefix; - public Rank(ResultSet set) throws SQLException - { + public Rank(ResultSet set) throws SQLException { this.permissions = new THashMap<>(); this.variables = new THashMap<>(); this.id = set.getInt("id"); @@ -51,8 +39,7 @@ public class Rank this.load(set); } - public void load(ResultSet set) throws SQLException - { + public void load(ResultSet set) throws SQLException { ResultSetMetaData meta = set.getMetaData(); this.name = set.getString("rank_name"); this.badge = set.getString("badge"); @@ -61,24 +48,18 @@ public class Rank this.prefix = set.getString("prefix"); this.prefixColor = set.getString("prefix_color"); this.hasPrefix = !this.prefix.isEmpty(); - for (int i = 1; i < meta.getColumnCount() + 1; i++) - { + for (int i = 1; i < meta.getColumnCount() + 1; i++) { String columnName = meta.getColumnName(i); - if (columnName.startsWith("cmd_") || columnName.startsWith("acc_")) - { + if (columnName.startsWith("cmd_") || columnName.startsWith("acc_")) { this.permissions.put(meta.getColumnName(i), new Permission(columnName, PermissionSetting.fromString(set.getString(i)))); - } - else - { + } else { this.variables.put(meta.getColumnName(i), set.getString(i)); } } } - public boolean hasPermission(String key, boolean isRoomOwner) - { - if (this.permissions.containsKey(key)) - { + public boolean hasPermission(String key, boolean isRoomOwner) { + if (this.permissions.containsKey(key)) { Permission permission = this.permissions.get(key); return permission.setting == PermissionSetting.ALLOWED || permission.setting == PermissionSetting.ROOM_OWNER && isRoomOwner; @@ -89,60 +70,49 @@ public class Rank } - public int getId() - { + public int getId() { return this.id; } - public int getLevel() - { + public int getLevel() { return this.level; } - public String getName() - { + public String getName() { return this.name; } - public String getBadge() - { + public String getBadge() { return this.badge; } - public THashMap getPermissions() - { + public THashMap getPermissions() { return this.permissions; } - public THashMap getVariables() - { + public THashMap getVariables() { return this.variables; } - public int getRoomEffect() - { + public int getRoomEffect() { return this.roomEffect; } - public boolean isLogCommands() - { + public boolean isLogCommands() { return this.logCommands; } - public String getPrefix() - { + public String getPrefix() { return this.prefix; } - public String getPrefixColor() - { + public String getPrefixColor() { return this.prefixColor; } - public boolean hasPrefix() - { + public boolean hasPrefix() { return this.hasPrefix; } } 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 bffb236e..be2a9e63 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -10,27 +10,23 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class GnomePet extends Pet implements IPetLook -{ +public class GnomePet extends Pet implements IPetLook { private final String gnomeData; - public GnomePet(ResultSet set) throws SQLException - { + public GnomePet(ResultSet set) throws SQLException { super(set); this.gnomeData = set.getString("gnome_data"); } - public GnomePet( int type, int race, String color, String name,int userId, String gnomeData) - { + public GnomePet(int type, int race, String color, String name, int userId, String gnomeData) { super(type, race, color, name, userId); this.gnomeData = gnomeData; } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.getId()); message.appendString(this.getName()); message.appendInt(this.petData.getType()); @@ -42,48 +38,36 @@ public class GnomePet extends Pet implements IPetLook } @Override - public void run() - { - if (this.needsUpdate) - { + public void run() { + if (this.needsUpdate) { super.run(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET gnome_data = ? WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET gnome_data = ? WHERE id = ? LIMIT 1")) { statement.setString(1, this.gnomeData); statement.setInt(2, this.id); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } @Override - public String getLook() - { + public String getLook() { return this.getPetData().getType() + " 0 FFFFFF " + this.gnomeData; } @Override - public void scratched(Habbo habbo) - { + public void scratched(Habbo habbo) { super.scratched(habbo); - if (this.getPetData().getType() == 26) - { - if (habbo != null) - { + if (this.getPetData().getType() == 26) { + if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GnomeRespectGiver")); } AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GnomeRespectReceiver")); - } - else if (this.getPetData().getType() == 27) - { - if (habbo != null) - { + } else if (this.getPetData().getType() == 27) { + if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("LeprechaunRespectGiver")); } AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("LeprechaunRespectReceiver")); @@ -92,16 +76,12 @@ public class GnomePet extends Pet implements IPetLook } @Override - protected void levelUp() - { + protected void levelUp() { super.levelUp(); - if (this.getPetData().getType() == 26) - { + if (this.getPetData().getType() == 26) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GnomeLevelUp")); - } - else if (this.getPetData().getType() == 27) - { + } else if (this.getPetData().getType() == 27) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("LeprechaunLevelUp")); } } 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 f90f7d2d..87be3a16 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -7,13 +7,11 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class HorsePet extends RideablePet -{ +public class HorsePet extends RideablePet { private int hairColor; private int hairStyle; - public HorsePet(ResultSet set) throws SQLException - { + public HorsePet(ResultSet set) throws SQLException { super(set); this.hairColor = set.getInt("hair_color"); this.hairStyle = set.getInt("hair_style"); @@ -21,8 +19,7 @@ public class HorsePet extends RideablePet this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1")); } - public HorsePet(int type, int race, String color, String name, int userId) - { + public HorsePet(int type, int race, String color, String name, int userId) { super(type, race, color, name, userId); this.hairColor = 0; this.hairStyle = -1; @@ -31,21 +28,16 @@ public class HorsePet extends RideablePet } @Override - public void run() - { - if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) - { + public void run() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) { statement.setInt(1, this.hairStyle); statement.setInt(2, this.hairColor); statement.setString(3, this.hasSaddle() ? "1" : "0"); statement.setString(4, this.anyoneCanRide() ? "1" : "0"); statement.setInt(5, super.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -53,23 +45,19 @@ public class HorsePet extends RideablePet } } - public int getHairColor() - { + public int getHairColor() { return this.hairColor; } - public void setHairColor(int hairColor) - { + public void setHairColor(int hairColor) { this.hairColor = hairColor; } - public int getHairStyle() - { + public int getHairStyle() { return this.hairStyle; } - public void setHairStyle(int hairStyle) - { + public void setHairStyle(int hairStyle) { this.hairStyle = hairStyle; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/IPetLook.java b/src/main/java/com/eu/habbo/habbohotel/pets/IPetLook.java index eb57b842..905b8597 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/IPetLook.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/IPetLook.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.pets; -public interface IPetLook -{ +public interface IPetLook { String getLook(); } \ No newline at end of file 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 721ef7d2..d683fd72 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -22,13 +22,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; -public class MonsterplantPet extends Pet implements IPetLook -{ - public static int growTime = (30 * 60); - public static int timeToLive = (3 * 24 * 60 * 60); //3 days - - public static final Map> bodyRarity = new LinkedHashMap>() - { +public class MonsterplantPet extends Pet implements IPetLook { + public static final Map> bodyRarity = new LinkedHashMap>() { { this.put(1, new Pair<>("Blungon", 0)); this.put(5, new Pair<>("Squarg", 0)); @@ -44,9 +39,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(9, new Pair<>("Fulvus", 0)); @@ -61,29 +54,25 @@ public class MonsterplantPet extends Pet implements IPetLook this.put(4, new Pair<>("Cyaneus", 5)); } }; - public static final ArrayList> indexedBody = new ArrayList<>(MonsterplantPet.bodyRarity.values()); - public static final ArrayList> indexedColors = new ArrayList<>(MonsterplantPet.colorRarity.values()); - - private int type; - private int hue; + public static int growTime = (30 * 60); + public static int timeToLive = (3 * 24 * 60 * 60); //3 days private final int nose; private final int noseColor; private final int eyes; private final int eyesColor; private final int mouth; private final int mouthColor; + public String look; + private int type; + private int hue; private int deathTimestamp = Emulator.getIntUnixTimestamp() + timeToLive; private boolean canBreed = true; private boolean publiclyBreedable = false; - private int growthStage = 0; - public String look; - - public MonsterplantPet(ResultSet set) throws SQLException - { + public MonsterplantPet(ResultSet set) throws SQLException { super(set); this.type = set.getInt("mp_type"); this.hue = set.getInt("mp_color"); @@ -98,8 +87,7 @@ public class MonsterplantPet extends Pet implements IPetLook this.canBreed = set.getString("mp_breedable").equals("1"); } - public MonsterplantPet(int userId, int type, int hue, int nose, int noseColor, int mouth, int mouthColor, int eyes, int eyesColor) - { + public MonsterplantPet(int userId, int type, int hue, int nose, int noseColor, int mouth, int mouthColor, int eyes, int eyesColor) { super(16, 0, "", "", userId); this.type = type; @@ -113,17 +101,14 @@ public class MonsterplantPet extends Pet implements IPetLook } @Override - public String getName() - { + public String getName() { String name = "Unknownis"; - if (colorRarity.containsKey(this.hue)) - { + if (colorRarity.containsKey(this.hue)) { name = colorRarity.get(this.hue).getKey(); } - if (bodyRarity.containsKey(this.type)) - { + if (bodyRarity.containsKey(this.type)) { name += " " + bodyRarity.get(this.type).getKey(); } @@ -131,14 +116,11 @@ public class MonsterplantPet extends Pet implements IPetLook } @Override - public void run() - { - if(this.needsUpdate) - { + public void run() { + if (this.needsUpdate) { super.run(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ? WHERE id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ? WHERE id = ?")) { statement.setInt(1, this.type); statement.setInt(2, this.hue); statement.setInt(3, this.nose); @@ -152,59 +134,44 @@ public class MonsterplantPet extends Pet implements IPetLook statement.setString(11, this.publiclyBreedable ? "1" : "0"); statement.setInt(12, this.id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } @Override - public void cycle() - { - if (this.room != null && this.roomUnit != null) - { - if (this.isDead()) - { + public void cycle() { + if (this.room != null && this.roomUnit != null) { + if (this.isDead()) { this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); - if (!this.roomUnit.hasStatus(RoomUnitStatus.RIP)) - { + if (!this.roomUnit.hasStatus(RoomUnitStatus.RIP)) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath")); } this.roomUnit.clearStatus(); this.roomUnit.setStatus(RoomUnitStatus.RIP, ""); this.packetUpdate = true; - } - else - { + } else { int difference = Emulator.getIntUnixTimestamp() - this.created + 1; - if (difference >= growTime) - { + if (difference >= growTime) { this.growthStage = 7; boolean clear = false; - for (RoomUnitStatus s : this.roomUnit.getStatusMap().keySet()) - { - if (s.equals(RoomUnitStatus.GROW)) - { + for (RoomUnitStatus s : this.roomUnit.getStatusMap().keySet()) { + if (s.equals(RoomUnitStatus.GROW)) { clear = true; } } - if (clear) - { + if (clear) { this.roomUnit.clearStatus(); this.packetUpdate = true; } - } - else - { + } else { int g = (int) Math.ceil(difference / (growTime / 7.0)); - if (g > this.growthStage) - { + if (g > this.growthStage) { this.growthStage = g; this.roomUnit.clearStatus(); this.roomUnit.setStatus(RoomUnitStatus.fromString("grw" + this.growthStage), ""); @@ -212,8 +179,7 @@ public class MonsterplantPet extends Pet implements IPetLook } } - if (Emulator.getRandom().nextInt(1000) < 10) - { + if (Emulator.getRandom().nextInt(1000) < 10) { super.updateGesture(Emulator.getIntUnixTimestamp()); this.packetUpdate = true; } @@ -223,36 +189,31 @@ public class MonsterplantPet extends Pet implements IPetLook super.cycle(); } - public int getType() - { + public int getType() { return this.type; } - public int getRarity() - { - if (bodyRarity.containsKey(this.type) && colorRarity.containsKey(this.hue)) - { + public int getRarity() { + if (bodyRarity.containsKey(this.type) && colorRarity.containsKey(this.hue)) { return bodyRarity.get(this.type).getValue() + colorRarity.get(this.hue).getValue(); } return 0; } @Override - public String getLook() - { + public String getLook() { return "16 0 FFFFFF " + "5 " + "0 -1 10 " + - "1 " + this.type + " " + this.hue + " " + + "1 " + this.type + " " + this.hue + " " + "2 " + this.mouth + " " + this.mouthColor + " " + - "3 " + this.nose + " " + this.noseColor + " " + - "4 " + this.eyes + " " + this.eyesColor; + "3 " + this.nose + " " + this.noseColor + " " + + "4 " + this.eyes + " " + this.eyesColor; } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.getId()); message.appendString(this.getName()); message.appendInt(this.petData.getType()); @@ -260,89 +221,75 @@ public class MonsterplantPet extends Pet implements IPetLook message.appendString(this.getLook().substring(5)); message.appendInt(this.getRarity()); message.appendInt(5); - message.appendInt(0); - message.appendInt(-1); - message.appendInt(10); - message.appendInt(1); - message.appendInt(this.type); - message.appendInt(this.hue); - message.appendInt(2); - message.appendInt(this.mouth); - message.appendInt(this.mouthColor); - message.appendInt(3); - message.appendInt(this.nose); - message.appendInt(this.noseColor); - message.appendInt(4); - message.appendInt(this.eyes); - message.appendInt(this.eyesColor); + message.appendInt(0); + message.appendInt(-1); + message.appendInt(10); + message.appendInt(1); + message.appendInt(this.type); + message.appendInt(this.hue); + message.appendInt(2); + message.appendInt(this.mouth); + message.appendInt(this.mouthColor); + message.appendInt(3); + message.appendInt(this.nose); + message.appendInt(this.noseColor); + message.appendInt(4); + message.appendInt(this.eyes); + message.appendInt(this.eyesColor); message.appendInt(this.growthStage); } - public int remainingTimeToLive() - { + public int remainingTimeToLive() { return Math.max(0, this.deathTimestamp - Emulator.getIntUnixTimestamp()); } - public boolean isDead() - { + public boolean isDead() { return Emulator.getIntUnixTimestamp() >= this.deathTimestamp; } - public void setDeathTimestamp(int deathTimestamp) - { + public void setDeathTimestamp(int deathTimestamp) { this.deathTimestamp = deathTimestamp; } - public int getGrowthStage() - { + public int getGrowthStage() { return this.growthStage; } - public int remainingGrowTime() - { - if (this.growthStage == 7) - { + public int remainingGrowTime() { + if (this.growthStage == 7) { return 0; } return Math.max(0, growTime - (Emulator.getIntUnixTimestamp() - this.created)); } - public boolean isFullyGrown() - { + public boolean isFullyGrown() { return this.growthStage == 7; } - public boolean canBreed() - { + public boolean canBreed() { return this.canBreed; } - public void setCanBreed(boolean canBreed) - { + public void setCanBreed(boolean canBreed) { this.canBreed = canBreed; } - public boolean breedable() - { + public boolean breedable() { return this.isFullyGrown() && this.canBreed && !this.isDead(); } - public boolean isPubliclyBreedable() - { + public boolean isPubliclyBreedable() { return this.publiclyBreedable; } - public void setPubliclyBreedable(boolean isPubliclyBreedable) - { + public void setPubliclyBreedable(boolean isPubliclyBreedable) { this.publiclyBreedable = isPubliclyBreedable; } - public void breed(MonsterplantPet pet) - { - if (this.canBreed && pet.canBreed) - { + public void breed(MonsterplantPet pet) { + if (this.canBreed && pet.canBreed) { this.canBreed = false; this.publiclyBreedable = false; @@ -363,27 +310,21 @@ public class MonsterplantPet extends Pet implements IPetLook Habbo ownerOne = this.room.getHabbo(this.getUserId()); Habbo ownerTwo = null; - if (this.getUserId() != pet.getUserId()) - { + if (this.getUserId() != pet.getUserId()) { ownerTwo = this.room.getHabbo(pet.getUserId()); } Item seedBase; - if (this.getRarity() < 8 || pet.getRarity() < 8 || Emulator.getRandom().nextInt(100) > this.getRarity() + pet.getRarity()) - { + if (this.getRarity() < 8 || pet.getRarity() < 8 || Emulator.getRandom().nextInt(100) > this.getRarity() + pet.getRarity()) { seedBase = Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("monsterplant.seed.item_id")); - } - else - { + } else { seedBase = Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("monsterplant.seed_rare.item_id")); } - if (seedBase != null) - { + if (seedBase != null) { HabboItem seed; - if (ownerOne != null) - { + if (ownerOne != null) { AchievementManager.progressAchievement(ownerOne, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantBreeder"), 5); seed = Emulator.getGameEnvironment().getItemManager().createItem(ownerOne.getHabboInfo().getId(), seedBase, 0, 0, ""); ownerOne.getInventory().getItemsComponent().addItem(seed); @@ -391,8 +332,7 @@ public class MonsterplantPet extends Pet implements IPetLook ownerOne.getClient().sendResponse(new InventoryRefreshComposer()); } - if (ownerTwo != null) - { + if (ownerTwo != null) { AchievementManager.progressAchievement(ownerTwo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantBreeder"), 5); seed = Emulator.getGameEnvironment().getItemManager().createItem(ownerTwo.getHabboInfo().getId(), seedBase, 0, 0, ""); ownerTwo.getInventory().getItemsComponent().addItem(seed); @@ -404,15 +344,13 @@ public class MonsterplantPet extends Pet implements IPetLook } @Override - public int getMaxEnergy() - { + public int getMaxEnergy() { return MonsterplantPet.timeToLive; } + @Override - public int getEnergy() - { - if (this.isDead()) - { + public int getEnergy() { + if (this.isDead()) { return 100; } @@ -420,8 +358,7 @@ public class MonsterplantPet extends Pet implements IPetLook } @Override - public void scratched(Habbo habbo) - { + public void scratched(Habbo habbo) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5); this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive); this.addExperience(10); @@ -430,8 +367,7 @@ public class MonsterplantPet extends Pet implements IPetLook } @Override - public boolean canWalk() - { + public boolean canWalk() { return false; } } 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 b28b91ab..8b41ebb2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -1,4 +1,3 @@ - package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; @@ -21,60 +20,27 @@ import java.util.Calendar; import java.util.Map; import java.util.TimeZone; -public class Pet implements ISerialize, Runnable -{ - - protected int id; - - - protected int userId; - - - protected Room room; - - - protected String name; - - - protected PetData petData; - - - protected int race; - - - protected String color; - - - protected int happyness; - +public class Pet implements ISerialize, Runnable { public int levelThirst; - - public int levelHunger; - - - protected int experience; - - - protected int energy; - - - protected int respect; - - - protected int created; - - - protected int level; - public boolean needsUpdate = false; - - private int chatTimeout; - RoomUnit roomUnit; - public boolean packetUpdate = false; - + protected int id; + protected int userId; + protected Room room; + protected String name; + protected PetData petData; + protected int race; + protected String color; + protected int happyness; + protected int experience; + protected int energy; + protected int respect; + protected int created; + protected int level; + RoomUnit roomUnit; + private int chatTimeout; private int tickTimeout = Emulator.getIntUnixTimestamp(); private int happynessDelay = Emulator.getIntUnixTimestamp(); private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); @@ -87,16 +53,14 @@ public class Pet implements ISerialize, Runnable private boolean muted = false; - public Pet(ResultSet set) throws SQLException - { + public Pet(ResultSet set) throws SQLException { super(); this.id = set.getInt("id"); this.userId = set.getInt("user_id"); this.room = null; this.name = set.getString("name"); this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(set.getInt("type")); - if (this.petData == null) - { + if (this.petData == null) { Emulator.getLogging().logErrorLine("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!"); this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(0); } @@ -112,16 +76,14 @@ public class Pet implements ISerialize, Runnable this.level = PetManager.getLevel(this.experience); } - public Pet(int type, int race, String color, String name, int userId) - { + public Pet(int type, int race, String color, String name, int userId) { this.id = 0; this.userId = userId; this.room = null; this.name = name; this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(type); - if(this.petData == null) - { + if (this.petData == null) { Emulator.getLogging().logErrorLine(new Exception("WARNING! Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!")); } @@ -138,69 +100,59 @@ public class Pet implements ISerialize, Runnable } - protected void say(String message) - { - if(this.roomUnit != null && this.room != null && !message.isEmpty()) - { + protected void say(String message) { + if (this.roomUnit != null && this.room != null && !message.isEmpty()) { RoomChatMessage chatMessage = new RoomChatMessage(message, this.roomUnit, RoomChatMessageBubbles.NORMAL); PetTalkEvent talkEvent = new PetTalkEvent(this, chatMessage); - if (!Emulator.getPluginManager().fireEvent(talkEvent).isCancelled()) - { + if (!Emulator.getPluginManager().fireEvent(talkEvent).isCancelled()) { this.room.petChat(new RoomUserTalkComposer(chatMessage).compose()); } } } - public void say(PetVocal vocal) - { - if(vocal != null) + public void say(PetVocal vocal) { + if (vocal != null) this.say(vocal.message); } - public void addEnergy(int amount) - { + public void addEnergy(int amount) { this.energy += amount; - if(this.energy > PetManager.maxEnergy(this.level)) + if (this.energy > PetManager.maxEnergy(this.level)) this.energy = PetManager.maxEnergy(this.level); - if(this.energy < 0) + if (this.energy < 0) this.energy = 0; } - public void addHappyness(int amount) - { + public void addHappyness(int amount) { this.happyness += amount; - if(this.happyness > 100) + if (this.happyness > 100) this.happyness = 100; - if(this.happyness < 0) + if (this.happyness < 0) this.happyness = 0; } - public int getRespect() - { + public int getRespect() { return this.respect; } - public void addRespect() - { + public void addRespect() { this.respect++; } - public int daysAlive() - { + public int daysAlive() { return (Emulator.getIntUnixTimestamp() - this.created) / 86400; } - public String bornDate() - { + public String bornDate() { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); cal.setTime(new java.util.Date(this.created)); @@ -209,16 +161,11 @@ public class Pet implements ISerialize, Runnable } @Override - public void run() - { - if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - if (this.id > 0) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happyness = ?, created = ? WHERE id = ?")) - { + public void run() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + if (this.id > 0) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happyness = ?, created = ? WHERE id = ?")) { statement.setInt(1, (this.room == null ? 0 : this.room.getId())); statement.setInt(2, this.experience); statement.setInt(3, this.energy); @@ -234,18 +181,14 @@ public class Pet implements ISerialize, Runnable statement.setInt(13, this.id); statement.execute(); } - } - else if (this.id == 0) - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_pets (user_id, room_id, name, race, type, color, experience, energy, respect, created) VALUES (?, 0, ?, ?, ?, ?, 0, 0, 0, ?)", Statement.RETURN_GENERATED_KEYS)) - { + } else if (this.id == 0) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_pets (user_id, room_id, name, race, type, color, experience, energy, respect, created) VALUES (?, 0, ?, ?, ?, ?, 0, 0, 0, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.userId); statement.setString(2, this.name); statement.setInt(3, this.race); statement.setInt(4, 0); - if (this.petData != null) - { + if (this.petData != null) { statement.setInt(4, this.petData.getType()); } @@ -253,18 +196,14 @@ public class Pet implements ISerialize, Runnable statement.setInt(6, this.created); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { this.id = set.getInt(1); } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -272,51 +211,41 @@ public class Pet implements ISerialize, Runnable } } - public void cycle() - { + public void cycle() { this.idleCommandTicks++; int time = Emulator.getIntUnixTimestamp(); - if(this.roomUnit != null && this.task != PetTasks.RIDE) - { - if(time - this.gestureTickTimeout > 5) - { + if (this.roomUnit != null && this.task != PetTasks.RIDE) { + if (time - this.gestureTickTimeout > 5) { this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); this.packetUpdate = true; } - if(time - this.postureTimeout > 1 && this.task == null) - { + if (time - this.postureTimeout > 1 && this.task == null) { this.clearPosture(); this.postureTimeout = time + 120; } - if (this.freeCommandTicks > 0) - { + if (this.freeCommandTicks > 0) { this.freeCommandTicks--; - if (this.freeCommandTicks == 0) - { + if (this.freeCommandTicks == 0) { this.freeCommand(); } } - if(!this.roomUnit.isWalking()) - { + if (!this.roomUnit.isWalking()) { this.roomUnit.removeStatus(RoomUnitStatus.MOVE); - if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) - { + if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) { RoomTile tile = this.room.getRandomWalkableTile(); - if (tile != null) - { + if (tile != null) { this.roomUnit.setGoalLocation(tile); } } - if (this.task == PetTasks.NEST || this.task == PetTasks.DOWN) - { + if (this.task == PetTasks.NEST || this.task == PetTasks.DOWN) { if (this.levelHunger > 0) this.levelHunger--; @@ -327,8 +256,7 @@ public class Pet implements ISerialize, Runnable this.addHappyness(1); - if (this.energy == PetManager.maxEnergy(this.level)) - { + if (this.energy == PetManager.maxEnergy(this.level)) { this.roomUnit.removeStatus(RoomUnitStatus.LAY); this.roomUnit.setCanWalk(true); this.roomUnit.setGoalLocation(this.room.getRandomWalkableTile()); @@ -336,73 +264,58 @@ public class Pet implements ISerialize, Runnable this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); this.gestureTickTimeout = time; } - } - else if(this.tickTimeout >= 5) - { - if(this.levelHunger < 100) + } else if (this.tickTimeout >= 5) { + if (this.levelHunger < 100) this.levelHunger++; - if(this.levelThirst < 100) + if (this.levelThirst < 100) this.levelThirst++; - if(this.energy < PetManager.maxEnergy(this.level)) + if (this.energy < PetManager.maxEnergy(this.level)) this.energy++; this.tickTimeout = time; } - } - else - { + } else { int timeout = Emulator.getRandom().nextInt(10) * 2; this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time); - if(this.energy >= 2) + if (this.energy >= 2) this.addEnergy(-1); - if(this.levelHunger < 100) + if (this.levelHunger < 100) this.levelHunger++; - if(this.levelThirst < 100) + if (this.levelThirst < 100) this.levelThirst++; - if(this.happyness > 0 && time - this.happynessDelay >= 30) - { + if (this.happyness > 0 && time - this.happynessDelay >= 30) { this.happyness--; this.happynessDelay = time; } } - if(time - this.gestureTickTimeout > 15) - { + if (time - this.gestureTickTimeout > 15) { this.updateGesture(time); - } - else if(time - this.randomActionTickTimeout > 30) - { + } else if (time - this.randomActionTickTimeout > 30) { this.randomAction(); this.randomActionTickTimeout = time + (10 * Emulator.getRandom().nextInt(60)); } - if(!this.muted) - { - if (this.chatTimeout <= time) - { - if (this.energy <= 30) - { + if (!this.muted) { + if (this.chatTimeout <= time) { + if (this.energy <= 30) { this.say(this.petData.randomVocal(PetVocalsType.TIRED)); - if(this.energy <= 10) + if (this.energy <= 10) this.findNest(); - } else if (this.happyness > 85) - { + } else if (this.happyness > 85) { this.say(this.petData.randomVocal(PetVocalsType.GENERIC_HAPPY)); - } else if (this.happyness < 15) - { + } else if (this.happyness < 15) { this.say(this.petData.randomVocal(PetVocalsType.GENERIC_SAD)); - } else if (this.levelHunger > 50) - { + } else if (this.levelHunger > 50) { this.say(this.petData.randomVocal(PetVocalsType.HUNGRY)); this.eat(); - } else if (this.levelThirst > 50) - { + } else if (this.levelThirst > 50) { this.say(this.petData.randomVocal(PetVocalsType.THIRSTY)); this.drink(); } @@ -415,8 +328,7 @@ public class Pet implements ISerialize, Runnable } - public void handleCommand(PetCommand command, Habbo habbo, String[] data) - { + public void handleCommand(PetCommand command, Habbo habbo, String[] data) { this.idleCommandTicks = 0; command.handle(this, habbo, data); @@ -424,13 +336,11 @@ public class Pet implements ISerialize, Runnable } - public boolean canWalk() - { - if(this.task == null) + public boolean canWalk() { + if (this.task == null) return true; - switch(this.task) - { + switch (this.task) { case DOWN: case FLAT: case HERE: @@ -451,24 +361,22 @@ public class Pet implements ISerialize, Runnable return true; } - public void clearPosture() - { + public void clearPosture() { THashMap keys = new THashMap<>(); - if(this.roomUnit.hasStatus(RoomUnitStatus.MOVE)) + if (this.roomUnit.hasStatus(RoomUnitStatus.MOVE)) keys.put(RoomUnitStatus.MOVE, this.roomUnit.getStatus(RoomUnitStatus.MOVE)); - if(this.roomUnit.hasStatus(RoomUnitStatus.SIT)) + if (this.roomUnit.hasStatus(RoomUnitStatus.SIT)) keys.put(RoomUnitStatus.SIT, this.roomUnit.getStatus(RoomUnitStatus.SIT)); - if(this.roomUnit.hasStatus(RoomUnitStatus.LAY)) + if (this.roomUnit.hasStatus(RoomUnitStatus.LAY)) keys.put(RoomUnitStatus.LAY, this.roomUnit.getStatus(RoomUnitStatus.LAY)); - if(this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) + if (this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE)); - if(this.task == null) - { + if (this.task == null) { boolean isDead = false; if (this.roomUnit.hasStatus(RoomUnitStatus.RIP)) isDead = true; @@ -476,8 +384,7 @@ public class Pet implements ISerialize, Runnable this.roomUnit.clearStatus(); if (isDead) this.roomUnit.setStatus(RoomUnitStatus.RIP, ""); - for (Map.Entry entry : keys.entrySet()) - { + for (Map.Entry entry : keys.entrySet()) { this.roomUnit.setStatus(entry.getKey(), entry.getValue()); } } @@ -485,52 +392,39 @@ public class Pet implements ISerialize, Runnable this.packetUpdate = true; } - public void updateGesture(int time) - { + public void updateGesture(int time) { this.gestureTickTimeout = time; - if (this.energy < 30) - { + if (this.energy < 30) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); this.findNest(); - } - else if(this.happyness == 100) - { + } else if (this.happyness == 100) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); - } else if (this.happyness >= 90) - { + } else if (this.happyness >= 90) { this.randomHappyAction(); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); - } else if (this.happyness <= 5) - { + } else if (this.happyness <= 5) { this.randomSadAction(); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); - } else if (this.levelHunger > 80) - { + } else if (this.levelHunger > 80) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey()); this.eat(); - } else if (this.levelThirst > 80) - { + } else if (this.levelThirst > 80) { this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey()); this.drink(); - } - else if(this.idleCommandTicks > 240) - { + } else if (this.idleCommandTicks > 240) { this.idleCommandTicks = 0; this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey()); } } + @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.id); message.appendString(this.name); - if (this.petData != null) - { + if (this.petData != null) { message.appendInt(this.petData.getType()); - } - else - { + } else { message.appendInt(-1); } message.appendInt(this.race); @@ -541,16 +435,12 @@ public class Pet implements ISerialize, Runnable } - public void findNest() - { + public void findNest() { HabboItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests()); this.roomUnit.setCanWalk(true); - if(item != null) - { + if (item != null) { this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); - } - else - { + } else { this.roomUnit.setStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.roomUnit.getX(), this.roomUnit.getY(), false) + ""); this.say(this.petData.randomVocal(PetVocalsType.SLEEPING)); this.task = PetTasks.DOWN; @@ -558,23 +448,19 @@ public class Pet implements ISerialize, Runnable } - public void drink() - { + public void drink() { HabboItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks()); - if(item != null) - { + if (item != null) { this.roomUnit.setCanWalk(true); this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } } - public void eat() - { + public void eat() { HabboItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods()); { - if(item != null) - { + if (item != null) { this.roomUnit.setCanWalk(true); this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } @@ -582,12 +468,10 @@ public class Pet implements ISerialize, Runnable } - public void findToy() - { + public void findToy() { HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys()); { - if(item != null) - { + if (item != null) { this.roomUnit.setCanWalk(true); this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } @@ -595,56 +479,45 @@ public class Pet implements ISerialize, Runnable } - public void randomHappyAction() - { - if (this.petData.actionsHappy.length > 0) - { + public void randomHappyAction() { + if (this.petData.actionsHappy.length > 0) { this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), ""); } } - public void randomSadAction() - { - if (this.petData.actionsTired.length > 0) - { + public void randomSadAction() { + if (this.petData.actionsTired.length > 0) { this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), ""); } } - public void randomAction() - { - if (this.petData.actionsRandom.length > 0) - { + public void randomAction() { + if (this.petData.actionsRandom.length > 0) { this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), ""); } } - public void addExperience(int amount) - { + public void addExperience(int amount) { this.experience += amount; - if(this.room != null) - { + if (this.room != null) { this.room.sendComposer(new RoomPetExperienceComposer(this, amount).compose()); - if(this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) - { + if (this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) { this.levelUp(); } } } - protected void levelUp() - { + protected void levelUp() { if (this.level >= PetManager.experiences.length) return; - if (this.experience < PetManager.experiences[this.level]) - { + if (this.experience < PetManager.experiences[this.level]) { this.experience = PetManager.experiences[this.level]; } this.level++; @@ -657,32 +530,29 @@ public class Pet implements ISerialize, Runnable } - public void addThirst(int amount) - { + public void addThirst(int amount) { this.levelThirst += amount; - if(this.levelThirst > 100) + if (this.levelThirst > 100) this.levelThirst = 100; - if(this.levelThirst < 0) + if (this.levelThirst < 0) this.levelThirst = 0; } - public void addHunger(int amount) - { + public void addHunger(int amount) { this.levelHunger += amount; - if(this.levelHunger > 100) + if (this.levelHunger > 100) this.levelHunger = 100; - if(this.levelHunger < 0) + if (this.levelHunger < 0) this.levelHunger = 0; } - public void freeCommand() - { + public void freeCommand() { this.task = null; this.roomUnit.setGoalLocation(this.getRoomUnit().getCurrentLocation()); this.roomUnit.clearStatus(); @@ -691,13 +561,11 @@ public class Pet implements ISerialize, Runnable } - public void scratched(Habbo habbo) - { + public void scratched(Habbo habbo) { this.addExperience(10); this.addRespect(); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().petRespectPointsToGive--; habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomPetRespectComposer(this).compose()); @@ -708,173 +576,139 @@ public class Pet implements ISerialize, Runnable } - public int getId() - { + public int getId() { return this.id; } - public int getUserId() - { + public int getUserId() { return this.userId; } - public void setUserId(int userId) - { + public void setUserId(int userId) { this.userId = userId; } - public Room getRoom() - { + public Room getRoom() { return this.room; } - public void setRoom(Room room) - { + public void setRoom(Room room) { this.room = room; } - public String getName() - { + public String getName() { return this.name; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } - public PetData getPetData() - { + public PetData getPetData() { return this.petData; } - public void setPetData(PetData petData) - { + public void setPetData(PetData petData) { this.petData = petData; } - public int getRace() - { + public int getRace() { return this.race; } - public void setRace(int race) - { + public void setRace(int race) { this.race = race; } - public String getColor() - { + public String getColor() { return this.color; } - public void setColor(String color) - { + public void setColor(String color) { this.color = color; } - public int getHappyness() - { + public int getHappyness() { return this.happyness; } - public void setHappyness(int happyness) - { + public void setHappyness(int happyness) { this.happyness = happyness; } - public int getExperience() - { + public int getExperience() { return this.experience; } - public void setExperience(int experience) - { + public void setExperience(int experience) { this.experience = experience; } - public int getEnergy() - { + public int getEnergy() { return this.energy; } - public int getMaxEnergy() - { - return this.level * 100; - } - - public void setEnergy(int energy) - { + public void setEnergy(int energy) { this.energy = energy; } - public int getCreated() - { + public int getMaxEnergy() { + return this.level * 100; + } + + public int getCreated() { return this.created; } - public void setCreated(int created) - { + public void setCreated(int created) { this.created = created; } - public int getLevel() - { + public int getLevel() { return this.level; } - public void setLevel(int level) - { + public void setLevel(int level) { this.level = level; } - public RoomUnit getRoomUnit() - { + public RoomUnit getRoomUnit() { return this.roomUnit; } - public void setRoomUnit(RoomUnit roomUnit) - { + public void setRoomUnit(RoomUnit roomUnit) { this.roomUnit = roomUnit; } - public PetTasks getTask() - { + public PetTasks getTask() { return this.task; } - public void setTask(PetTasks newTask) - { + public void setTask(PetTasks newTask) { this.task = newTask; } - public boolean isMuted() - { + public boolean isMuted() { return this.muted; } - public void setMuted(boolean muted) - { + public void setMuted(boolean muted) { this.muted = muted; } - public int getLevelThirst() - { + public int getLevelThirst() { return this.levelThirst; } - public void setLevelThirst(int levelThirst) - { + public void setLevelThirst(int levelThirst) { this.levelThirst = levelThirst; } - public int getLevelHunger() - { + public int getLevelHunger() { return this.levelHunger; } - public void setLevelHunger(int levelHunger) - { + public void setLevelHunger(int levelHunger) { this.levelHunger = levelHunger; } @@ -884,11 +718,11 @@ public class Pet implements ISerialize, Runnable public void removeFromRoom(boolean dontSendPackets) { - if(this.roomUnit != null && this.roomUnit.getCurrentLocation() != null) { + if (this.roomUnit != null && this.roomUnit.getCurrentLocation() != null) { this.roomUnit.getCurrentLocation().removeUnit(this.roomUnit); } - if(!dontSendPackets) { + if (!dontSendPackets) { room.sendComposer(new RoomUserRemoveComposer(this.roomUnit).compose()); room.removePet(this.id); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetAction.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetAction.java index 1e418ad6..919da879 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetAction.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetAction.java @@ -6,29 +6,17 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; import java.util.List; -public abstract class PetAction -{ - - public int minimumActionDuration = 500; - +public abstract class PetAction { public final PetTasks petTask; - - public final boolean stopsPetWalking; - - public final List statusToRemove = new ArrayList<>(); + public final List statusToSet = new ArrayList<>(); + public int minimumActionDuration = 500; + public String gestureToSet = null; - - public String gestureToSet = null; - - - public final List statusToSet = new ArrayList<>(); - - protected PetAction(PetTasks petTask, boolean stopsPetWalking) - { - this.petTask = petTask; + protected PetAction(PetTasks petTask, boolean stopsPetWalking) { + this.petTask = petTask; this.stopsPetWalking = stopsPetWalking; } 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 38c216fc..82720c52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetBreedingReward.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.pets; import java.sql.ResultSet; import java.sql.SQLException; -public class PetBreedingReward -{ +public class PetBreedingReward { public final int petType; @@ -14,8 +13,7 @@ public class PetBreedingReward public final int breed; - public PetBreedingReward(ResultSet set) throws SQLException - { + public PetBreedingReward(ResultSet set) throws SQLException { this.petType = set.getInt("pet_type"); this.rarityLevel = set.getInt("rarity_level"); this.breed = set.getInt("breed"); 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 da071b43..e2ca68ad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -7,8 +7,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class PetCommand implements Comparable -{ +public class PetCommand implements Comparable { public final int id; @@ -30,48 +29,38 @@ public class PetCommand implements Comparable public final PetAction action; - public PetCommand(ResultSet set, PetAction action) throws SQLException - { - this.id = set.getInt("command_id"); - this.key = set.getString("text"); - 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.action = action; + public PetCommand(ResultSet set, PetAction action) throws SQLException { + this.id = set.getInt("command_id"); + this.key = set.getString("text"); + 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.action = action; } @Override - public int compareTo(PetCommand o) - { + public int compareTo(PetCommand o) { return this.level - o.level; } - public void handle(Pet pet, Habbo habbo, String[] data) - { - if(Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) - { + public void handle(Pet pet, Habbo habbo, String[] data) { + if (Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) { pet.say(pet.petData.randomVocal(PetVocalsType.DISOBEY)); return; } - if (this.action != null) - { - if (this.action.petTask != pet.getTask()) - { - if (this.action.stopsPetWalking) - { + if (this.action != null) { + if (this.action.petTask != pet.getTask()) { + if (this.action.stopsPetWalking) { pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentLocation()); } - if (this.action.apply(pet, habbo, data)) - { - for (RoomUnitStatus status : this.action.statusToRemove) - { + if (this.action.apply(pet, habbo, data)) { + for (RoomUnitStatus status : this.action.statusToRemove) { pet.getRoomUnit().removeStatus(status); } - for (RoomUnitStatus status : this.action.statusToSet) - { + for (RoomUnitStatus status : this.action.statusToSet) { pet.getRoomUnit().setStatus(status, "0"); } 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 ce3a3728..9479b16d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -16,76 +16,35 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class PetData implements Comparable -{ - - private int type; - - - private String name; - +public class PetData implements Comparable { public static final String BLINK = "eyb"; - - public static final String SPEAK = "spk"; - - public static final String EAT = "eat"; public static final String PLAYFUL = "pla"; - - - public String[] actionsHappy; - - - public String[] actionsTired; - - - public String[] actionsRandom; - - - private List petCommands; - - - private List nestItems; - - - private List foodItems; - - - private List drinkItems; - - - private List toyItems; - - public static final List generalDrinkItems = new ArrayList<>(); - - public static final List generalFoodItems = new ArrayList<>(); - - public static final List generalNestItems = new ArrayList<>(); - - public static final List generalToyItems = new ArrayList<>(); - - - public THashMap> petVocals; - - public static final THashMap> generalPetVocals = new THashMap<>(); - - + public String[] actionsHappy; + public String[] actionsTired; + public String[] actionsRandom; + public THashMap> petVocals; + private int type; + private String name; + private List petCommands; + private List nestItems; + private List foodItems; + private List drinkItems; + private List toyItems; private int offspringType; - public PetData(ResultSet set) throws SQLException - { + public PetData(ResultSet set) throws SQLException { this.load(set); } - public void load(ResultSet set) throws SQLException - { + public void load(ResultSet set) throws SQLException { this.type = set.getInt("pet_type"); this.name = set.getString("pet_name"); this.offspringType = set.getInt("offspring_type"); @@ -96,74 +55,60 @@ public class PetData implements Comparable this.reset(); } - public void setPetCommands(List petCommands) - { - this.petCommands = petCommands; - } - - public List getPetCommands() - { + public List getPetCommands() { return this.petCommands; } + public void setPetCommands(List petCommands) { + this.petCommands = petCommands; + } - public int getType() - { + public int getType() { return this.type; } - public String getName() - { + public String getName() { return this.name; } - public int getOffspringType() - { + public int getOffspringType() { return this.offspringType; } - public void addNest(Item nest) - { - if(nest != null) + public void addNest(Item nest) { + if (nest != null) this.nestItems.add(nest); } - public List getNests() - { + public List getNests() { return this.nestItems; } - public boolean haveNest(HabboItem nest) - { + public boolean haveNest(HabboItem nest) { return this.haveNest(nest.getBaseItem()); } - boolean haveNest(Item nest) - { + boolean haveNest(Item nest) { return PetData.generalNestItems.contains(nest) || this.nestItems.contains(nest); } - public HabboItem randomNest(THashSet items) - { + public HabboItem randomNest(THashSet items) { List nestList = new ArrayList<>(); - for(InteractionNest nest : items) - { - if(this.haveNest(nest)) - { + for (InteractionNest nest : items) { + if (this.haveNest(nest)) { nestList.add(nest); } } - if(!nestList.isEmpty()) - { + if (!nestList.isEmpty()) { Collections.shuffle(nestList); return nestList.get(0); @@ -173,44 +118,36 @@ public class PetData implements Comparable } - public void addFoodItem(Item food) - { + public void addFoodItem(Item food) { this.foodItems.add(food); } - public List getFoodItems() - { + public List getFoodItems() { return this.foodItems; } - public boolean haveFoodItem(HabboItem food) - { + public boolean haveFoodItem(HabboItem food) { return this.haveFoodItem(food.getBaseItem()); } - boolean haveFoodItem(Item food) - { + boolean haveFoodItem(Item food) { return this.foodItems.contains(food) || PetData.generalFoodItems.contains(food); } - public HabboItem randomFoodItem(THashSet items) - { + public HabboItem randomFoodItem(THashSet items) { List foodList = new ArrayList<>(); - for(InteractionPetFood food : items) - { - if(this.haveFoodItem(food)) - { + for (InteractionPetFood food : items) { + if (this.haveFoodItem(food)) { foodList.add(food); } } - if(!foodList.isEmpty()) - { + if (!foodList.isEmpty()) { Collections.shuffle(foodList); return foodList.get(0); } @@ -219,44 +156,36 @@ public class PetData implements Comparable } - public void addDrinkItem(Item item) - { + public void addDrinkItem(Item item) { this.drinkItems.add(item); } - public List getDrinkItems() - { + public List getDrinkItems() { return this.drinkItems; } - public boolean haveDrinkItem(HabboItem item) - { + public boolean haveDrinkItem(HabboItem item) { return this.haveDrinkItem(item.getBaseItem()); } - boolean haveDrinkItem(Item item) - { + boolean haveDrinkItem(Item item) { return this.drinkItems.contains(item) || PetData.generalDrinkItems.contains(item); } - public HabboItem randomDrinkItem(THashSet items) - { + public HabboItem randomDrinkItem(THashSet items) { List drinkList = new ArrayList<>(); - for(InteractionPetDrink drink : items) - { - if(this.haveDrinkItem(drink)) - { + for (InteractionPetDrink drink : items) { + if (this.haveDrinkItem(drink)) { drinkList.add(drink); } } - if(!drinkList.isEmpty()) - { + if (!drinkList.isEmpty()) { Collections.shuffle(drinkList); return drinkList.get(0); } @@ -265,44 +194,36 @@ public class PetData implements Comparable } - public void addToyItem(Item toy) - { + public void addToyItem(Item toy) { this.toyItems.add(toy); } - public List getToyItems() - { + public List getToyItems() { return this.toyItems; } - public boolean haveToyItem(HabboItem toy) - { + public boolean haveToyItem(HabboItem toy) { return this.haveToyItem(toy.getBaseItem()); } - public boolean haveToyItem(Item toy) - { + public boolean haveToyItem(Item toy) { return this.toyItems.contains(toy) || PetData.generalToyItems.contains(toy); } - public HabboItem randomToyItem(THashSet toys) - { + public HabboItem randomToyItem(THashSet toys) { List toyList = new ArrayList<>(); - for(InteractionPetToy toy : toys) - { - if(this.haveToyItem(toy)) - { + for (InteractionPetToy toy : toys) { + if (this.haveToyItem(toy)) { toyList.add(toy); } } - if(!toyList.isEmpty()) - { + if (!toyList.isEmpty()) { Collections.shuffle(toyList); return toyList.get(0); } @@ -311,31 +232,28 @@ public class PetData implements Comparable } - public PetVocal randomVocal(PetVocalsType type) - { + public PetVocal randomVocal(PetVocalsType type) { //TODO: Remove this useless copying. List vocals = new ArrayList<>(); - if(this.petVocals.get(type) != null) + if (this.petVocals.get(type) != null) vocals.addAll(this.petVocals.get(type)); - if(PetData.generalPetVocals.get(type) != null) + if (PetData.generalPetVocals.get(type) != null) vocals.addAll(PetData.generalPetVocals.get(type)); - if(vocals.isEmpty()) + if (vocals.isEmpty()) return null; return vocals.get(Emulator.getRandom().nextInt(vocals.size())); } @Override - public int compareTo(PetData o) - { + public int compareTo(PetData o) { return this.getType() - o.getType(); } - public void reset() - { + public void reset() { this.petCommands = new ArrayList<>(); this.nestItems = new ArrayList<>(); this.foodItems = new ArrayList<>(); @@ -344,15 +262,12 @@ public class PetData implements Comparable this.petVocals = new THashMap<>(); - for(PetVocalsType type : PetVocalsType.values()) - { + for (PetVocalsType type : PetVocalsType.values()) { this.petVocals.put(type, new THashSet<>()); } - if(PetData.generalPetVocals.isEmpty()) - { - for(PetVocalsType type : PetVocalsType.values()) - { + if (PetData.generalPetVocals.isEmpty()) { + for (PetVocalsType type : PetVocalsType.values()) { PetData.generalPetVocals.put(type, new THashSet<>()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetGestures.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetGestures.java index 60e801be..61f0aed7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetGestures.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetGestures.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.pets; -public enum PetGestures -{ +public enum PetGestures { THIRSTY("thr"), TIRED("trd"), PLAYFULL("plf"), @@ -16,13 +15,11 @@ public enum PetGestures private final String key; - PetGestures(String key) - { + PetGestures(String key) { this.key = key; } - public String getKey() - { + public String getKey() { return this.key; } } 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 a8564f34..82301279 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -25,16 +25,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; -public class PetManager -{ - 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}; - - private final THashMap> petRaces; - private final THashMap petData; - private final TIntIntMap breedingPetType; - private final THashMap>> breedingReward; - public final THashMap petActions = new THashMap() - { +public class PetManager { + 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() { { this.put(0, new ActionFree()); this.put(1, new ActionSit()); @@ -69,9 +63,13 @@ public class PetManager } }; + private final THashMap> petRaces; + private final THashMap petData; + private final TIntIntMap breedingPetType; + private final THashMap>> breedingReward; - public PetManager() - { + + public PetManager() { long millis = System.currentTimeMillis(); this.petRaces = new THashMap<>(); @@ -84,59 +82,97 @@ public class PetManager Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } + public static int getLevel(int experience) { + int index = 0; - public void reloadPetData() - { + for (int i = 0; i < experiences.length; i++) { + if (experiences[i] > experience) { + index = i; + break; + } + } + + return index + 1; + } + + public static int maxEnergy(int level) { + //TODO: Add energy calculation. + return 100 * level; + } + + public static int randomBody(int minimumRarity) { + int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0); + return MonsterplantPet.bodyRarity.get(MonsterplantPet.bodyRarity.keySet().toArray()[randomRarity]).getValue(); + } + + public static int randomColor(int minimumRarity) { + int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0); + return MonsterplantPet.colorRarity.get(MonsterplantPet.colorRarity.keySet().toArray()[randomRarity]).getValue(); + } + + public static int random(int low, int high, double bias) { + double r = Math.random(); + r = Math.pow(r, bias); + return (int) (low + (high - low) * r); + } + + public static Pet loadPet(ResultSet set) throws SQLException { + if (set.getInt("type") == 15) + return new HorsePet(set); + else if (set.getInt("type") == 16) + return new MonsterplantPet(set); + else if (set.getInt("type") == 26 || set.getInt("type") == 27) + return new GnomePet(set); + else + return new Pet(set); + } + + public static NormalDistribution getNormalDistributionForBreeding(int levelOne, int levelTwo) { + return getNormalDistributionForBreeding((levelOne + levelTwo) / 2); + } + + public static NormalDistribution getNormalDistributionForBreeding(double avgLevel) { + return new NormalDistribution(avgLevel, (20 - (avgLevel / 2)) / 2); + } + + public void reloadPetData() { this.petRaces.clear(); this.petData.clear(); this.breedingPetType.clear(); this.breedingReward.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { this.loadRaces(connection); this.loadPetData(connection); this.loadPetCommands(connection); this.loadPetBreeding(connection); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!"); } } - private void loadRaces(Connection connection) - { + private void loadRaces(Connection connection) { this.petRaces.clear(); - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeds ORDER BY race, color_one, color_two ASC")) - { - while(set.next()) - { - if(this.petRaces.get(set.getInt("race")) == null) + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeds ORDER BY race, color_one, color_two ASC")) { + while (set.next()) { + if (this.petRaces.get(set.getInt("race")) == null) this.petRaces.put(set.getInt("race"), new THashSet<>()); this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadPetData(Connection connection) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_actions ORDER BY pet_type ASC")) - { - while(set.next()) - { + private void loadPetData(Connection connection) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_actions ORDER BY pet_type ASC")) { + while (set.next()) { this.petData.put(set.getInt("pet_type"), new PetData(set)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -145,197 +181,149 @@ public class PetManager this.loadPetVocals(connection); } - private void loadPetItems(Connection connection) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_items")) - { - while(set.next()) - { + private void loadPetItems(Connection connection) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_items")) { + while (set.next()) { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("item_id")); - if(baseItem != null) - { - if(set.getInt("pet_id") == -1) - { - if(baseItem.getInteractionType().getType() == InteractionNest.class) PetData.generalNestItems.add(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetFood.class) PetData.generalFoodItems.add(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetDrink.class) PetData.generalDrinkItems.add(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetToy.class) PetData.generalToyItems.add(baseItem); - } - else - { + if (baseItem != null) { + if (set.getInt("pet_id") == -1) { + if (baseItem.getInteractionType().getType() == InteractionNest.class) + PetData.generalNestItems.add(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetFood.class) + PetData.generalFoodItems.add(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) + PetData.generalDrinkItems.add(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class) + PetData.generalToyItems.add(baseItem); + } else { PetData data = this.getPetData(set.getInt("pet_id")); - if(data != null) - { - if(baseItem.getInteractionType().getType() == InteractionNest.class) data.addNest(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetFood.class) data.addFoodItem(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetDrink.class) data.addDrinkItem(baseItem); - else if(baseItem.getInteractionType().getType() == InteractionPetToy.class) data.addToyItem(baseItem); + if (data != null) { + if (baseItem.getInteractionType().getType() == InteractionNest.class) + data.addNest(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetFood.class) + data.addFoodItem(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) + data.addDrinkItem(baseItem); + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class) + data.addToyItem(baseItem); } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadPetVocals(Connection connection) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_vocals")) - { - while(set.next()) - { - if(set.getInt("pet_id") >= 0) - { - if (this.petData.containsKey(set.getInt("pet_id"))) - { + private void loadPetVocals(Connection connection) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_vocals")) { + while (set.next()) { + if (set.getInt("pet_id") >= 0) { + if (this.petData.containsKey(set.getInt("pet_id"))) { PetVocalsType petVocalsType = PetVocalsType.valueOf(set.getString("type").toUpperCase()); - if (petVocalsType != null) - { + if (petVocalsType != null) { this.petData.get(set.getInt("pet_id")).petVocals.get(petVocalsType).add(new PetVocal(set.getString("message"))); - } - else - { + } else { Emulator.getLogging().logErrorLine("Unknown pet vocal type " + set.getString("type")); } - } - else - { + } else { Emulator.getLogging().logErrorLine("Missing pet_actions table entry for pet id " + set.getInt("pet_id")); } - } - else - { - if(!PetData.generalPetVocals.containsKey(PetVocalsType.valueOf(set.getString("type").toUpperCase()))) + } else { + if (!PetData.generalPetVocals.containsKey(PetVocalsType.valueOf(set.getString("type").toUpperCase()))) PetData.generalPetVocals.put(PetVocalsType.valueOf(set.getString("type").toUpperCase()), new THashSet<>()); PetData.generalPetVocals.get(PetVocalsType.valueOf(set.getString("type").toUpperCase())).add(new PetVocal(set.getString("message"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadPetCommands(Connection connection) - { + private void loadPetCommands(Connection connection) { THashMap commandsList = new THashMap<>(); - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands_data")) - { - while(set.next()) - { - commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands_data")) { + while (set.next()) { + commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) - { - while(set.next()) - { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) { + while (set.next()) { PetData data = this.petData.get(set.getInt("pet_id")); - if(data != null) - { + if (data != null) { data.getPetCommands().add(commandsList.get(set.getInt("command_id"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadPetBreeding(Connection connection) - { - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding")) - { - while (set.next()) - { + private void loadPetBreeding(Connection connection) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding")) { + while (set.next()) { this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) - { - while (set.next()) - { + 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)) - { + if (!this.breedingReward.containsKey(reward.petType)) { this.breedingReward.put(reward.petType, new TIntObjectHashMap<>()); } - if (!this.breedingReward.get(reward.petType).containsKey(reward.rarityLevel)) - { + if (!this.breedingReward.get(reward.petType).containsKey(reward.rarityLevel)) { this.breedingReward.get(reward.petType).put(reward.rarityLevel, new ArrayList<>()); } this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public THashSet getBreeds(String petName) - { - if(!petName.startsWith("a0 pet")) - { + public THashSet getBreeds(String petName) { + if (!petName.startsWith("a0 pet")) { Emulator.getLogging().logErrorLine("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!"); return null; } - try - { + try { int petId = Integer.valueOf(petName.split("t")[1]); return this.petRaces.get(petId); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - public TIntObjectHashMap> getBreedingRewards(int petType) - { + public TIntObjectHashMap> getBreedingRewards(int petType) { return this.breedingReward.get(petType); } - public int getRarityForOffspring(Pet pet) - { + public int getRarityForOffspring(Pet pet) { final int[] rarityLevel = {0}; TIntObjectHashMap> offspringList = this.breedingReward.get(pet.getPetData().getType()); - offspringList.forEachEntry(new TIntObjectProcedure>() - { + offspringList.forEachEntry(new TIntObjectProcedure>() { @Override - public boolean execute(int i, ArrayList petBreedingRewards) - { - for (PetBreedingReward reward : petBreedingRewards) - { - if (reward.breed == pet.getRace()) - { + public boolean execute(int i, ArrayList petBreedingRewards) { + for (PetBreedingReward reward : petBreedingRewards) { + if (reward.breed == pet.getRace()) { rarityLevel[0] = i; return false; } @@ -348,54 +336,22 @@ public class PetManager return 4 - rarityLevel[0]; } - public static int getLevel(int experience) - { - int index = 0; - - for(int i = 0; i < experiences.length; i++) - { - if(experiences[i] > experience) - { - index = i; - break; - } - } - - return index + 1; - } - - public static int maxEnergy(int level) - { - //TODO: Add energy calculation. - return 100 * level; - } - - public PetData getPetData(int type) - { - synchronized (this.petData) - { - if (this.petData.containsKey(type)) - { + public PetData getPetData(int type) { + synchronized (this.petData) { + if (this.petData.containsKey(type)) { return this.petData.get(type); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { Emulator.getLogging().logErrorLine("Missing petdata for type " + type + ". Adding this to the database..."); - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO pet_actions (pet_type) VALUES (?)")) - { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO pet_actions (pet_type) VALUES (?)")) { statement.setInt(1, type); statement.execute(); } - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM pet_actions WHERE pet_type = ? LIMIT 1")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM pet_actions WHERE pet_type = ? LIMIT 1")) { statement.setInt(1, type); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { PetData petData = new PetData(set); this.petData.put(type, petData); Emulator.getLogging().logErrorLine("Missing petdata for type " + type + " added to the database!"); @@ -403,9 +359,7 @@ public class PetManager } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -414,14 +368,10 @@ public class PetManager return null; } - public PetData getPetData(String petName) - { - synchronized (this.petData) - { - for (Map.Entry entry : this.petData.entrySet()) - { - if (entry.getValue().getName().equalsIgnoreCase(petName)) - { + public PetData getPetData(String petName) { + synchronized (this.petData) { + for (Map.Entry entry : this.petData.entrySet()) { + if (entry.getValue().getName().equalsIgnoreCase(petName)) { return entry.getValue(); } } @@ -430,17 +380,14 @@ public class PetManager return null; } - public Collection getPetData() - { + public Collection getPetData() { return this.petData.values(); } - public Pet createPet(Item item, String name, String race, String color, GameClient client) - { + public Pet createPet(Item item, String name, String race, String color, GameClient client) { int type = Integer.valueOf(item.getName().toLowerCase().replace("a0 pet", "")); - if (this.petData.containsKey(type)) - { + if (this.petData.containsKey(type)) { Pet pet; if (type == 15) pet = new HorsePet(type, Integer.valueOf(race), color, name, client.getHabbo().getHabboInfo().getId()); @@ -461,15 +408,12 @@ public class PetManager return null; } - public Pet createPet(int type, String name, GameClient client) - { + public Pet createPet(int type, String name, GameClient client) { return this.createPet(type, Emulator.getRandom().nextInt(this.petRaces.get(type).size() + 1), name, client); } - public Pet createPet(int type, int race, String name, GameClient client) - { - if (this.petData.containsKey(type)) - { + public Pet createPet(int type, int race, String name, GameClient client) { + if (this.petData.containsKey(type)) { Pet pet = new Pet(type, race, "FFFFFF", name, client.getHabbo().getHabboInfo().getId()); pet.needsUpdate = true; pet.run(); @@ -478,8 +422,7 @@ public class PetManager return null; } - public MonsterplantPet createMonsterplant(Room room, Habbo habbo, boolean rare, RoomTile t, int minimumRarity) - { + public MonsterplantPet createMonsterplant(Room room, Habbo habbo, boolean rare, RoomTile t, int minimumRarity) { MonsterplantPet pet = new MonsterplantPet( habbo.getHabboInfo().getId(), //Owner ID randomBody(rare ? 4 : minimumRarity), @@ -501,16 +444,15 @@ public class PetManager return pet; } - public Pet createGnome(String name, Room room, Habbo habbo) - { + public Pet createGnome(String name, Room room, Habbo habbo) { Pet pet = new GnomePet(26, 0, "FFFFFF", name, habbo.getHabboInfo().getId(), "5 " + - "0 -1 " + this.randomGnomeSkinColor() + " " + - "1 10" + (1 + Emulator.getRandom().nextInt(2)) + " " + this.randomGnomeColor() + " " + - "2 201 " + this.randomGnomeColor() + " " + - "3 30" + (1 + Emulator.getRandom().nextInt(2)) + " " + this.randomGnomeColor() + " " + - "4 40" + Emulator.getRandom().nextInt(2) + " " + this.randomGnomeColor() - ); + "0 -1 " + this.randomGnomeSkinColor() + " " + + "1 10" + (1 + Emulator.getRandom().nextInt(2)) + " " + this.randomGnomeColor() + " " + + "2 201 " + this.randomGnomeColor() + " " + + "3 30" + (1 + Emulator.getRandom().nextInt(2)) + " " + this.randomGnomeColor() + " " + + "4 40" + Emulator.getRandom().nextInt(2) + " " + this.randomGnomeColor() + ); pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); @@ -522,8 +464,7 @@ public class PetManager return pet; } - public Pet createLeprechaun(String name, Room room, Habbo habbo) - { + public Pet createLeprechaun(String name, Room room, Habbo habbo) { Pet pet = new GnomePet(27, 0, "FFFFFF", name, habbo.getHabboInfo().getId(), "5 " + "0 -1 0 " + @@ -543,83 +484,32 @@ public class PetManager return pet; } - private int randomGnomeColor() - { + private int randomGnomeColor() { int color = 19; - while (color == 19 || color == 27) - { + while (color == 19 || color == 27) { color = Emulator.getRandom().nextInt(34); } return color; } - private int randomLeprechaunColor() - { + private int randomLeprechaunColor() { return Emulator.getRandom().nextInt(2) == 1 ? 19 : 27; } - static int[] skins = new int[]{0, 1, 6, 7}; - private int randomGnomeSkinColor() - { + private int randomGnomeSkinColor() { return skins[Emulator.getRandom().nextInt(skins.length)]; } - public static int randomBody(int minimumRarity) - { - int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0); - return MonsterplantPet.bodyRarity.get(MonsterplantPet.bodyRarity.keySet().toArray()[randomRarity]).getValue(); - } - - public static int randomColor(int minimumRarity) - { - int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0); - return MonsterplantPet.colorRarity.get(MonsterplantPet.colorRarity.keySet().toArray()[randomRarity]).getValue(); - } - - public static int random(int low, int high, double bias) - { - double r = Math.random(); - r = Math.pow(r, bias); - return (int) (low + (high - low) * r); - } - - public static Pet loadPet(ResultSet set) throws SQLException - { - if(set.getInt("type") == 15) - return new HorsePet(set); - else if(set.getInt("type") == 16) - return new MonsterplantPet(set); - else if (set.getInt("type") == 26 || set.getInt("type") == 27) - return new GnomePet(set); - else - return new Pet(set); - } - - - public boolean deletePet(Pet pet) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_pets WHERE id = ? LIMIT 1")) - { + public boolean deletePet(Pet pet) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_pets WHERE id = ? LIMIT 1")) { statement.setInt(1, pet.getId()); return statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return false; } - - public static NormalDistribution getNormalDistributionForBreeding(int levelOne, int levelTwo) - { - return getNormalDistributionForBreeding((levelOne + levelTwo) / 2); - } - - public static NormalDistribution getNormalDistributionForBreeding(double avgLevel) - { - return new NormalDistribution(avgLevel, (20 - (avgLevel / 2)) / 2); - } } \ No newline at end of file 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 f7935cca..c02d6a41 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetRace.java @@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.pets; import java.sql.ResultSet; import java.sql.SQLException; -public class PetRace -{ +public class PetRace { public final int race; @@ -20,8 +19,7 @@ public class PetRace public final boolean hasColorTwo; - public PetRace(ResultSet set) throws SQLException - { + public PetRace(ResultSet set) throws SQLException { this.race = set.getInt("race"); this.colorOne = set.getInt("color_one"); this.colorTwo = set.getInt("color_two"); 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 4e644d78..bdba8b2b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetTasks.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.pets; -public enum PetTasks -{ +public enum PetTasks { NONE(""), FREE(""), SIT("sit"), @@ -53,13 +52,11 @@ public enum PetTasks private final String status; - PetTasks(String status) - { + PetTasks(String status) { this.status = status; } - public String getStatus() - { + 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 c50f0fd6..30cd7f91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetVocal.java @@ -1,11 +1,9 @@ package com.eu.habbo.habbohotel.pets; -public class PetVocal -{ +public class PetVocal { public final String message; - public PetVocal(String message) - { + public PetVocal(String message) { this.message = message; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetVocalsType.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetVocalsType.java index 2ad687da..0aad8358 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetVocalsType.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetVocalsType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.pets; -public enum PetVocalsType -{ +public enum PetVocalsType { DISOBEY, DRINKING, EATING, 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 db9f11c9..92ec07a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java @@ -21,33 +21,27 @@ public class RideablePet extends Pet { this.rider = null; } - public boolean hasSaddle() - { + public boolean hasSaddle() { return this.hasSaddle; } - public void hasSaddle(boolean hasSaddle) - { + public void hasSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } - public boolean anyoneCanRide() - { + public boolean anyoneCanRide() { return this.anyoneCanRide; } - public void setAnyoneCanRide(boolean anyoneCanRide) - { + public void setAnyoneCanRide(boolean anyoneCanRide) { this.anyoneCanRide = anyoneCanRide; } - public Habbo getRider() - { + public Habbo getRider() { return this.rider; } - public void setRider(Habbo rider) - { + public void setRider(Habbo rider) { this.rider = rider; } } 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 d273ce37..e2fb3e5e 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 @@ -7,20 +7,17 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionBeg extends PetAction -{ - public ActionBeg() - { +public class ActionBeg extends PetAction { + public ActionBeg() { super(PetTasks.BEG, true); this.statusToSet.add(RoomUnitStatus.BEG); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - if(pet.getHappyness() > 90) + if (pet.getHappyness() > 90) 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 b9ecd19c..e04a1883 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 @@ -8,21 +8,18 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionBreatheFire extends PetAction -{ - public ActionBreatheFire() - { +public class ActionBreatheFire extends PetAction { + public ActionBreatheFire() { super(null, true); this.minimumActionDuration = 1000; this.statusToSet.add(RoomUnitStatus.FLAME); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.FLAME, null, false), this.minimumActionDuration); - if(pet.getHappyness() > 50) + if (pet.getHappyness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java index 7ddef52e..180474e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java @@ -9,37 +9,28 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.pets.breeding.PetBreedingStartFailedComposer; import org.apache.commons.lang3.StringUtils; -public class ActionBreed extends PetAction -{ - public ActionBreed() - { +public class ActionBreed extends PetAction { + public ActionBreed() { super(PetTasks.BREED, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { InteractionPetBreedingNest nest = null; - for (HabboItem item : pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetBreedingNest.class)) - { - if (StringUtils.containsIgnoreCase(item.getBaseItem().getName(), pet.getPetData().getName())) - { - if (!((InteractionPetBreedingNest)item).boxFull()) - { + for (HabboItem item : pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetBreedingNest.class)) { + if (StringUtils.containsIgnoreCase(item.getBaseItem().getName(), pet.getPetData().getName())) { + if (!((InteractionPetBreedingNest) item).boxFull()) { nest = (InteractionPetBreedingNest) item; break; } } } - if (nest != null) - { + if (nest != null) { pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(nest.getX(), nest.getY())); return true; - } - else - { + } else { habbo.getClient().sendResponse(new PetBreedingStartFailedComposer(PetBreedingStartFailedComposer.NO_NESTS)); } 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 42ff7ca6..6ad3b69f 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 @@ -9,22 +9,19 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionCroak extends PetAction -{ - public ActionCroak() - { +public class ActionCroak extends PetAction { + public ActionCroak() { super(PetTasks.SPEAK, false); this.minimumActionDuration = 2000; } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, "0"); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), 2000); - if(pet.getHappyness() > 80) + if (pet.getHappyness() > 80) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); return true; 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 0ecd01bd..8f47aad6 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 @@ -8,16 +8,13 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -public class ActionDip extends PetAction -{ - public ActionDip() - { +public class ActionDip extends PetAction { + public ActionDip() { super(null, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { THashSet waterItems = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionWater.class); if (waterItems.isEmpty()) 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 8f64df9d..2f601fb5 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 @@ -7,21 +7,18 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionDown extends PetAction -{ - public ActionDown() - { +public class ActionDown extends PetAction { + public ActionDown() { super(PetTasks.DOWN, true); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.SIT); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) + ""); - if(pet.getHappyness() > 50) + if (pet.getHappyness() > 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/ActionDrink.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java index f035657b..7d56c1c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java @@ -5,27 +5,21 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionDrink extends PetAction -{ - public ActionDrink() - { +public class ActionDrink extends PetAction { + public ActionDrink() { super(null, false); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - if(pet.getLevelThirst() > 40) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getLevelThirst() > 40) { pet.drink(); - if(pet.getLevelThirst() > 65) + if (pet.getLevelThirst() > 65) pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY)); return true; - } - else - { + } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java index ecb06123..0b701c6d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java @@ -8,29 +8,23 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionEat extends PetAction -{ - public ActionEat() - { +public class ActionEat extends PetAction { + public ActionEat() { super(null, true); this.statusToSet.add(RoomUnitStatus.EAT); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //Eat - if(pet.getLevelHunger() > 40) - { + if (pet.getLevelHunger() > 40) { pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), 500); pet.eat(); return true; - } - else - { + } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); return false; } 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 cca9df9f..767faa3f 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 @@ -9,10 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetFollowHabbo; -public class ActionFollow extends PetAction -{ - public ActionFollow() - { +public class ActionFollow extends PetAction { + public ActionFollow() { super(PetTasks.FOLLOW, true); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); @@ -20,13 +18,12 @@ public class ActionFollow extends PetAction } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, 0)); - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 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/ActionFollowLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java index b1d64a8f..84b16e6a 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 @@ -8,22 +8,19 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetFollowHabbo; -public class ActionFollowLeft extends PetAction -{ - public ActionFollowLeft() - { +public class ActionFollowLeft extends PetAction { + public ActionFollowLeft() { super(PetTasks.FOLLOW, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //Follow left. pet.clearPosture(); - Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, - 2)); + Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, -2)); - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 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 33a3a406..e00de028 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 @@ -8,22 +8,19 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetFollowHabbo; -public class ActionFollowRight extends PetAction -{ - public ActionFollowRight() - { +public class ActionFollowRight extends PetAction { + public ActionFollowRight() { super(PetTasks.FOLLOW, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //Follow right. pet.clearPosture(); - Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, + 2)); + Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, +2)); - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 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/ActionFree.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFree.java index 668a8bef..39fc50a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFree.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFree.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionFree extends PetAction -{ - public ActionFree() - { +public class ActionFree extends PetAction { + public ActionFree() { super(PetTasks.FREE, false); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.freeCommand(); return true; 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 642baa7b..150249a4 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 @@ -7,22 +7,19 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionHere extends PetAction -{ - public ActionHere() - { +public class ActionHere extends PetAction { + public ActionHere() { super(PetTasks.HERE, false); this.statusToRemove.add(RoomUnitStatus.DEAD); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 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/ActionJump.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java index 77476d8f..8e232d47 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 @@ -9,23 +9,20 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionJump extends PetAction -{ - public ActionJump() - { +public class ActionJump extends PetAction { + public ActionJump() { super(PetTasks.JUMP, true); this.minimumActionDuration = 2000; this.statusToSet.add(RoomUnitStatus.JUMP); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), 2000); - if(pet.getHappyness() > 60) + if (pet.getHappyness() > 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/ActionMoveForward.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java index 2e12d1c2..abaac92e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java @@ -5,16 +5,13 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionMoveForward extends PetAction -{ - public ActionMoveForward() - { +public class ActionMoveForward extends PetAction { + public ActionMoveForward() { super(null, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentLocation(), pet.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java index 56acaa98..f7d994d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java @@ -5,27 +5,21 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionNest extends PetAction -{ - public ActionNest() - { +public class ActionNest extends PetAction { + public ActionNest() { super(null, false); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - if(pet.getEnergy() < 65) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getEnergy() < 65) { pet.findNest(); if (pet.getEnergy() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED)); return true; - } - else - { + } else { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java index 6e20c9e1..71a7a291 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java @@ -5,22 +5,18 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionPlay extends PetAction -{ - public ActionPlay() - { +public class ActionPlay extends PetAction { + public ActionPlay() { super(null, false); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //Play //TODO Implement playing for pets. For example; go to ball, toy etc. - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); - else - { + else { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); } 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 bd0935b8..53aae87f 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 @@ -7,10 +7,8 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionPlayDead extends PetAction -{ - public ActionPlayDead() - { +public class ActionPlayDead extends PetAction { + public ActionPlayDead() { super(PetTasks.PLAY_DEAD, true); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); @@ -18,13 +16,12 @@ public class ActionPlayDead extends PetAction } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) + ""); - if(pet.getHappyness() > 50) + if (pet.getHappyness() > 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 e7897e99..7f8cc949 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 @@ -5,17 +5,14 @@ import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionPlayFootball extends PetAction -{ - public ActionPlayFootball() - { +public class ActionPlayFootball extends PetAction { + public ActionPlayFootball() { super(null, false); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - if(pet.getHappyness() > 75) + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() > 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 1f35c80f..00f893e5 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 @@ -6,20 +6,17 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionRelax extends PetAction -{ - public ActionRelax() - { +public class ActionRelax extends PetAction { + public ActionRelax() { super(null, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //Relax - if(pet.getHappyness() > 75) + if (pet.getHappyness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); - else if(pet.getHappyness() < 30) + else if (pet.getHappyness() < 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/ActionSilent.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java index 8c93e2fd..2625825c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java @@ -6,18 +6,15 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionSilent extends PetAction -{ - public ActionSilent() - { +public class ActionSilent extends PetAction { + public ActionSilent() { super(null, false); this.statusToRemove.add(RoomUnitStatus.SPEAK); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.setMuted(true); pet.say(pet.getPetData().randomVocal(PetVocalsType.MUTED)); 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 2c83a190..52ef037f 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 @@ -7,18 +7,14 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionSit extends PetAction -{ - public ActionSit() - { +public class ActionSit extends PetAction { + public ActionSit() { super(PetTasks.SIT, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) - 0.50 + ""); if (pet.getHappyness() > 75) 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 29e9f4d8..be7eaeae 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 @@ -9,32 +9,29 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionSpeak extends PetAction -{ - public ActionSpeak() - { +public class ActionSpeak extends PetAction { + public ActionSpeak() { super(PetTasks.SPEAK, false); this.statusToSet.add(RoomUnitStatus.SPEAK); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.setMuted(false); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.SPEAK, null, false), 2000); - if(pet.getHappyness() > 70) + if (pet.getHappyness() > 70) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); - else if(pet.getHappyness() < 30) + else if (pet.getHappyness() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD)); - else if(pet.getLevelHunger() > 65) + else if (pet.getLevelHunger() > 65) pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); - else if(pet.getLevelThirst() > 65) + else if (pet.getLevelThirst() > 65) pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY)); - else if(pet.getEnergy() < 25) + else if (pet.getEnergy() < 25) pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED)); - else if(pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN) + else if (pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN) pet.say(pet.getPetData().randomVocal(PetVocalsType.SLEEPING)); 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 c4145c18..598c66dc 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 @@ -7,10 +7,8 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionStand extends PetAction -{ - public ActionStand() - { +public class ActionStand extends PetAction { + public ActionStand() { super(PetTasks.STAND, true); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); @@ -19,11 +17,10 @@ public class ActionStand extends PetAction } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - if(pet.getHappyness() > 30) + if (pet.getHappyness() > 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/ActionStay.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java index 4324d67c..7ee56474 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java @@ -7,10 +7,8 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionStay extends PetAction -{ - public ActionStay() - { +public class ActionStay extends PetAction { + public ActionStay() { super(PetTasks.STAY, true); this.statusToRemove.remove(RoomUnitStatus.MOVE); @@ -18,8 +16,7 @@ public class ActionStay extends PetAction } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); pet.getRoomUnit().setCanWalk(false); 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 ff7a56c5..e6a7748e 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 @@ -8,10 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionTorch extends PetAction -{ - public ActionTorch() - { +public class ActionTorch extends PetAction { + public ActionTorch() { super(null, true); this.minimumActionDuration = 1000; @@ -19,10 +17,8 @@ public class ActionTorch extends PetAction } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - if(pet.getHappyness() < 30) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 30) { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java index 76895647..de7a4d8d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionTurnLeft extends PetAction -{ - public ActionTurnLeft() - { +public class ActionTurnLeft extends PetAction { + public ActionTurnLeft() { super(null, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getBodyRotation().getValue() - 1)]); + public boolean apply(Pet pet, Habbo habbo, String[] data) { + pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getBodyRotation().getValue() - 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java index 39b725d8..37041721 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.Habbo; -public class ActionTurnRight extends PetAction -{ - public ActionTurnRight() - { +public class ActionTurnRight extends PetAction { + public ActionTurnRight() { super(null, true); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { - pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getBodyRotation().getValue() + 1)]); + public boolean apply(Pet pet, Habbo habbo, String[] data) { + pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getBodyRotation().getValue() + 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } 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 2f18809b..23b8ebfa 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 @@ -8,21 +8,17 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionWave extends PetAction -{ - public ActionWave() - { +public class ActionWave extends PetAction { + public ActionWave() { super(PetTasks.WAVE, false); this.statusToSet.add(RoomUnitStatus.WAVE); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { //WAV - if(pet.getHappyness() > 65) - { + if (pet.getHappyness() > 65) { pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, "0"); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), 2000); 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 219c16a9..07a1b225 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 @@ -8,21 +8,18 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; -public class ActionWings extends PetAction -{ - public ActionWings() - { +public class ActionWings extends PetAction { + public ActionWings() { super(null, true); this.statusToSet.add(RoomUnitStatus.WINGS); } @Override - public boolean apply(Pet pet, Habbo habbo, String[] data) - { + public boolean apply(Pet pet, Habbo habbo, String[] data) { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WINGS, null, false), this.minimumActionDuration); - if(pet.getHappyness() > 50) + if (pet.getHappyness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); return true; 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 f58a09b5..8e7927dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java @@ -5,8 +5,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; -public class Poll -{ +public class Poll { public final int id; @@ -23,8 +22,7 @@ public class Poll private ArrayList questions; - public Poll(ResultSet set) throws SQLException - { + public Poll(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.title = set.getString("title"); this.thanksMessage = set.getString("thanks_message"); @@ -32,17 +30,13 @@ public class Poll this.questions = new ArrayList<>(); } - public ArrayList getQuestions() - { + public ArrayList getQuestions() { return this.questions; } - public PollQuestion getQuestion(int id) - { - for (PollQuestion q : this.questions) - { - if (q.id == id) - { + public PollQuestion getQuestion(int id) { + for (PollQuestion q : this.questions) { + if (q.id == id) { return q; } } @@ -50,8 +44,7 @@ public class Poll return null; } - public void addQuestion(PollQuestion question) - { + public void addQuestion(PollQuestion question) { this.questions.add(question); Collections.sort(this.questions); 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 e20d27bf..e7edc7ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java @@ -6,54 +6,53 @@ import gnu.trove.map.hash.THashMap; import java.sql.*; -public class PollManager -{ +public class PollManager { private final THashMap activePolls = new THashMap<>(); - public PollManager() - { + public PollManager() { this.loadPolls(); } + public static boolean donePoll(Habbo habbo, int pollId) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NULL FROM polls_answers WHERE poll_id = ? AND user_id = ? LIMIT 1")) { + statement.setInt(1, pollId); + statement.setInt(2, habbo.getHabboInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + if (set.isBeforeFirst()) { + return true; + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + return false; + } - public void loadPolls() - { - synchronized (this.activePolls) - { + public void loadPolls() { + synchronized (this.activePolls) { this.activePolls.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (Statement statement = connection.createStatement()) - { - try (ResultSet set = statement.executeQuery("SELECT * FROM polls")) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (Statement statement = connection.createStatement()) { + try (ResultSet set = statement.executeQuery("SELECT * FROM polls")) { + while (set.next()) { this.activePolls.put(set.getInt("id"), new Poll(set)); } } - try (ResultSet set = statement.executeQuery("SELECT * FROM polls_questions ORDER BY parent_id, `order` ASC")) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery("SELECT * FROM polls_questions ORDER BY parent_id, `order` ASC")) { + while (set.next()) { Poll poll = this.getPoll(set.getInt("poll_id")); - if (poll != null) - { + if (poll != null) { PollQuestion question = new PollQuestion(set); - if (set.getInt("parent_id") <= 0) - { + if (set.getInt("parent_id") <= 0) { poll.addQuestion(question); - } - else - { + } else { PollQuestion parentQuestion = poll.getQuestion(set.getInt("parent_id")); - if (parentQuestion != null) - { + if (parentQuestion != null) { parentQuestion.addSubQuestion(question); } } @@ -63,39 +62,13 @@ public class PollManager } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - - public Poll getPoll(int pollId) - { + public Poll getPoll(int pollId) { return this.activePolls.get(pollId); } - - - public static boolean donePoll(Habbo habbo, int pollId) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NULL FROM polls_answers WHERE poll_id = ? AND user_id = ? LIMIT 1")) - { - statement.setInt(1, pollId); - statement.setInt(2, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.isBeforeFirst()) - { - return true; - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - return false; - } } 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 fb600e7d..b1c159e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollQuestion.java @@ -10,8 +10,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Map; -public class PollQuestion implements ISerialize, Comparable -{ +public class PollQuestion implements ISerialize, Comparable { public final int id; @@ -35,8 +34,7 @@ public class PollQuestion implements ISerialize, Comparable private ArrayList subQuestions; - public PollQuestion(ResultSet set) throws SQLException - { + public PollQuestion(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.parentId = set.getInt("parent_id"); this.type = set.getInt("type"); @@ -49,23 +47,19 @@ public class PollQuestion implements ISerialize, Comparable String opts = set.getString("options"); - if(this.type == 1 || this.type == 2) - { - for (int i = 0; i < opts.split(";").length; i++) - { + if (this.type == 1 || this.type == 2) { + for (int i = 0; i < opts.split(";").length; i++) { this.options.put(i, new String[]{opts.split(";")[i].split(":")[0], opts.split(";")[i].split(":")[1]}); } } } - public void addSubQuestion(PollQuestion pollQuestion) - { + public void addSubQuestion(PollQuestion pollQuestion) { this.subQuestions.add(pollQuestion); } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.id); message.appendInt(this.order); message.appendInt(this.type); @@ -74,31 +68,26 @@ public class PollQuestion implements ISerialize, Comparable message.appendInt(0); message.appendInt(this.options.size()); - if (this.type == 1 || this.type == 2) - { - for (Map.Entry set : this.options.entrySet()) - { + if (this.type == 1 || this.type == 2) { + for (Map.Entry set : this.options.entrySet()) { message.appendString(set.getValue()[0]); message.appendString(set.getValue()[1]); message.appendInt(set.getKey()); } } - if (this.parentId <= 0) - { + if (this.parentId <= 0) { Collections.sort(this.subQuestions); message.appendInt(this.subQuestions.size()); - for (PollQuestion q : this.subQuestions) - { + for (PollQuestion q : this.subQuestions) { q.serialize(message); } } } @Override - public int compareTo(PollQuestion o) - { + public int compareTo(PollQuestion o) { return this.order - o.order; } } 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 77e1bf63..23db2026 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -7,48 +7,39 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class CustomRoomLayout extends RoomLayout implements Runnable -{ - private boolean needsUpdate; +public class CustomRoomLayout extends RoomLayout implements Runnable { private final int roomId; + private boolean needsUpdate; - public CustomRoomLayout(ResultSet set, Room room) throws SQLException - { + public CustomRoomLayout(ResultSet set, Room room) throws SQLException { super(set, room); this.roomId = room.getId(); } @Override - public void run() - { - if(this.needsUpdate) - { + public void run() { + if (this.needsUpdate) { this.needsUpdate = false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_models_custom SET door_x = ?, door_y = ?, door_dir = ?, heightmap = ? WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_models_custom SET door_x = ?, door_y = ?, door_dir = ?, heightmap = ? WHERE id = ? LIMIT 1")) { statement.setInt(1, this.getDoorX()); statement.setInt(2, this.getDoorY()); statement.setInt(3, this.getDoorDirection()); statement.setString(4, this.getHeightmap()); statement.setInt(5, this.roomId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public boolean needsUpdate() - { + public boolean needsUpdate() { return this.needsUpdate; } - public void needsUpdate(boolean needsUpdate) - { + public void needsUpdate(boolean needsUpdate) { this.needsUpdate = needsUpdate; } } 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 00674246..5d806570 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum FurnitureMovementError -{ +public enum FurnitureMovementError { NONE(""), NO_RIGHTS("${room.error.cant_set_not_owner}"), INVALID_MOVE("${room.error.cant_set_item}"), @@ -15,10 +14,9 @@ public enum FurnitureMovementError MAX_DIMMERS("${room.error.max_dimmers}"), MAX_SOUNDFURNI("${room.errors.max_soundfurni}"); - FurnitureMovementError(String errorCode) - { + public final String errorCode; + + FurnitureMovementError(String errorCode) { this.errorCode = errorCode; } - - public final String 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 e1a292db..c1f21496 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -53,7 +53,6 @@ import com.eu.habbo.plugin.events.users.UserExitRoomEvent; import com.eu.habbo.plugin.events.users.UserIdleEvent; import com.eu.habbo.plugin.events.users.UserRightsTakenEvent; import com.eu.habbo.plugin.events.users.UserRolledEvent; -import com.eu.habbo.threading.runnables.RoomUnitRidePet; import com.eu.habbo.threading.runnables.YouAreAPirate; import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; @@ -80,8 +79,28 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -public class Room implements Comparable, ISerialize, Runnable -{ +public class Room implements Comparable, ISerialize, Runnable { + public static final Comparator SORT_SCORE = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + + if (!(o1 instanceof Room && o2 instanceof Room)) + return 0; + + return ((Room) o2).getScore() - ((Room) o1).getScore(); + } + }; + public static final Comparator SORT_ID = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + + if (!(o1 instanceof Room && o2 instanceof Room)) + return 0; + + return ((Room) o2).getId() - ((Room) o1).getId(); + } + }; + private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>(); //Configuration. Loaded from database & updated accordingly. public static boolean HABBO_CHAT_DELAY = false; public static int MAXIMUM_BOTS = 10; @@ -91,17 +110,44 @@ public class Room implements Comparable, ISerialize, Runnable public static int IDLE_CYCLES_KICK = 480; public static String PREFIX_FORMAT = "[%prefix%] "; - private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>(); - - static - { - for(int i = 1; i <= 3; i++) - { + static { + for (int i = 1; i <= 3; i++) { RoomMoodlightData data = RoomMoodlightData.fromString(""); data.setId(i); defaultMoodData.put(i, data); } } + + public final Object roomUnitLock = new Object(); + public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); + public final List userVotes; + private final ConcurrentHashMap currentHabbos = new ConcurrentHashMap<>(3); + private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + private final TIntObjectMap currentBots = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + private final TIntObjectMap currentPets = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + private final THashSet activeTrades; + private final TIntArrayList rights; + private final TIntIntHashMap mutedHabbos; + private final TIntObjectHashMap bannedHabbos; + private final ConcurrentSet games; + private final TIntObjectMap furniOwnerNames; + private final TIntIntMap furniOwnerCount; + private final TIntObjectMap moodlightData; + private final THashSet wordFilterWords; + private final TIntObjectMap roomItems; + private final THashMap>> wiredHighscoreData; + private final Object loadLock = new Object(); + //Use appropriately. Could potentially cause memory leaks when used incorrectly. + public volatile boolean preventUnloading = false; + public volatile boolean preventUncaching = false; + public THashMap waterTiles; + public ConcurrentSet scheduledComposers = new ConcurrentSet<>(); + public ConcurrentSet scheduledTasks = new ConcurrentSet<>(); + public String wordQuiz = ""; + public int noVotes = 0; + public int yesVotes = 0; + public int wordQuizEnd = 0; + public ScheduledFuture roomCycleTask; private int id; private int ownerId; private String ownerName; @@ -115,17 +161,13 @@ public class Room implements Comparable, ISerialize, Runnable private int usersMax; private volatile int score; private volatile int category; - private String floorPaint; private String wallPaint; private String backgroundPaint; - private int wallSize; private int wallHeight; private int floorSize; - private int guild; - private String tags; private volatile boolean publicRoom; private volatile boolean staffPromotedRoom; @@ -149,24 +191,7 @@ public class Room implements Comparable, ISerialize, Runnable private volatile boolean moveDiagonally; private volatile boolean jukeboxActive; private volatile boolean hideWired; - - private final ConcurrentHashMap currentHabbos = new ConcurrentHashMap<>(3); - private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - private final TIntObjectMap currentBots = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - private final TIntObjectMap currentPets = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - private final THashSet activeTrades; - private final TIntArrayList rights; - private final TIntIntHashMap mutedHabbos; - private final TIntObjectHashMap bannedHabbos; - private final ConcurrentSet games; - private final TIntObjectMap furniOwnerNames; - private final TIntIntMap furniOwnerCount; - private final TIntObjectMap moodlightData; - private final THashSet wordFilterWords; - private final TIntObjectMap roomItems; - private final THashMap>> wiredHighscoreData; private RoomPromotion promotion; - private volatile boolean needsUpdate; private volatile boolean loaded; private volatile boolean preLoaded; @@ -176,30 +201,11 @@ public class Room implements Comparable, ISerialize, Runnable private long rollerCycle = System.currentTimeMillis(); private volatile int lastTimerReset = Emulator.getIntUnixTimestamp(); private volatile boolean muted; - private RoomSpecialTypes roomSpecialTypes; - - private final Object loadLock = new Object(); - public final Object roomUnitLock = new Object(); - - //Use appropriately. Could potentially cause memory leaks when used incorrectly. - public volatile boolean preventUnloading = false; - public volatile boolean preventUncaching = false; - public THashMap waterTiles; - public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); - public ConcurrentSet scheduledComposers = new ConcurrentSet<>(); - public ConcurrentSet scheduledTasks = new ConcurrentSet<>(); - public String wordQuiz = ""; - public int noVotes = 0; - public int yesVotes = 0; - public int wordQuizEnd = 0; - public final List userVotes; - public ScheduledFuture roomCycleTask; private TraxManager traxManager; private long cycleTimestamp; - public Room(ResultSet set) throws SQLException - { + public Room(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.ownerId = set.getInt("owner_id"); this.ownerName = set.getString("owner_name"); @@ -242,18 +248,14 @@ public class Room implements Comparable, ISerialize, Runnable this.bannedHabbos = new TIntObjectHashMap<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) - { - if(this.promoted) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) { + if (this.promoted) { statement.setInt(1, this.id); statement.setInt(2, Emulator.getIntUnixTimestamp()); - try (ResultSet promotionSet = statement.executeQuery()) - { + try (ResultSet promotionSet = statement.executeQuery()) { this.promoted = false; - if (promotionSet.next()) - { + if (promotionSet.next()) { this.promoted = true; this.promotion = new RoomPromotion(this, promotionSet); } @@ -261,9 +263,7 @@ public class Room implements Comparable, ISerialize, Runnable } this.loadBans(connection); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -279,8 +279,7 @@ public class Room implements Comparable, ISerialize, Runnable this.wordFilterWords = new THashSet<>(0); this.moodlightData = new TIntObjectHashMap<>(defaultMoodData); - for(String s : set.getString("moodlight_data").split(";")) - { + for (String s : set.getString("moodlight_data").split(";")) { RoomMoodlightData data = RoomMoodlightData.fromString(s); this.moodlightData.put(data.getId(), data); } @@ -294,19 +293,15 @@ public class Room implements Comparable, ISerialize, Runnable this.userVotes = new ArrayList<>(); } - public synchronized void loadData() - { - synchronized (this.loadLock) - { + public synchronized void loadData() { + synchronized (this.loadLock) { if (!this.preLoaded || this.loaded) return; this.preLoaded = false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - synchronized ( this.roomUnitLock) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + synchronized (this.roomUnitLock) { this.unitCounter = 0; this.currentHabbos.clear(); this.currentPets.clear(); @@ -315,75 +310,51 @@ public class Room implements Comparable, ISerialize, Runnable this.roomSpecialTypes = new RoomSpecialTypes(); - try - { + try { this.loadLayout(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadRights(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadItems(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadHeightmap(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadBots(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadPets(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadWordFilter(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.loadWiredData(connection); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -391,19 +362,15 @@ public class Room implements Comparable, ISerialize, Runnable this.loaded = true; this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } this.traxManager = new TraxManager(this); - if (this.jukeboxActive) - { + if (this.jukeboxActive) { this.traxManager.play(0); - for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) - { + for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) { item.setExtradata("1"); this.updateItem(item); } @@ -413,126 +380,88 @@ public class Room implements Comparable, ISerialize, Runnable Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this)); } - private synchronized void loadLayout() - { - if (this.layout == null) - { - if (this.overrideModel) - { + private synchronized void loadLayout() { + if (this.layout == null) { + if (this.overrideModel) { this.layout = Emulator.getGameEnvironment().getRoomManager().loadCustomLayout(this); - } - else - { + } else { this.layout = Emulator.getGameEnvironment().getRoomManager().loadLayout(this.layoutName, this); } } } - private synchronized void loadHeightmap() - { - if (this.layout != null) - { - for (short x = 0; x < this.layout.getMapSizeX(); x++) - { - for (short y = 0; y < this.layout.getMapSizeY(); y++) - { + private synchronized void loadHeightmap() { + if (this.layout != null) { + for (short x = 0; x < this.layout.getMapSizeX(); x++) { + for (short y = 0; y < this.layout.getMapSizeY(); y++) { RoomTile tile = this.layout.getTile(x, y); - if (tile != null) - { + if (tile != null) { this.updateTile(tile); } } } - } - else - { + } else { Emulator.getLogging().logErrorLine("Unknown Room Layout for Room (ID: " + this.id + ")"); } } - private synchronized void loadItems(Connection connection) - { + private synchronized void loadItems(Connection connection) { this.roomItems.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.addHabboItem(Emulator.getGameEnvironment().getItemManager().loadHabboItem(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private synchronized void loadWiredData(Connection connection) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) - { + private synchronized void loadWiredData(Connection connection) { + try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - try - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + try { HabboItem item = this.getHabboItem(set.getInt("id")); - if (item instanceof InteractionWired) - { + if (item instanceof InteractionWired) { ((InteractionWired) item).loadWiredData(set, this); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - private synchronized void loadBots(Connection connection) - { + private synchronized void loadBots(Connection connection) { this.currentBots.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Bot b = Emulator.getGameEnvironment().getBotManager().loadBot(set); - if (b != null) - { + if (b != null) { b.setRoom(this); 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) - { + if (b.getRoomUnit().getCurrentLocation() == null) { b.getRoomUnit().setLocation(this.getLayout().getDoorTile()); b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } - else - { + } else { b.getRoomUnit().setZ(set.getDouble("z")); b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); } @@ -545,38 +474,28 @@ public class Room implements Comparable, ISerialize, Runnable } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private synchronized void loadPets(Connection connection) - { + private synchronized void loadPets(Connection connection) { this.currentPets.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - try - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + try { Pet pet = PetManager.loadPet(set); pet.setRoom(this); pet.setRoomUnit(new RoomUnit()); pet.getRoomUnit().setPathFinderRoom(this); pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (pet.getRoomUnit().getCurrentLocation() == null) - { + if (pet.getRoomUnit().getCurrentLocation() == null) { pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } - else - { + } else { pet.getRoomUnit().setZ(set.getDouble("z")); pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); } @@ -585,55 +504,41 @@ public class Room implements Comparable, ISerialize, Runnable this.addPet(pet); this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private synchronized void loadWordFilter(Connection connection) - { + private synchronized void loadWordFilter(Connection connection) { this.wordFilterWords.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.wordFilterWords.add(set.getString("word")); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void updateTile(RoomTile tile) - { - if (tile != null) - { + public void updateTile(RoomTile tile) { + if (tile != null) { tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false)); tile.setState(this.calculateTileState(tile)); } } - public void updateTiles(THashSet tiles) - { - for (RoomTile tile : tiles) - { + public void updateTiles(THashSet tiles) { + for (RoomTile tile : tiles) { this.tileCache.remove(tile); tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false)); tile.setState(this.calculateTileState(tile)); @@ -642,38 +547,30 @@ public class Room implements Comparable, ISerialize, Runnable this.sendComposer(new UpdateStackHeightComposer(tiles).compose()); } - private RoomTileState calculateTileState(RoomTile tile) - { + private RoomTileState calculateTileState(RoomTile tile) { return this.calculateTileState(tile, null); } - private RoomTileState calculateTileState(RoomTile tile, HabboItem exclude) - { + private RoomTileState calculateTileState(RoomTile tile, HabboItem exclude) { if (tile == null || tile.state == RoomTileState.INVALID) return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; HabboItem lowestItem = null; HabboItem lowestChair = this.getLowestChair(tile); - for (HabboItem item : this.getItemsAt(tile)) - { + for (HabboItem item : this.getItemsAt(tile)) { if (exclude != null && item == exclude) continue; - if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) - { + if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) { continue; } - if (lowestItem == null || lowestItem.getZ() < item.getZ()) - { + if (lowestItem == null || lowestItem.getZ() < item.getZ()) { lowestItem = item; result = this.checkStateForItem(lowestItem); - } - else if (lowestItem.getZ() == item.getZ()) - { - if (result == RoomTileState.OPEN) - { + } else if (lowestItem.getZ() == item.getZ()) { + if (result == RoomTileState.OPEN) { result = this.checkStateForItem(item); } } @@ -684,41 +581,34 @@ public class Room implements Comparable, ISerialize, Runnable return result; } - private RoomTileState checkStateForItem(HabboItem item) - { + private RoomTileState checkStateForItem(HabboItem item) { RoomTileState result = RoomTileState.BLOCKED; - if (item.isWalkable()) - { + if (item.isWalkable()) { result = RoomTileState.OPEN; } - if (item.getBaseItem().allowSit()) - { + if (item.getBaseItem().allowSit()) { result = RoomTileState.SIT; } - if (item.getBaseItem().allowLay()) - { + if (item.getBaseItem().allowLay()) { result = RoomTileState.LAY; } return result; } - public boolean tileWalkable(RoomTile t) - { + + public boolean tileWalkable(RoomTile t) { return this.tileWalkable(t.x, t.y); } - public boolean tileWalkable(short x, short y) - { + public boolean tileWalkable(short x, short y) { boolean walkable = this.layout.tileWalkable(x, y); RoomTile tile = this.getLayout().getTile(x, y); - if (walkable && tile != null) - { - if (tile.hasUnits() && !this.allowWalkthrough) - { + if (walkable && tile != null) { + if (tile.hasUnits() && !this.allowWalkthrough) { walkable = false; } } @@ -726,17 +616,15 @@ public class Room implements Comparable, ISerialize, Runnable return walkable; } - public void pickUpItem(HabboItem item, Habbo picker) - { - if(item == null) + public void pickUpItem(HabboItem item, Habbo picker) { + if (item == null) return; - if(Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) { Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker); Emulator.getPluginManager().fireEvent(furniturePickedUpEvent); - if(furniturePickedUpEvent.isCancelled()) + if (furniturePickedUpEvent.isCancelled()) return; } @@ -745,22 +633,18 @@ public class Room implements Comparable, ISerialize, Runnable item.setRoomId(0); item.needsUpdate(true); - if (item.getBaseItem().getType() == FurnitureType.FLOOR) - { + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); THashSet updatedTiles = new THashSet<>(); Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - for (short x = (short)rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) - { - for (short y = (short)rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) - { + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { double stackHeight = this.getStackHeight(x, y, false); RoomTile tile = this.layout.getTile(x, y); - if (tile != null) - { + if (tile != null) { tile.setStackHeight(stackHeight); updatedTiles.add(tile); } @@ -768,14 +652,11 @@ public class Room implements Comparable, ISerialize, Runnable } this.sendComposer(new UpdateStackHeightComposer(updatedTiles).compose()); this.updateTiles(updatedTiles); - for (RoomTile tile : updatedTiles) - { + for (RoomTile tile : updatedTiles) { this.updateHabbosAt(tile.x, tile.y); this.updateBotsAt(tile.x, tile.y); } - } - else if (item.getBaseItem().getType() == FurnitureType.WALL) - { + } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new RemoveWallItemComposer(item).compose()); } @@ -788,53 +669,40 @@ public class Room implements Comparable, ISerialize, Runnable Emulator.getThreading().run(item); } - public void updateHabbosAt(Rectangle rectangle) - { - for(short i = (short) rectangle.x; i < rectangle.x + rectangle.width; i++) - { - for(short j = (short) rectangle.y; j < rectangle.y + rectangle.height; j++) - { + public void updateHabbosAt(Rectangle rectangle) { + for (short i = (short) rectangle.x; i < rectangle.x + rectangle.width; i++) { + for (short j = (short) rectangle.y; j < rectangle.y + rectangle.height; j++) { this.updateHabbosAt(i, j); } } } - public void updateHabbo(Habbo habbo) - { + public void updateHabbo(Habbo habbo) { this.updateRoomUnit(habbo.getRoomUnit()); } - public void updateRoomUnit(RoomUnit roomUnit) - { + + public void updateRoomUnit(RoomUnit roomUnit) { HabboItem item = this.getTopItemAt(roomUnit.getX(), roomUnit.getY()); - if((item == null && !roomUnit.cmdSit) || (item != null && !item.getBaseItem().allowSit())) + if ((item == null && !roomUnit.cmdSit) || (item != null && !item.getBaseItem().allowSit())) roomUnit.removeStatus(RoomUnitStatus.SIT); double oldZ = roomUnit.getZ(); - if(item != null) - { - if(item.getBaseItem().allowSit()) - { + if (item != null) { + if (item.getBaseItem().allowSit()) { roomUnit.setZ(item.getZ()); - } - else - { + } else { roomUnit.setZ(item.getZ() + Item.getCurrentHeight(item)); } - if (oldZ != roomUnit.getZ()) - { - this.scheduledTasks.add(new Runnable() - { + if (oldZ != roomUnit.getZ()) { + this.scheduledTasks.add(new Runnable() { @Override - public void run() - { - try - { + public void run() { + try { item.onWalkOn(roomUnit, Room.this, null); - } catch (Exception e) - { + } catch (Exception e) { } } @@ -845,67 +713,54 @@ public class Room implements Comparable, ISerialize, Runnable this.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } - public void updateHabbosAt(short x, short y) - { + public void updateHabbosAt(short x, short y) { THashSet habbos = this.getHabbosAt(x, y); HabboItem item = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); - for (Habbo habbo : habbos) - { + for (Habbo habbo : habbos) { if ((item == null && !habbo.getRoomUnit().cmdSit) || (item != null && !item.getBaseItem().allowSit())) habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); if ((item == null && !habbo.getRoomUnit().cmdLay) || (item != null && !item.getBaseItem().allowLay())) habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); - if(item != null) - { - if(item.getBaseItem().allowSit() || item.getBaseItem().allowLay()) - { + if (item != null) { + if (item.getBaseItem().allowSit() || item.getBaseItem().allowLay()) { habbo.getRoomUnit().setZ(item.getZ()); habbo.getRoomUnit().setPreviousLocationZ(item.getZ()); habbo.getRoomUnit().setRotation(RoomUserRotation.fromValue(item.getRotation())); - } - else - { + } else { habbo.getRoomUnit().setZ(item.getZ() + Item.getCurrentHeight(item)); } - } - else - { + } else { habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); } roomUnits.add(habbo.getRoomUnit()); } - if (!roomUnits.isEmpty()) - { + if (!roomUnits.isEmpty()) { this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose()); } } - private void updateBotsAt(short x, short y) - { + private void updateBotsAt(short x, short y) { HabboItem topItem = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); - for (Bot bot: this.getBotsAt(this.layout.getTile(x, y))) { - if (topItem != null) - { - if (topItem.getBaseItem().allowSit()) - { + for (Bot bot : this.getBotsAt(this.layout.getTile(x, y))) { + if (topItem != null) { + if (topItem.getBaseItem().allowSit()) { bot.getRoomUnit().setZ(topItem.getZ()); bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation())); - } else{ + } else { bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight()); - if (topItem.getBaseItem().allowLay()) - { + if (topItem.getBaseItem().allowLay()) { bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); } } @@ -916,29 +771,23 @@ public class Room implements Comparable, ISerialize, Runnable roomUnits.add(bot.getRoomUnit()); } - if (!roomUnits.isEmpty()) - { + if (!roomUnits.isEmpty()) { this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose()); } } - public void pickupPetsForHabbo(Habbo habbo) - { + public void pickupPetsForHabbo(Habbo habbo) { THashSet pets = new THashSet<>(); - synchronized (this.currentPets) - { - for(Pet pet : this.currentPets.valueCollection()) - { - if(pet.getUserId() == habbo.getHabboInfo().getId()) - { + synchronized (this.currentPets) { + for (Pet pet : this.currentPets.valueCollection()) { + if (pet.getUserId() == habbo.getHabboInfo().getId()) { pets.add(pet); } } } - for(Pet pet : pets) - { + for (Pet pet : pets) { pet.removeFromRoom(); Emulator.getThreading().run(pet); habbo.getInventory().getPetsComponent().addPet(pet); @@ -948,33 +797,25 @@ public class Room implements Comparable, ISerialize, Runnable } - public void startTrade(Habbo userOne, Habbo userTwo) - { + public void startTrade(Habbo userOne, Habbo userTwo) { RoomTrade trade = new RoomTrade(userOne, userTwo, this); - synchronized (this.activeTrades) - { + synchronized (this.activeTrades) { this.activeTrades.add(trade); } trade.start(); } - public void stopTrade(RoomTrade trade) - { - synchronized (this.activeTrades) - { + public void stopTrade(RoomTrade trade) { + synchronized (this.activeTrades) { this.activeTrades.remove(trade); } } - public RoomTrade getActiveTradeForHabbo(Habbo user) - { - synchronized (this.activeTrades) - { - for (RoomTrade trade : this.activeTrades) - { - for (RoomTradeUser habbo : trade.getRoomTradeUsers()) - { + public RoomTrade getActiveTradeForHabbo(Habbo user) { + synchronized (this.activeTrades) { + for (RoomTrade trade : this.activeTrades) { + for (RoomTradeUser habbo : trade.getRoomTradeUsers()) { if (habbo.getHabbo() == user) return trade; } @@ -983,24 +824,19 @@ public class Room implements Comparable, ISerialize, Runnable return null; } - public synchronized void dispose() - { - synchronized (this.loadLock) - { + public synchronized void dispose() { + synchronized (this.loadLock) { if (this.preventUnloading) return; if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) return; - if (this.loaded) - { - if (!this.traxManager.disposed()) - { + if (this.loaded) { + if (!this.traxManager.disposed()) { this.traxManager.dispose(); } - try - { + try { this.roomCycleTask.cancel(false); this.scheduledTasks.clear(); this.scheduledComposers.clear(); @@ -1008,62 +844,50 @@ public class Room implements Comparable, ISerialize, Runnable this.tileCache.clear(); - synchronized (this.mutedHabbos) - { + synchronized (this.mutedHabbos) { this.mutedHabbos.clear(); } - for(InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) { + for (InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) { timer.setRunning(false); } - for (Game game : this.games) - { + for (Game game : this.games) { game.stop(); } this.games.clear(); removeAllPets(ownerId); - synchronized (this.roomItems) - { + synchronized (this.roomItems) { TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); if (iterator.value().needsUpdate()) iterator.value().run(); - } catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } } - if (this.roomSpecialTypes != null) - { + if (this.roomSpecialTypes != null) { this.roomSpecialTypes.dispose(); } - synchronized (this.roomItems) - { + synchronized (this.roomItems) { this.roomItems.clear(); } - synchronized (this.habboQueue) - { + synchronized (this.habboQueue) { this.habboQueue.clear(); } - - - for (Habbo habbo : this.currentHabbos.values()) - { + for (Habbo habbo : this.currentHabbos.values()) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this); } @@ -1074,15 +898,12 @@ public class Room implements Comparable, ISerialize, Runnable TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { botIterator.advance(); botIterator.value().needsUpdate(true); Emulator.getThreading().run(botIterator.value()); - } catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } @@ -1090,8 +911,7 @@ public class Room implements Comparable, ISerialize, Runnable this.currentBots.clear(); this.currentPets.clear(); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -1109,28 +929,22 @@ public class Room implements Comparable, ISerialize, Runnable @SuppressWarnings("NullableProblems") @Override - public int compareTo(Room o) - { - if (o.getUserCount() != this.getUserCount()) - { - return o.getCurrentHabbos().size() - this.getCurrentHabbos().size(); + public int compareTo(Room o) { + if (o.getUserCount() != this.getUserCount()) { + return o.getCurrentHabbos().size() - this.getCurrentHabbos().size(); } - return this.id - o.id ; + return this.id - o.id; } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.id); message.appendString(this.name); - if(this.isPublicRoom()) - { + if (this.isPublicRoom()) { message.appendInt(0); message.appendString(""); - } - else - { + } else { message.appendInt(this.ownerId); message.appendString(this.ownerName); } @@ -1143,55 +957,42 @@ public class Room implements Comparable, ISerialize, Runnable message.appendInt(0); message.appendInt(this.category); message.appendInt(this.tags.split(";").length); - for(String s : this.tags.split(";")) - { + for (String s : this.tags.split(";")) { message.appendString(s); } int base = 0; - if(this.getGuildId() > 0) - { + if (this.getGuildId() > 0) { base = base | 2; } - if (this.isPromoted()) - { + if (this.isPromoted()) { base = base | 4; } - if(!this.isPublicRoom()) - { + if (!this.isPublicRoom()) { base = base | 8; } - - - - message.appendInt(base); - if(this.getGuildId() > 0) - { + if (this.getGuildId() > 0) { Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.getGuildId()); - if (g != null) - { + if (g != null) { message.appendInt(g.getId()); message.appendString(g.getName()); message.appendString(g.getBadge()); - } - else - { + } else { message.appendInt(0); message.appendString(""); message.appendString(""); } } - if(this.promoted) - { + if (this.promoted) { message.appendString(this.promotion.getTitle()); message.appendString(this.promotion.getDescription()); message.appendInt((this.promotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); @@ -1199,51 +1000,21 @@ public class Room implements Comparable, ISerialize, Runnable } - public static final Comparator SORT_SCORE = new Comparator() { - @Override - public int compare(Object o1, Object o2) { - - if (!(o1 instanceof Room && o2 instanceof Room)) - return 0; - - return ((Room) o2).getScore() - ((Room) o1).getScore(); - } - }; - - public static final Comparator SORT_ID = new Comparator() { - @Override - public int compare(Object o1, Object o2) { - - if (!(o1 instanceof Room && o2 instanceof Room)) - return 0; - - return ((Room) o2).getId() - ((Room) o1).getId(); - } - }; - @Override - public void run() - { + public void run() { long millis = System.currentTimeMillis(); - synchronized (this.loadLock) - { - if (this.loaded) - { - try - { + synchronized (this.loadLock) { + if (this.loaded) { + try { Emulator.getThreading().run( - new Runnable() - { + new Runnable() { @Override - public void run() - { + public void run() { Room.this.cycle(); } }); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -1252,12 +1023,9 @@ public class Room implements Comparable, ISerialize, Runnable this.save(); } - public void save() - { - if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ? WHERE id = ?")) - { + public void save() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.description); statement.setString(3, this.password); @@ -1274,8 +1042,7 @@ public class Room implements Comparable, ISerialize, Runnable StringBuilder moodLightData = new StringBuilder(); int id = 1; - for(RoomMoodlightData data : this.moodlightData.valueCollection()) - { + for (RoomMoodlightData data : this.moodlightData.valueCollection()) { data.setId(id); moodLightData.append(data.toString()).append(";"); id++; @@ -1310,60 +1077,47 @@ public class Room implements Comparable, ISerialize, Runnable statement.setInt(40, this.id); statement.executeUpdate(); this.needsUpdate = false; - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - private void updateDatabaseUserCount() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET users = ? WHERE id = ? LIMIT 1")) - { + private void updateDatabaseUserCount() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET users = ? WHERE id = ? LIMIT 1")) { statement.setInt(1, this.currentHabbos.size()); statement.setInt(2, this.id); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void cycle() - { + private void cycle() { this.cycleTimestamp = System.currentTimeMillis(); final boolean[] foundRightHolder = {false}; boolean loaded; - synchronized (this.loadLock) - { + synchronized (this.loadLock) { loaded = this.loaded; } this.tileCache.clear(); - if(loaded) - { - if (!this.scheduledTasks.isEmpty()) - { + if (loaded) { + if (!this.scheduledTasks.isEmpty()) { ConcurrentSet tasks = this.scheduledTasks; this.scheduledTasks = new ConcurrentSet<>(); - for (Runnable runnable : tasks) - { + for (Runnable runnable : tasks) { Emulator.getThreading().run(runnable); } } - for (ICycleable task : this.roomSpecialTypes.getCycleTasks()) - { + for (ICycleable task : this.roomSpecialTypes.getCycleTasks()) { task.cycle(this); } - if (!this.currentHabbos.isEmpty()) - { + if (!this.currentHabbos.isEmpty()) { this.idleCycles = 0; THashSet updatedUnit = new THashSet<>(); @@ -1373,34 +1127,26 @@ public class Room implements Comparable, ISerialize, Runnable final long millis = System.currentTimeMillis(); - for (Habbo habbo : this.currentHabbos.values()) - { - if (!foundRightHolder[0]) - { + for (Habbo habbo : this.currentHabbos.values()) { + if (!foundRightHolder[0]) { 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 * 1000)) { this.giveHandItem(habbo, 0); } - if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) - { + if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) { this.giveEffect(habbo, 0, -1); } - if (habbo.getRoomUnit().isKicked) - { + if (habbo.getRoomUnit().isKicked) { habbo.getRoomUnit().kickCount++; - if (habbo.getRoomUnit().kickCount >= 5) - { - this.scheduledTasks.add(new Runnable() - { + if (habbo.getRoomUnit().kickCount >= 5) { + this.scheduledTasks.add(new Runnable() { @Override - public void run() - { + public void run() { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room); } }); @@ -1408,101 +1154,74 @@ public class Room implements Comparable, ISerialize, Runnable } } - if (Emulator.getConfig().getBoolean("hotel.rooms.auto.idle")) - { - if (!habbo.getRoomUnit().isIdle()) - { + if (Emulator.getConfig().getBoolean("hotel.rooms.auto.idle")) { + if (!habbo.getRoomUnit().isIdle()) { habbo.getRoomUnit().increaseIdleTimer(); - if (habbo.getRoomUnit().isIdle()) - { + if (habbo.getRoomUnit().isIdle()) { this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); } - } - else - { + } else { habbo.getRoomUnit().increaseIdleTimer(); - if (!this.isOwner(habbo) && habbo.getRoomUnit().getIdleTimer() >= Room.IDLE_CYCLES_KICK) - { + if (!this.isOwner(habbo) && habbo.getRoomUnit().getIdleTimer() >= Room.IDLE_CYCLES_KICK) { UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { + if (!event.isCancelled()) { toKick.add(habbo); } } } } - if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) - { + if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().mutedBubbleTracker = false; this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose()); } - if (!habbo.hasPermission("acc_chat_no_flood") && habbo.getHabboStats().chatCounter > 0) - { + if (!habbo.hasPermission("acc_chat_no_flood") && habbo.getHabboStats().chatCounter > 0) { //if (habbo.getRoomUnit().talkTimeOut == 0 || currentTimestamp - habbo.getRoomUnit().talkTimeOut < 0) { habbo.getHabboStats().chatCounter--; - if (habbo.getHabboStats().chatCounter > 3 && !this.hasRights(habbo)) - { - if (this.chatProtection == 0) - { + if (habbo.getHabboStats().chatCounter > 3 && !this.hasRights(habbo)) { + if (this.chatProtection == 0) { this.floodMuteHabbo(habbo, 30); - } - else if (this.chatProtection == 1 && habbo.getHabboStats().chatCounter > 4) - { + } else if (this.chatProtection == 1 && habbo.getHabboStats().chatCounter > 4) { this.floodMuteHabbo(habbo, 30); - } - else if (this.chatProtection == 2 && habbo.getHabboStats().chatCounter > 5) - { + } else if (this.chatProtection == 2 && habbo.getHabboStats().chatCounter > 5) { this.floodMuteHabbo(habbo, 30); } } } - } - else - { + } else { habbo.getHabboStats().chatCounter = 0; } - if (this.cycleRoomUnit(habbo.getRoomUnit(), RoomUnitType.USER)) - { + if (this.cycleRoomUnit(habbo.getRoomUnit(), RoomUnitType.USER)) { updatedUnit.add(habbo.getRoomUnit()); } } - if(!toKick.isEmpty()) - { - for(Habbo habbo : toKick) - { + if (!toKick.isEmpty()) { + for (Habbo habbo : toKick) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this); } } - if (!this.currentBots.isEmpty()) - { + if (!this.currentBots.isEmpty()) { TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { final Bot bot; - try - { + try { botIterator.advance(); bot = botIterator.value(); - } - catch (Exception e) - { + } catch (Exception e) { break; } - if (!this.allowBotsWalk && bot.getRoomUnit().isWalking()) - { + if (!this.allowBotsWalk && bot.getRoomUnit().isWalking()) { bot.getRoomUnit().stopWalking(); updatedUnit.add(bot.getRoomUnit()); continue; @@ -1511,54 +1230,42 @@ public class Room implements Comparable, ISerialize, Runnable botIterator.value().cycle(this.allowBotsWalk); - if (this.cycleRoomUnit(bot.getRoomUnit(), RoomUnitType.BOT)) - { + if (this.cycleRoomUnit(bot.getRoomUnit(), RoomUnitType.BOT)) { updatedUnit.add(bot.getRoomUnit()); } - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } } } - if (!this.currentPets.isEmpty()) - { - if (this.allowBotsWalk) - { + if (!this.currentPets.isEmpty()) { + if (this.allowBotsWalk) { TIntObjectIterator petIterator = this.currentPets.iterator(); - for (int i = this.currentPets.size(); i-- > 0; ) - { - try - { + for (int i = this.currentPets.size(); i-- > 0; ) { + try { petIterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } Pet pet = petIterator.value(); - if (this.cycleRoomUnit(pet.getRoomUnit(), RoomUnitType.PET)) - { + if (this.cycleRoomUnit(pet.getRoomUnit(), RoomUnitType.PET)) { updatedUnit.add(pet.getRoomUnit()); } pet.cycle(); - if (pet.packetUpdate) - { + if (pet.packetUpdate) { updatedUnit.add(pet.getRoomUnit()); pet.packetUpdate = false; } - if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) - { + if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); updatedUnit.add(pet.getRoomUnit()); } @@ -1566,8 +1273,7 @@ public class Room implements Comparable, ISerialize, Runnable } } - if(this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed) - { + if (this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed) { this.rollerCycle = 0; THashSet messages = new THashSet<>(); @@ -1577,26 +1283,25 @@ public class Room implements Comparable, ISerialize, Runnable List rollerFurniIds = new ArrayList<>(); List rolledUnitIds = new ArrayList<>(); - + this.roomSpecialTypes.getRollers().forEachValue(roller -> { HabboItem newRoller = null; RoomTile rollerTile = this.getLayout().getTile(roller.getX(), roller.getY()); - if(rollerTile == null) + if (rollerTile == null) return true; THashSet itemsOnRoller = new THashSet<>(); - for(HabboItem item : getItemsAt(rollerTile)) - { - if(item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { + for (HabboItem item : getItemsAt(rollerTile)) { + if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { itemsOnRoller.add(item); } } - // itemsOnRoller.addAll(this.getItemsAt(rollerTile)); + // itemsOnRoller.addAll(this.getItemsAt(rollerTile)); itemsOnRoller.remove(roller); if (!rollerTile.hasUnits() && itemsOnRoller.isEmpty()) @@ -1624,10 +1329,8 @@ public class Room implements Comparable, ISerialize, Runnable itemsNewTile.removeAll(itemsOnRoller); List toRemove = new ArrayList<>(); - for (HabboItem item : itemsOnRoller) - { - if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())) - { + for (HabboItem item : itemsOnRoller) { + if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())) { toRemove.add(item); } } @@ -1638,62 +1341,50 @@ public class Room implements Comparable, ISerialize, Runnable boolean allowFurniture = true; boolean stackContainsRoller = false; - for (HabboItem item : itemsNewTile) - { - if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1"))) - { + for (HabboItem item : itemsNewTile) { + if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1"))) { allowUsers = false; } - if (item instanceof InteractionRoller) - { + if (item instanceof InteractionRoller) { newRoller = item; stackContainsRoller = true; - if ((item.getZ() != roller.getZ() || (itemsNewTile.size() > 1 && item != topItem)) && !InteractionRoller.NO_RULES) - { + if ((item.getZ() != roller.getZ() || (itemsNewTile.size() > 1 && item != topItem)) && !InteractionRoller.NO_RULES) { allowUsers = false; allowFurniture = false; continue; } break; - } else - { + } else { allowFurniture = false; } } - if (allowFurniture) - { + if (allowFurniture) { allowFurniture = tileInFront.getAllowStack(); } double zOffset = 0; - if (newRoller != null) - { - if ((!itemsNewTile.isEmpty() && (itemsNewTile.size() > 1)) && !InteractionRoller.NO_RULES) - { + if (newRoller != null) { + if ((!itemsNewTile.isEmpty() && (itemsNewTile.size() > 1)) && !InteractionRoller.NO_RULES) { return true; } - } - else - { + } else { zOffset = -Item.getCurrentHeight(roller) + tileInFront.getStackHeight() - rollerTile.z; } - if (allowUsers) - { + if (allowUsers) { Event roomUserRolledEvent = null; - if (Emulator.getPluginManager().isRegistered(UserRolledEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(UserRolledEvent.class, true)) { roomUserRolledEvent = new UserRolledEvent(null, null, null); } ArrayList unitsOnTile = new ArrayList(rollerTile.getUnits()); - for(RoomUnit unit : rollerTile.getUnits()) { - if(unit.getRoomUnitType() == RoomUnitType.PET) { + for (RoomUnit unit : rollerTile.getUnits()) { + if (unit.getRoomUnitType() == RoomUnitType.PET) { Pet pet = this.getPet(unit); if (pet instanceof RideablePet && ((RideablePet) pet).getRider() != null) { unitsOnTile.remove(unit); @@ -1703,20 +1394,19 @@ public class Room implements Comparable, ISerialize, Runnable HabboItem nextTileChair = this.getLowestChair(tileInFront); - for(RoomUnit unit : unitsOnTile) { + for (RoomUnit unit : unitsOnTile) { if (rolledUnitIds.contains(unit.getId())) continue; if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable())) continue; - if(unit.hasStatus(RoomUnitStatus.MOVE)) + if (unit.hasStatus(RoomUnitStatus.MOVE)) continue; RoomTile tile = tileInFront.copy(); tile.setStackHeight(unit.getZ() + zOffset); - if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.USER) - { + if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.USER) { roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tile); Emulator.getPluginManager().fireEvent(roomUserRolledEvent); @@ -1726,9 +1416,9 @@ public class Room implements Comparable, ISerialize, Runnable // horse riding boolean isRiding = false; - if(unit.getRoomUnitType() == RoomUnitType.USER) { + if (unit.getRoomUnitType() == RoomUnitType.USER) { Habbo rollingHabbo = this.getHabbo(unit); - if(rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { + if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); if (riding != null) { RoomUnit ridingUnit = riding.getRoomUnit(); @@ -1745,22 +1435,17 @@ public class Room implements Comparable, ISerialize, Runnable updatedUnit.remove(unit); messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, tile.getStackHeight() + (isRiding ? 1 : 0) + (nextTileChair != null ? -1 : 0), room)); - if (itemsOnRoller.isEmpty()) - { + if (itemsOnRoller.isEmpty()) { HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y); - if (item != null && itemsNewTile.contains(item)) - { + if (item != null && itemsNewTile.contains(item)) { Emulator.getThreading().run(new Runnable() { @Override public void run() { - if (unit.getGoal() == rollerTile) - { - try - { + if (unit.getGoal() == rollerTile) { + try { item.onWalkOn(unit, room, null); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -1769,50 +1454,39 @@ public class Room implements Comparable, ISerialize, Runnable } } - if(unit.hasStatus(RoomUnitStatus.SIT)) { + if (unit.hasStatus(RoomUnitStatus.SIT)) { unit.sitUpdate = true; } } } - if (!messages.isEmpty()) - { - for (MessageComposer message : messages) - { + if (!messages.isEmpty()) { + for (MessageComposer message : messages) { room.sendComposer(message.compose()); } messages.clear(); } - if (allowFurniture || !stackContainsRoller || InteractionRoller.NO_RULES) - { + if (allowFurniture || !stackContainsRoller || InteractionRoller.NO_RULES) { Event furnitureRolledEvent = null; - if (Emulator.getPluginManager().isRegistered(FurnitureRolledEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(FurnitureRolledEvent.class, true)) { furnitureRolledEvent = new FurnitureRolledEvent(null, null, null); } - if (newRoller == null || topItem == newRoller) - { + if (newRoller == null || topItem == newRoller) { List sortedItems = new ArrayList<>(itemsOnRoller); - sortedItems.sort(new Comparator() - { + sortedItems.sort(new Comparator() { @Override - public int compare(HabboItem o1, HabboItem o2) - { + public int compare(HabboItem o1, HabboItem o2) { return o1.getZ() > o2.getZ() ? -1 : 1; } }); - for (HabboItem item : sortedItems) - { - if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) - { - if (item != roller) - { - if (furnitureRolledEvent != null) - { + for (HabboItem item : sortedItems) { + if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) { + if (item != roller) { + if (furnitureRolledEvent != null) { furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront); Emulator.getPluginManager().fireEvent(furnitureRolledEvent); @@ -1829,10 +1503,8 @@ public class Room implements Comparable, ISerialize, Runnable } - if (!messages.isEmpty()) - { - for (MessageComposer message : messages) - { + if (!messages.isEmpty()) { + for (MessageComposer message : messages) { room.sendComposer(message.compose()); } messages.clear(); @@ -1843,53 +1515,39 @@ public class Room implements Comparable, ISerialize, Runnable int currentTime = (int) (this.cycleTimestamp / 1000); - for(HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class)) - { - if(pyramid instanceof InteractionPyramid) - { + for (HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class)) { + if (pyramid instanceof InteractionPyramid) { - if(((InteractionPyramid) pyramid).getNextChange() < currentTime) - { + if (((InteractionPyramid) pyramid).getNextChange() < currentTime) { ((InteractionPyramid) pyramid).change(this); } } } - } - else - { + } else { this.rollerCycle++; } - if(!updatedUnit.isEmpty()) - { + if (!updatedUnit.isEmpty()) { this.sendComposer(new RoomUserStatusComposer(updatedUnit, true).compose()); } this.traxManager.cycle(); - } - else - { + } else { - if(this.idleCycles < 60) + if (this.idleCycles < 60) this.idleCycles++; else this.dispose(); } } - synchronized (this.habboQueue) - { - if (!this.habboQueue.isEmpty() && !foundRightHolder[0]) - { - this.habboQueue.forEachEntry(new TIntObjectProcedure() - { + 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()) - { + public boolean execute(int a, Habbo b) { + if (b.isOnline()) { + if (b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { b.getClient().sendResponse(new RoomAccessDeniedComposer("")); } } @@ -1902,10 +1560,8 @@ public class Room implements Comparable, ISerialize, Runnable } } - if (!this.scheduledComposers.isEmpty()) - { - for (ServerMessage message : this.scheduledComposers) - { + if (!this.scheduledComposers.isEmpty()) { + for (ServerMessage message : this.scheduledComposers) { this.sendComposer(message); } @@ -1914,47 +1570,34 @@ public class Room implements Comparable, ISerialize, Runnable } - private boolean cycleRoomUnit(RoomUnit unit, RoomUnitType type) - { + private boolean cycleRoomUnit(RoomUnit unit, RoomUnitType type) { boolean update = unit.needsStatusUpdate(); - if (unit.hasStatus(RoomUnitStatus.SIGN)) - { + if (unit.hasStatus(RoomUnitStatus.SIGN)) { this.sendComposer(new RoomUserStatusComposer(unit).compose()); unit.removeStatus(RoomUnitStatus.SIGN); } - if (unit.isWalking() && unit.getPath() != null && !unit.getPath().isEmpty()) - { - if (!unit.cycle(this)) - { + if (unit.isWalking() && unit.getPath() != null && !unit.getPath().isEmpty()) { + if (!unit.cycle(this)) { return true; } - } - else - { - if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.animateWalk) - { + } else { + if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.animateWalk) { unit.removeStatus(RoomUnitStatus.MOVE); update = true; } - if (!unit.isWalking() && !unit.cmdSit) - { + if (!unit.isWalking() && !unit.cmdSit) { HabboItem topItem = this.getLowestChair(this.getLayout().getTile(unit.getX(), unit.getY())); - if (topItem == null || !topItem.getBaseItem().allowSit()) - { - if (unit.hasStatus(RoomUnitStatus.SIT)) - { + if (topItem == null || !topItem.getBaseItem().allowSit()) { + if (unit.hasStatus(RoomUnitStatus.SIT)) { unit.removeStatus(RoomUnitStatus.SIT); update = true; } - } - else - { - if (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate) - { + } else { + if (!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) + ""); @@ -1968,32 +1611,23 @@ public class Room implements Comparable, ISerialize, Runnable } } - if (!unit.isWalking() && !unit.cmdLay) - { + if (!unit.isWalking() && !unit.cmdLay) { HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY()); - if (topItem == null || !topItem.getBaseItem().allowLay()) - { - if (unit.hasStatus(RoomUnitStatus.LAY)) - { + if (topItem == null || !topItem.getBaseItem().allowLay()) { + if (unit.hasStatus(RoomUnitStatus.LAY)) { unit.removeStatus(RoomUnitStatus.LAY); update = true; } - } - else - { - if (!unit.hasStatus(RoomUnitStatus.LAY)) - { + } else { + if (!unit.hasStatus(RoomUnitStatus.LAY)) { unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) * 1.0D + ""); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); - if (topItem.getRotation() == 0 || topItem.getRotation() == 4) - { + if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { unit.setLocation(this.layout.getTile(unit.getX(), topItem.getY())); //unit.setOldY(topItem.getY()); - } - else - { + } else { unit.setLocation(this.layout.getTile(topItem.getX(), unit.getY())); //unit.setOldX(topItem.getX()); } @@ -2002,174 +1636,216 @@ public class Room implements Comparable, ISerialize, Runnable } } - if (update) - { + if (update) { unit.statusUpdate(false); } return update; } - public int getId() - { + public int getId() { return this.id; } - public int getOwnerId() - { + public int getOwnerId() { return this.ownerId; } - public void setOwnerId(int ownerId) - { + public void setOwnerId(int ownerId) { this.ownerId = ownerId; } - public String getOwnerName() - { + public String getOwnerName() { return this.ownerName; } - public void setOwnerName(String ownerName) - { + public void setOwnerName(String ownerName) { this.ownerName = ownerName; } - public String getName() - { + public String getName() { return this.name; } - public String getDescription() - { + public void setName(String name) { + this.name = name; + + if (this.name.length() > 50) { + this.name = this.name.substring(0, 50); + } + + if (this.hasGuild()) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); + + if (guild != null) { + guild.setRoomName(name); + } + } + } + + public String getDescription() { return this.description; } - public RoomLayout getLayout() - { + public void setDescription(String description) { + this.description = description; + + if (this.description.length() > 250) { + this.description = this.description.substring(0, 250); + } + } + + public RoomLayout getLayout() { return this.layout; } - public void setLayout(RoomLayout layout) - { + public void setLayout(RoomLayout layout) { this.layout = layout; } - public boolean hasCustomLayout() - { + public boolean hasCustomLayout() { return this.overrideModel; } - public void setHasCustomLayout(boolean overrideModel) - { + public void setHasCustomLayout(boolean overrideModel) { this.overrideModel = overrideModel; } - public String getPassword() - { + public String getPassword() { return this.password; } - public RoomState getState() - { + public void setPassword(String password) { + this.password = password; + + if (this.password.length() > 20) { + this.password = this.password.substring(0, 20); + } + } + + public RoomState getState() { return this.state; } - public int getUsersMax() - { + public void setState(RoomState state) { + this.state = state; + } + + public int getUsersMax() { return this.usersMax; } - public int getScore() - { + public void setUsersMax(int usersMax) { + this.usersMax = usersMax; + } + + public int getScore() { return this.score; } - public int getCategory() - { + public void setScore(int score) { + this.score = score; + } + + public int getCategory() { return this.category; } - public String getFloorPaint() - { + public void setCategory(int category) { + this.category = category; + } + + public String getFloorPaint() { return this.floorPaint; } - public String getWallPaint() - { + public void setFloorPaint(String floorPaint) { + this.floorPaint = floorPaint; + } + + public String getWallPaint() { return this.wallPaint; } - public String getBackgroundPaint() - { + public void setWallPaint(String wallPaint) { + this.wallPaint = wallPaint; + } + + public String getBackgroundPaint() { return this.backgroundPaint; } - public int getWallSize() - { + public void setBackgroundPaint(String backgroundPaint) { + this.backgroundPaint = backgroundPaint; + } + + public int getWallSize() { return this.wallSize; } - public int getWallHeight() - { + public void setWallSize(int wallSize) { + this.wallSize = wallSize; + } + + public int getWallHeight() { return this.wallHeight; } - public void setWallHeight(int wallHeight) - { + public void setWallHeight(int wallHeight) { this.wallHeight = wallHeight; } - public int getFloorSize() - { + public int getFloorSize() { return this.floorSize; } - public String getTags() - { + public void setFloorSize(int floorSize) { + this.floorSize = floorSize; + } + + public String getTags() { return this.tags; } - public int getTradeMode() - { + public void setTags(String tags) { + this.tags = tags; + } + + public int getTradeMode() { return this.tradeMode; } - public boolean moveDiagonally() - { + public void setTradeMode(int tradeMode) { + this.tradeMode = tradeMode; + } + + public boolean moveDiagonally() { return this.moveDiagonally; } - public void moveDiagonally(boolean moveDiagonally) - { + public void moveDiagonally(boolean moveDiagonally) { this.moveDiagonally = moveDiagonally; this.layout.moveDiagonally(this.moveDiagonally); this.needsUpdate = true; } - public int getGuildId() - { + public int getGuildId() { return this.guild; } - public boolean hasGuild() - { + public boolean hasGuild() { return this.guild != 0; } - public void setGuild(int guild) - { + public void setGuild(int guild) { this.guild = guild; } - public String getGuildName() - { - if (this.hasGuild()) - { + public String getGuildName() { + if (this.hasGuild()) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); - if (guild != null) - { + if (guild != null) { return guild.getName(); } } @@ -2177,216 +1853,128 @@ public class Room implements Comparable, ISerialize, Runnable return ""; } - public boolean isPublicRoom() - { + public boolean isPublicRoom() { return this.publicRoom; } - - public void setPublicRoom(boolean publicRoom) - { + public void setPublicRoom(boolean publicRoom) { this.publicRoom = publicRoom; } - public boolean isStaffPromotedRoom() - { + public boolean isStaffPromotedRoom() { return this.staffPromotedRoom; } - public void setStaffPromotedRoom(boolean staffPromotedRoom) - { + public void setStaffPromotedRoom(boolean staffPromotedRoom) { this.staffPromotedRoom = staffPromotedRoom; } - public boolean isAllowPets() - { + public boolean isAllowPets() { return this.allowPets; } - public boolean isAllowPetsEat() - { + public void setAllowPets(boolean allowPets) { + this.allowPets = allowPets; + if (!allowPets) { + removeAllPets(ownerId); + } + } + + public boolean isAllowPetsEat() { return this.allowPetsEat; } - public boolean isAllowWalkthrough() - { + public void setAllowPetsEat(boolean allowPetsEat) { + this.allowPetsEat = allowPetsEat; + } + + public boolean isAllowWalkthrough() { return this.allowWalkthrough; } - public boolean isAllowBotsWalk() - { + public void setAllowWalkthrough(boolean allowWalkthrough) { + this.allowWalkthrough = allowWalkthrough; + } + + public boolean isAllowBotsWalk() { return this.allowBotsWalk; } - public boolean isAllowEffects() - { + public void setAllowBotsWalk(boolean allowBotsWalk) { + this.allowBotsWalk = allowBotsWalk; + } + + public boolean isAllowEffects() { return this.allowEffects; } - public void setAllowEffects(boolean allowEffects) - { + public void setAllowEffects(boolean allowEffects) { this.allowEffects = allowEffects; } - public boolean isHideWall() - { + public boolean isHideWall() { return this.hideWall; } - public Color getBackgroundTonerColor() - { + public void setHideWall(boolean hideWall) { + this.hideWall = hideWall; + } + + public Color getBackgroundTonerColor() { Color color = new Color(0, 0, 0); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i > 0; i--) - { - try - { + for (int i = this.roomItems.size(); i > 0; i--) { + try { iterator.advance(); HabboItem object = iterator.value(); - if (object instanceof InteractionBackgroundToner) - { + if (object instanceof InteractionBackgroundToner) { String[] extraData = object.getExtradata().split(":"); - if (extraData.length == 4) - { - if (extraData[0].equalsIgnoreCase("1")) - { + if (extraData.length == 4) { + if (extraData[0].equalsIgnoreCase("1")) { return Color.getHSBColor(Integer.valueOf(extraData[1]), Integer.valueOf(extraData[2]), Integer.valueOf(extraData[3])); } } } - } - catch (Exception e) - { + } catch (Exception e) { } } return color; } - public int getChatMode() - { + public int getChatMode() { return this.chatMode; } - public int getChatWeight() - { + public void setChatMode(int chatMode) { + this.chatMode = chatMode; + } + + public int getChatWeight() { return this.chatWeight; } - public int getChatSpeed() - { + public void setChatWeight(int chatWeight) { + this.chatWeight = chatWeight; + } + + public int getChatSpeed() { return this.chatSpeed; } - public int getChatDistance() - { + public void setChatSpeed(int chatSpeed) { + this.chatSpeed = chatSpeed; + } + + public int getChatDistance() { return this.chatDistance; } - public void setName(String name) - { - this.name = name; - - if (this.name.length() > 50) - { - this.name = this.name.substring(0, 50); - } - - if (this.hasGuild()) - { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); - - if (guild != null) - { - guild.setRoomName(name); - } - } - } - - public void setDescription(String description) - { - this.description = description; - - if (this.description.length() > 250) - { - this.description = this.description.substring(0, 250); - } - } - - public void setPassword(String password) - { - this.password = password; - - if (this.password.length() > 20) - { - this.password = this.password.substring(0, 20); - } - } - - public void setState(RoomState state) - { - this.state = state; - } - - public void setUsersMax(int usersMax) - { - this.usersMax = usersMax; - } - - public void setScore(int score) - { - this.score = score; - } - - public void setCategory(int category) - { - this.category = category; - } - - public void setFloorPaint(String floorPaint) - { - this.floorPaint = floorPaint; - } - - public void setWallPaint(String wallPaint) - { - this.wallPaint = wallPaint; - } - - public void setBackgroundPaint(String backgroundPaint) - { - this.backgroundPaint = backgroundPaint; - } - - public void setWallSize(int wallSize) - { - this.wallSize = wallSize; - } - - public void setFloorSize(int floorSize) - { - this.floorSize = floorSize; - } - - public void setTags(String tags) - { - this.tags = tags; - } - - public void setTradeMode(int tradeMode) - { - this.tradeMode = tradeMode; - } - - public void setAllowPets(boolean allowPets) - { - this.allowPets = allowPets; - if(!allowPets) { - removeAllPets(ownerId); - } + public void setChatDistance(int chatDistance) { + this.chatDistance = chatDistance; } public void removeAllPets() { @@ -2395,6 +1983,7 @@ public class Room implements Comparable, ISerialize, Runnable /** * Removes all pets from the room except if the owner id is excludeUserId + * * @param excludeUserId Habbo id to keep pets */ public void removeAllPets(int excludeUserId) { @@ -2427,146 +2016,95 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void setAllowPetsEat(boolean allowPetsEat) - { - this.allowPetsEat = allowPetsEat; - } - - public void setAllowWalkthrough(boolean allowWalkthrough) - { - this.allowWalkthrough = allowWalkthrough; - } - - public void setAllowBotsWalk(boolean allowBotsWalk) - { - this.allowBotsWalk = allowBotsWalk; - } - - public void setHideWall(boolean hideWall) - { - this.hideWall = hideWall; - } - - public void setChatMode(int chatMode) - { - this.chatMode = chatMode; - } - - public void setChatWeight(int chatWeight) - { - this.chatWeight = chatWeight; - } - - public void setChatSpeed(int chatSpeed) - { - this.chatSpeed = chatSpeed; - } - - public void setChatDistance(int chatDistance) - { - this.chatDistance = chatDistance; - } - - public int getChatProtection() - { + public int getChatProtection() { return this.chatProtection; } - public void setChatProtection(int chatProtection) - { + public void setChatProtection(int chatProtection) { this.chatProtection = chatProtection; } - public int getMuteOption() - { + public int getMuteOption() { return this.muteOption; } - public void setMuteOption(int muteOption) - { + public void setMuteOption(int muteOption) { this.muteOption = muteOption; } - public int getKickOption() - { + public int getKickOption() { return this.kickOption; } - public void setKickOption(int kickOption) - { + public void setKickOption(int kickOption) { this.kickOption = kickOption; } - public int getBanOption() - { + public int getBanOption() { return this.banOption; } - public void setBanOption(int banOption) - { + public void setBanOption(int banOption) { this.banOption = banOption; } - public int getPollId() - { + public int getPollId() { return this.pollId; } - public int getRollerSpeed() - { + public void setPollId(int pollId) { + this.pollId = pollId; + } + + public int getRollerSpeed() { return this.rollerSpeed; } - public String[] filterAnything() - { + public void setRollerSpeed(int rollerSpeed) { + this.rollerSpeed = rollerSpeed; + this.rollerCycle = 0; + this.needsUpdate = true; + } + + public String[] filterAnything() { return new String[]{this.getOwnerName(), this.getGuildName(), this.getDescription(), this.getPromotionDesc()}; } - public long getCycleTimestamp() - { + public long getCycleTimestamp() { return this.cycleTimestamp; } - public boolean isPromoted() - { + public boolean isPromoted() { this.promoted = this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp(); this.needsUpdate = true; return this.promoted; } - public RoomPromotion getPromotion() - { + public RoomPromotion getPromotion() { return this.promotion; } - public String getPromotionDesc() - { - if (this.promotion != null) - { + public String getPromotionDesc() { + if (this.promotion != null) { return this.promotion.getDescription(); } return ""; } - public void createPromotion(String title, String description) - { + public void createPromotion(String title, String description) { this.promoted = true; - if(this.promotion == null) - { + if (this.promotion == null) { this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60)); - } - else - { + } else { this.promotion.setTitle(title); this.promotion.setDescription(description); this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60)); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?")) { statement.setInt(1, this.id); statement.setString(2, title); statement.setString(3, description); @@ -2575,52 +2113,30 @@ public class Room implements Comparable, ISerialize, Runnable statement.setString(6, this.promotion.getDescription()); statement.setInt(7, this.promotion.getEndTimestamp()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } this.needsUpdate = true; } - public void setRollerSpeed(int rollerSpeed) - { - this.rollerSpeed = rollerSpeed; - this.rollerCycle = 0; - this.needsUpdate = true; - } - - public void setPollId(int pollId) - { - this.pollId = pollId; - } - - public boolean addGame(Game game) - { - synchronized (this.games) - { + public boolean addGame(Game game) { + synchronized (this.games) { return this.games.add(game); } } - public boolean deleteGame(Game game) - { + public boolean deleteGame(Game game) { game.stop(); - synchronized (this.games) - { + synchronized (this.games) { return this.games.remove(game); } } - public Game getGame(Class gameType) - { - synchronized (this.games) - { - for(Game game : this.games) - { - if(gameType.isInstance(game)) - { + public Game getGame(Class gameType) { + synchronized (this.games) { + for (Game game : this.games) { + if (gameType.isInstance(game)) { return game; } } @@ -2629,515 +2145,361 @@ public class Room implements Comparable, ISerialize, Runnable return null; } - public int getUserCount() - { + public int getUserCount() { return this.currentHabbos.size(); } - public ConcurrentHashMap getCurrentHabbos() - { + public ConcurrentHashMap getCurrentHabbos() { return this.currentHabbos; } - public Collection getHabbos() - { + public Collection getHabbos() { return this.currentHabbos.values(); } - public TIntObjectMap getHabboQueue() - { + public TIntObjectMap getHabboQueue() { return this.habboQueue; } - public TIntObjectMap getFurniOwnerNames() - { + public TIntObjectMap getFurniOwnerNames() { return this.furniOwnerNames; } - public String getFurniOwnerName(int userId) - { + public String getFurniOwnerName(int userId) { return this.furniOwnerNames.get(userId); } - public TIntIntMap getFurniOwnerCount() - { + public TIntIntMap getFurniOwnerCount() { return this.furniOwnerCount; } - public TIntObjectMap getMoodlightData() - { + public TIntObjectMap getMoodlightData() { return this.moodlightData; } - public int getLastTimerReset() - { + public int getLastTimerReset() { return this.lastTimerReset; } - public void setLastTimerReset(int lastTimerReset) - { + public void setLastTimerReset(int lastTimerReset) { this.lastTimerReset = lastTimerReset; } - public void addToQueue(Habbo habbo) - { - synchronized (this.habboQueue) - { + public void addToQueue(Habbo habbo) { + synchronized (this.habboQueue) { this.habboQueue.put(habbo.getHabboInfo().getId(), habbo); } } - public boolean removeFromQueue(Habbo habbo) - { - try - { + public boolean removeFromQueue(Habbo habbo) { + try { this.sendComposer(new HideDoorbellComposer(habbo.getHabboInfo().getUsername()).compose()); - synchronized (this.habboQueue) - { + synchronized (this.habboQueue) { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return true; } - public TIntObjectMap getCurrentBots() - { + public TIntObjectMap getCurrentBots() { return this.currentBots; } - public TIntObjectMap getCurrentPets() - { + public TIntObjectMap getCurrentPets() { return this.currentPets; } - public THashSet getWordFilterWords() - { + public THashSet getWordFilterWords() { return this.wordFilterWords; } - public RoomSpecialTypes getRoomSpecialTypes() - { + public RoomSpecialTypes getRoomSpecialTypes() { return this.roomSpecialTypes; } - public boolean isPreLoaded() - { + public boolean isPreLoaded() { return this.preLoaded; } - public boolean isLoaded() - { + public boolean isLoaded() { return this.loaded; } - public void setNeedsUpdate(boolean needsUpdate) - { + public void setNeedsUpdate(boolean needsUpdate) { this.needsUpdate = needsUpdate; } - public TIntArrayList getRights() - { + public TIntArrayList getRights() { return this.rights; } - public boolean isMuted() - { + public boolean isMuted() { return this.muted; } - public void setMuted(boolean muted) - { + public void setMuted(boolean muted) { this.muted = muted; } - public TraxManager getTraxManager() - { + public TraxManager getTraxManager() { return this.traxManager; } - public void addHabboItem(HabboItem item) - { - if(item == null) + public void addHabboItem(HabboItem item) { + if (item == null) return; - synchronized (this.roomItems) - { - try - { + synchronized (this.roomItems) { + try { this.roomItems.put(item.getId(), item); - } catch (Exception e) - { + } catch (Exception e) { } } - synchronized (this.furniOwnerCount) - { + synchronized (this.furniOwnerCount) { this.furniOwnerCount.put(item.getUserId(), this.furniOwnerCount.get(item.getUserId()) + 1); } - synchronized (this.furniOwnerNames) - { - if (!this.furniOwnerNames.containsKey(item.getUserId())) - { + synchronized (this.furniOwnerNames) { + if (!this.furniOwnerNames.containsKey(item.getUserId())) { HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getUserId()); - if (habbo != null) - { + if (habbo != null) { this.furniOwnerNames.put(item.getUserId(), habbo.getUsername()); - } - else - { - Emulator.getLogging().logDebugLine("Failed to find username for item (ID:" + item.getId() + ", UserID: " + item.getUserId() + ")" ); + } else { + Emulator.getLogging().logDebugLine("Failed to find username for item (ID:" + item.getId() + ", UserID: " + item.getUserId() + ")"); } } } //TODO: Move this list - synchronized (this.roomSpecialTypes) - { - if (item instanceof ICycleable) - { - this.roomSpecialTypes.addCycleTask((ICycleable)item); + synchronized (this.roomSpecialTypes) { + if (item instanceof ICycleable) { + this.roomSpecialTypes.addCycleTask((ICycleable) item); } - if (item instanceof InteractionWiredTrigger) - { + if (item instanceof InteractionWiredTrigger) { this.roomSpecialTypes.addTrigger((InteractionWiredTrigger) item); - } else if (item instanceof InteractionWiredEffect) - { + } else if (item instanceof InteractionWiredEffect) { this.roomSpecialTypes.addEffect((InteractionWiredEffect) item); - } else if (item instanceof InteractionWiredCondition) - { + } else if (item instanceof InteractionWiredCondition) { this.roomSpecialTypes.addCondition((InteractionWiredCondition) item); - } else if (item instanceof InteractionWiredExtra) - { + } else if (item instanceof InteractionWiredExtra) { this.roomSpecialTypes.addExtra((InteractionWiredExtra) item); - } else if (item instanceof InteractionBattleBanzaiTeleporter) - { + } else if (item instanceof InteractionBattleBanzaiTeleporter) { this.roomSpecialTypes.addBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item); - } else if (item instanceof InteractionRoller) - { + } else if (item instanceof InteractionRoller) { this.roomSpecialTypes.addRoller((InteractionRoller) item); - } else if (item instanceof InteractionGameScoreboard) - { + } else if (item instanceof InteractionGameScoreboard) { this.roomSpecialTypes.addGameScoreboard((InteractionGameScoreboard) item); - } else if (item instanceof InteractionGameGate) - { + } else if (item instanceof InteractionGameGate) { this.roomSpecialTypes.addGameGate((InteractionGameGate) item); - } else if (item instanceof InteractionGameTimer) - { + } else if (item instanceof InteractionGameTimer) { this.roomSpecialTypes.addGameTimer((InteractionGameTimer) item); - } else if (item instanceof InteractionFreezeExitTile) - { + } else if (item instanceof InteractionFreezeExitTile) { this.roomSpecialTypes.addFreezeExitTile((InteractionFreezeExitTile) item); - } else if (item instanceof InteractionNest) - { + } else if (item instanceof InteractionNest) { this.roomSpecialTypes.addNest((InteractionNest) item); - } else if (item instanceof InteractionPetDrink) - { + } else if (item instanceof InteractionPetDrink) { this.roomSpecialTypes.addPetDrink((InteractionPetDrink) item); - } else if (item instanceof InteractionPetFood) - { + } else if (item instanceof InteractionPetFood) { this.roomSpecialTypes.addPetFood((InteractionPetFood) item); - } else if (item instanceof InteractionMoodLight) - { + } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionPyramid) - { + } else if (item instanceof InteractionPyramid) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionMusicDisc) - { + } else if (item instanceof InteractionMusicDisc) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionBattleBanzaiSphere) - { + } else if (item instanceof InteractionBattleBanzaiSphere) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTalkingFurniture) - { + } else if (item instanceof InteractionTalkingFurniture) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionWater) - { + } else if (item instanceof InteractionWater) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionWaterItem) - { + } else if (item instanceof InteractionWaterItem) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionMuteArea) - { + } else if (item instanceof InteractionMuteArea) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTagPole) - { + } else if (item instanceof InteractionTagPole) { this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTagField) - { + } else if (item instanceof InteractionTagField) { this.roomSpecialTypes.addUndefined(item); - }else if (item instanceof InteractionJukeBox) - { + } else if (item instanceof InteractionJukeBox) { this.roomSpecialTypes.addUndefined(item); - }else if (item instanceof InteractionPetBreedingNest) - { + } else if (item instanceof InteractionPetBreedingNest) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof InteractionBlackHole) - { + } else if (item instanceof InteractionBlackHole) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof InteractionWiredHighscore) - { + } else if (item instanceof InteractionWiredHighscore) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof InteractionStickyPole) - { + } else if (item instanceof InteractionStickyPole) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof WiredBlob) - { + } else if (item instanceof WiredBlob) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof InteractionTent) - { + } else if (item instanceof InteractionTent) { this.roomSpecialTypes.addUndefined(item); - } - else if (item instanceof InteractionSnowboardSlope) - { + } else if (item instanceof InteractionSnowboardSlope) { this.roomSpecialTypes.addUndefined(item); } } } - public HabboItem getHabboItem(int id) - { + public HabboItem getHabboItem(int id) { HabboItem item; - synchronized (this.roomItems) - { + synchronized (this.roomItems) { item = this.roomItems.get(id); } - if(item == null) + if (item == null) item = this.roomSpecialTypes.getBanzaiTeleporter(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getTrigger(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getEffect(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getCondition(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getGameGate(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getGameScorebord(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getGameTimer(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getFreezeExitTiles().get(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getRoller(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getNest(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getPetDrink(id); - if(item == null) + if (item == null) item = this.roomSpecialTypes.getPetFood(id); return item; } - void removeHabboItem(int id) - { + void removeHabboItem(int id) { this.removeHabboItem(this.getHabboItem(id)); } - public void removeHabboItem(HabboItem item) - { - if (item != null) - { + public void removeHabboItem(HabboItem item) { + if (item != null) { HabboItem i; - synchronized (this.roomItems) - { + synchronized (this.roomItems) { i = this.roomItems.remove(item.getId()); } - if (i != null) - { - synchronized (this.furniOwnerCount) - { - synchronized (this.furniOwnerNames) - { + if (i != null) { + synchronized (this.furniOwnerCount) { + synchronized (this.furniOwnerNames) { int count = this.furniOwnerCount.get(i.getUserId()); if (count > 1) this.furniOwnerCount.put(i.getUserId(), count - 1); - else - { + else { this.furniOwnerCount.remove(i.getUserId()); this.furniOwnerNames.remove(i.getUserId()); } } } - if (item instanceof ICycleable) - { + if (item instanceof ICycleable) { this.roomSpecialTypes.removeCycleTask((ICycleable) item); } - if (item instanceof InteractionBattleBanzaiTeleporter) - { + if (item instanceof InteractionBattleBanzaiTeleporter) { this.roomSpecialTypes.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item); - } - else if (item instanceof InteractionWiredTrigger) - { + } else if (item instanceof InteractionWiredTrigger) { this.roomSpecialTypes.removeTrigger((InteractionWiredTrigger) item); - } - else if (item instanceof InteractionWiredEffect) - { + } else if (item instanceof InteractionWiredEffect) { this.roomSpecialTypes.removeEffect((InteractionWiredEffect) item); - } - else if (item instanceof InteractionWiredCondition) - { + } else if (item instanceof InteractionWiredCondition) { this.roomSpecialTypes.removeCondition((InteractionWiredCondition) item); - } - else if (item instanceof InteractionWiredExtra) - { + } else if (item instanceof InteractionWiredExtra) { this.roomSpecialTypes.removeExtra((InteractionWiredExtra) item); - } - else if (item instanceof InteractionRoller) - { + } else if (item instanceof InteractionRoller) { this.roomSpecialTypes.removeRoller((InteractionRoller) item); - } - else if (item instanceof InteractionGameScoreboard) - { + } else if (item instanceof InteractionGameScoreboard) { this.roomSpecialTypes.removeScoreboard((InteractionGameScoreboard) item); - } - else if (item instanceof InteractionGameGate) - { + } else if (item instanceof InteractionGameGate) { this.roomSpecialTypes.removeGameGate((InteractionGameGate) item); - } - else if (item instanceof InteractionGameTimer) - { + } else if (item instanceof InteractionGameTimer) { this.roomSpecialTypes.removeGameTimer((InteractionGameTimer) item); - } - else if (item instanceof InteractionFreezeExitTile) - { + } else if (item instanceof InteractionFreezeExitTile) { this.roomSpecialTypes.removeFreezeExitTile((InteractionFreezeExitTile) item); - } - else if (item instanceof InteractionNest) - { + } else if (item instanceof InteractionNest) { this.roomSpecialTypes.removeNest((InteractionNest) item); - } - else if (item instanceof InteractionPetDrink) - { + } else if (item instanceof InteractionPetDrink) { this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item); - } - else if (item instanceof InteractionPetFood) - { + } else if (item instanceof InteractionPetFood) { this.roomSpecialTypes.removePetFood((InteractionPetFood) item); - } - else if (item instanceof InteractionMoodLight) - { + } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionPyramid) - { + } else if (item instanceof InteractionPyramid) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionMusicDisc) - { + } else if (item instanceof InteractionMusicDisc) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionBattleBanzaiSphere) - { + } else if (item instanceof InteractionBattleBanzaiSphere) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionTalkingFurniture) - { + } else if (item instanceof InteractionTalkingFurniture) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionWaterItem) - { + } else if (item instanceof InteractionWaterItem) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionWater) - { + } else if (item instanceof InteractionWater) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionMuteArea) - { + } else if (item instanceof InteractionMuteArea) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionTagPole) - { + } else if (item instanceof InteractionTagPole) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionTagField) - { + } else if (item instanceof InteractionTagField) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionJukeBox) - { + } else if (item instanceof InteractionJukeBox) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionPetBreedingNest) - { + } else if (item instanceof InteractionPetBreedingNest) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionBlackHole) - { + } else if (item instanceof InteractionBlackHole) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionWiredHighscore) - { + } else if (item instanceof InteractionWiredHighscore) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionStickyPole) - { + } else if (item instanceof InteractionStickyPole) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof WiredBlob) - { + } else if (item instanceof WiredBlob) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionTent) - { + } else if (item instanceof InteractionTent) { this.roomSpecialTypes.removeUndefined(item); - } - else if (item instanceof InteractionSnowboardSlope) - { + } else if (item instanceof InteractionSnowboardSlope) { this.roomSpecialTypes.removeUndefined(item); } } } } - public THashSet getFloorItems() - { + public THashSet getFloorItems() { THashSet items = new THashSet<>(); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } @@ -3147,24 +2509,18 @@ public class Room implements Comparable, ISerialize, Runnable } - return items; } - public THashSet getWallItems() - { + public THashSet getWallItems() { THashSet items = new THashSet<>(); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } @@ -3176,10 +2532,8 @@ public class Room implements Comparable, ISerialize, Runnable } - public void addHabbo(Habbo habbo) - { - synchronized (this.roomUnitLock) - { + public void addHabbo(Habbo habbo) { + synchronized (this.roomUnitLock) { habbo.getRoomUnit().setId(this.unitCounter); this.currentHabbos.put(habbo.getHabboInfo().getId(), habbo); this.unitCounter++; @@ -3187,18 +2541,15 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void kickHabbo(Habbo habbo, boolean alert) - { - if(alert) - { + public void kickHabbo(Habbo habbo, boolean alert) { + if (alert) { habbo.getClient().sendResponse(new GenericErrorMessagesComposer(GenericErrorMessagesComposer.KICKED_OUT_OF_THE_ROOM)); } habbo.getRoomUnit().isKicked = true; habbo.getRoomUnit().setGoalLocation(this.layout.getDoorTile()); - if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.isPublicRoom()) - { + if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.isPublicRoom()) { habbo.getRoomUnit().setCanWalk(true); Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this); } @@ -3208,103 +2559,81 @@ public class Room implements Comparable, ISerialize, Runnable removeHabbo(habbo, false); } - public void removeHabbo(Habbo habbo, boolean sendRemovePacket) - { - if(habbo.getRoomUnit() != null && habbo.getRoomUnit().getCurrentLocation() != null) { + public void removeHabbo(Habbo habbo, boolean sendRemovePacket) { + if (habbo.getRoomUnit() != null && habbo.getRoomUnit().getCurrentLocation() != null) { habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); } - if(sendRemovePacket && habbo.getRoomUnit() != null) { + if (sendRemovePacket && habbo.getRoomUnit() != null) { this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); } HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); - if (item != null) - { - try - { + if (item != null) { + try { item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - synchronized (this.roomUnitLock) - { + synchronized (this.roomUnitLock) { this.currentHabbos.remove(habbo.getHabboInfo().getId()); } - if(habbo.getHabboInfo().getCurrentGame() != null) - { - if (this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) - { + if (habbo.getHabboInfo().getCurrentGame() != null) { + if (this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) { this.getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); } } RoomTrade trade = this.getActiveTradeForHabbo(habbo); - if(trade != null) - { + if (trade != null) { trade.stopTrade(habbo); } - if (habbo.getHabboInfo().getId() != this.ownerId) - { + if (habbo.getHabboInfo().getId() != this.ownerId) { this.pickupPetsForHabbo(habbo); } this.updateDatabaseUserCount(); } - public void addBot(Bot bot) - { - synchronized (this.roomUnitLock) - { + public void addBot(Bot bot) { + synchronized (this.roomUnitLock) { bot.getRoomUnit().setId(this.unitCounter); this.currentBots.put(bot.getId(), bot); this.unitCounter++; } } - public void addPet(Pet pet) - { - synchronized (this.roomUnitLock) - { + public void addPet(Pet pet) { + synchronized (this.roomUnitLock) { pet.getRoomUnit().setId(this.unitCounter); this.currentPets.put(pet.getId(), pet); this.unitCounter++; Habbo habbo = this.getHabbo(pet.getUserId()); - if (habbo != null) - { + if (habbo != null) { this.furniOwnerNames.put(pet.getUserId(), this.getHabbo(pet.getUserId()).getHabboInfo().getUsername()); } } } - public Bot getBot(int botId) - { + public Bot getBot(int botId) { return this.currentBots.get(botId); } - public Bot getBot(RoomUnit roomUnit) - { - synchronized (this.currentBots) - { + public Bot getBot(RoomUnit roomUnit) { + synchronized (this.currentBots) { TIntObjectIterator iterator = this.currentBots.iterator(); - for(int i = this.currentBots.size(); i-- > 0;) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } @@ -3317,20 +2646,14 @@ public class Room implements Comparable, ISerialize, Runnable return null; } - public Bot getBotByRoomUnitId(int id) - { - synchronized (this.currentBots) - { + public Bot getBotByRoomUnitId(int id) { + synchronized (this.currentBots) { TIntObjectIterator iterator = this.currentBots.iterator(); - for(int i = this.currentBots.size(); i-- > 0;) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } @@ -3343,22 +2666,16 @@ public class Room implements Comparable, ISerialize, Runnable return null; } - public List getBots(String name) - { + public List getBots(String name) { List bots = new ArrayList<>(); - synchronized (this.currentBots) - { + synchronized (this.currentBots) { TIntObjectIterator iterator = this.currentBots.iterator(); - for(int i = this.currentBots.size(); i-- > 0;) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } @@ -3371,19 +2688,14 @@ public class Room implements Comparable, ISerialize, Runnable return bots; } - public boolean hasBotsAt(final int x, final int y) - { + public boolean hasBotsAt(final int x, final int y) { final boolean[] result = {false}; - synchronized (this.currentBots) - { - this.currentBots.forEachValue(new TObjectProcedure() - { + synchronized (this.currentBots) { + this.currentBots.forEachValue(new TObjectProcedure() { @Override - public boolean execute(Bot object) - { - if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) - { + public boolean execute(Bot object) { + if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { result[0] = true; return false; } @@ -3396,41 +2708,32 @@ public class Room implements Comparable, ISerialize, Runnable return result[0]; } - public Pet getPet(int petId) - { + public Pet getPet(int petId) { return this.currentPets.get(petId); } - public Pet getPet(RoomUnit roomUnit) - { + public Pet getPet(RoomUnit roomUnit) { TIntObjectIterator petIterator = this.currentPets.iterator(); - for(int i = this.currentPets.size(); i-- > 0;) - { - try - { + for (int i = this.currentPets.size(); i-- > 0; ) { + try { petIterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } - if(petIterator.value().getRoomUnit() == roomUnit) + if (petIterator.value().getRoomUnit() == roomUnit) return petIterator.value(); } return null; } - public boolean removeBot(Bot bot) - { - synchronized (this.currentBots) - { - if (this.currentBots.containsKey(bot.getId())) - { - if(bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentLocation() != null) { + public boolean removeBot(Bot bot) { + synchronized (this.currentBots) { + if (this.currentBots.containsKey(bot.getId())) { + if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentLocation() != null) { bot.getRoomUnit().getCurrentLocation().removeUnit(bot.getRoomUnit()); } @@ -3446,14 +2749,11 @@ public class Room implements Comparable, ISerialize, Runnable return false; } - public void placePet(Pet pet, short x, short y, double z, int rot) - { - synchronized (this.currentPets) - { + public void placePet(Pet pet, short x, short y, double z, int rot) { + synchronized (this.currentPets) { RoomTile tile = this.layout.getTile(x, y); - if (tile == null) - { + if (tile == null) { tile = this.layout.getDoorTile(); } @@ -3466,8 +2766,7 @@ public class Room implements Comparable, ISerialize, Runnable pet.getRoomUnit().setPathFinderRoom(this); pet.getRoomUnit().setPreviousLocationZ(z); pet.getRoomUnit().setZ(z); - if (pet.getRoomUnit().getCurrentLocation() == null) - { + if (pet.getRoomUnit().getCurrentLocation() == null) { pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); } @@ -3479,35 +2778,26 @@ public class Room implements Comparable, ISerialize, Runnable } } - public Pet removePet(int petId) - { + public Pet removePet(int petId) { return this.currentPets.remove(petId); } - public boolean hasHabbosAt(int x, int y) - { - for (Habbo habbo : this.getHabbos()) - { + public boolean hasHabbosAt(int x, int y) { + for (Habbo habbo : this.getHabbos()) { if (habbo.getRoomUnit().getX() == x && habbo.getRoomUnit().getY() == y) return true; } return false; } - public boolean hasPetsAt(int x, int y) - { - synchronized (this.currentPets) - { + public boolean hasPetsAt(int x, int y) { + synchronized (this.currentPets) { TIntObjectIterator petIterator = this.currentPets.iterator(); - for (int i = this.currentPets.size(); i-- > 0; ) - { - try - { + for (int i = this.currentPets.size(); i-- > 0; ) { + try { petIterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } @@ -3520,26 +2810,19 @@ public class Room implements Comparable, ISerialize, Runnable return false; } - public THashSet getBotsAt(RoomTile tile) - { + public THashSet getBotsAt(RoomTile tile) { THashSet bots = new THashSet<>(); - synchronized (this.currentBots) - { + synchronized (this.currentBots) { TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { botIterator.advance(); - if (botIterator.value().getRoomUnit().getCurrentLocation().equals(tile)) - { + if (botIterator.value().getRoomUnit().getCurrentLocation().equals(tile)) { bots.add(botIterator.value()); } - } - catch (Exception e) - { + } catch (Exception e) { break; } } @@ -3548,17 +2831,14 @@ public class Room implements Comparable, ISerialize, Runnable return bots; } - public THashSet getHabbosAt(short x, short y) - { + public THashSet getHabbosAt(short x, short y) { return this.getHabbosAt(this.layout.getTile(x, y)); } - public THashSet getHabbosAt(RoomTile tile) - { + public THashSet getHabbosAt(RoomTile tile) { THashSet habbos = new THashSet<>(); - for (Habbo habbo : this.getHabbos()) - { + for (Habbo habbo : this.getHabbos()) { if (habbo.getRoomUnit().getCurrentLocation().equals(tile)) habbos.add(habbo); } @@ -3566,13 +2846,10 @@ public class Room implements Comparable, ISerialize, Runnable return habbos; } - public THashSet getHabbosOnItem(HabboItem item) - { + public THashSet getHabbosOnItem(HabboItem item) { THashSet habbos = new THashSet<>(); - for(short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) - { - for(short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) - { + for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { habbos.addAll(this.getHabbosAt(x, y)); } } @@ -3580,13 +2857,10 @@ public class Room implements Comparable, ISerialize, Runnable return habbos; } - public THashSet getBotsOnItem(HabboItem item) - { + public THashSet getBotsOnItem(HabboItem item) { THashSet bots = new THashSet<>(); - for(short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) - { - for(short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) - { + for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { bots.addAll(this.getBotsAt(this.getLayout().getTile(x, y))); } } @@ -3594,33 +2868,27 @@ public class Room implements Comparable, ISerialize, Runnable return bots; } - public void teleportHabboToItem(Habbo habbo, HabboItem item) - { + public void teleportHabboToItem(Habbo habbo, HabboItem item) { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } - public void teleportHabboToLocation(Habbo habbo, short x, short y) - { + public void teleportHabboToLocation(Habbo habbo, short x, short y) { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), x, y, 0.0); } - public void teleportRoomUnitToItem(RoomUnit roomUnit, HabboItem item) - { + public void teleportRoomUnitToItem(RoomUnit roomUnit, HabboItem item) { this.teleportRoomUnitToLocation(roomUnit, item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } - public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y) - { + public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y) { this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0); } - void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) - { - if (this.loaded) - { + + void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) { + if (this.loaded) { RoomTile tile = this.layout.getTile(x, y); - if (z < tile.z) - { + if (z < tile.z) { z = tile.z; } @@ -3634,25 +2902,20 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void muteHabbo(Habbo habbo, int minutes) - { - synchronized (this.mutedHabbos) - { + public void muteHabbo(Habbo habbo, int minutes) { + synchronized (this.mutedHabbos) { this.mutedHabbos.put(habbo.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + (minutes * 60)); } } - public boolean isMuted(Habbo habbo) - { + public boolean isMuted(Habbo habbo) { if (this.isOwner(habbo) || this.hasRights(habbo)) return false; - if(this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) - { + if (this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) { boolean time = this.mutedHabbos.get(habbo.getHabboInfo().getId()) > Emulator.getIntUnixTimestamp(); - if (!time) - { + if (!time) { this.mutedHabbos.remove(habbo.getHabboInfo().getId()); } @@ -3662,64 +2925,51 @@ public class Room implements Comparable, ISerialize, Runnable return false; } - public void habboEntered(Habbo habbo) - { + public void habboEntered(Habbo habbo) { habbo.getRoomUnit().animateWalk = false; - synchronized (this.currentBots) - { - if(habbo.getHabboInfo().getId() != this.getOwnerId()) + synchronized (this.currentBots) { + if (habbo.getHabboInfo().getId() != this.getOwnerId()) return; TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { botIterator.advance(); - if(botIterator.value() instanceof VisitorBot) - { - ((VisitorBot)botIterator.value()).onUserEnter(habbo); + if (botIterator.value() instanceof VisitorBot) { + ((VisitorBot) botIterator.value()).onUserEnter(habbo); break; } - } - catch (Exception e) - { + } catch (Exception e) { break; } } } HabboItem doorTileTopItem = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); - if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) - { - try - { + if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) { + try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } } - public void floodMuteHabbo(Habbo habbo, int timeOut) - { + public void floodMuteHabbo(Habbo habbo, int timeOut) { habbo.getHabboStats().mutedCount++; - timeOut += (timeOut * (int)Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2))); + timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2))); habbo.getHabboStats().chatCounter = 0; habbo.mute(timeOut); } - public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) - { + public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) { this.talk(habbo, roomChatMessage, chatType, false); } - public void talk(final Habbo habbo, final RoomChatMessage roomChatMessage, RoomChatType chatType, boolean ignoreWired) - { + public void talk(final Habbo habbo, final RoomChatMessage roomChatMessage, RoomChatType chatType, boolean ignoreWired) { if (!habbo.getHabboStats().allowTalk()) return; @@ -3737,16 +2987,13 @@ public class Room implements Comparable, ISerialize, Runnable return; long millis = System.currentTimeMillis(); - if (HABBO_CHAT_DELAY) - { - if (millis - habbo.getHabboStats().lastChat < 750) - { + if (HABBO_CHAT_DELAY) { + if (millis - habbo.getHabboStats().lastChat < 750) { return; } } habbo.getHabboStats().lastChat = millis; - if(roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) - { + if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { Emulator.getThreading().run(new YouAreAPirate(habbo, this)); return; } @@ -3754,65 +3001,51 @@ public class Room implements Comparable, ISerialize, Runnable UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.TALKED, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { this.unIdle(habbo); } } this.sendComposer(new RoomUserTypingComposer(habbo.getRoomUnit(), false).compose()); - if(roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals("")) + if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals("")) return; - for(HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) - { - if(((InteractionMuteArea)area).inSquare(habbo.getRoomUnit().getCurrentLocation())) - { + for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { + if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentLocation())) { return; } } - if(!this.wordFilterWords.isEmpty()) - { - if (!habbo.hasPermission("acc_chat_no_filter")) - { - for(String string : this.wordFilterWords) - { + if (!this.wordFilterWords.isEmpty()) { + if (!habbo.hasPermission("acc_chat_no_filter")) { + for (String string : this.wordFilterWords) { roomChatMessage.setMessage(roomChatMessage.getMessage().replace(string, "bobba")); } } } - if(!habbo.hasPermission("acc_nomute")) - { - if(this.isMuted() && !this.hasRights(habbo)) - { + if (!habbo.hasPermission("acc_nomute")) { + if (this.isMuted() && !this.hasRights(habbo)) { return; } - if (this.isMuted(habbo)) - { + if (this.isMuted(habbo)) { habbo.getClient().sendResponse(new MutedWhisperComposer(this.mutedHabbos.get(habbo.getHabboInfo().getId()) - Emulator.getIntUnixTimestamp())); return; } } - if (chatType != RoomChatType.WHISPER) - { - if (CommandHandler.handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) - { + if (chatType != RoomChatType.WHISPER) { + if (CommandHandler.handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()}); roomChatMessage.isCommand = true; return; } - if(!ignoreWired) - { - if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()})) - { + if (!ignoreWired) { + if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()})) { habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(roomChatMessage.getMessage(), habbo, habbo, roomChatMessage.getBubble()))); return; } @@ -3824,10 +3057,8 @@ public class Room implements Comparable, ISerialize, Runnable Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); - if(chatType == RoomChatType.WHISPER) - { - if (roomChatMessage.getTargetHabbo() == null) - { + if (chatType == RoomChatType.WHISPER) { + if (roomChatMessage.getTargetHabbo() == null) { return; } @@ -3836,122 +3067,96 @@ public class Room implements Comparable, ISerialize, Runnable staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage()); final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose(); - for (Habbo h : this.getHabbos()) - { - if (h == roomChatMessage.getTargetHabbo() || h == habbo) - { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) - { - if (prefixMessage != null) - { + for (Habbo h : this.getHabbos()) { + if (h == roomChatMessage.getTargetHabbo() || h == habbo) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null) { h.getClient().sendResponse(prefixMessage); } h.getClient().sendResponse(message); - if (clearPrefixMessage != null) - { + if (clearPrefixMessage != null) { h.getClient().sendResponse(clearPrefixMessage); } } continue; } - if (h.hasPermission("acc_see_whispers")) - { + if (h.hasPermission("acc_see_whispers")) { h.getClient().sendResponse(staffMessage); } } - } - else if (chatType == RoomChatType.TALK) - { + } else if (chatType == RoomChatType.TALK) { ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose(); boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit"); - for (Habbo h : this.getHabbos()) - { + for (Habbo h : this.getHabbos()) { if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance || h.equals(habbo) || this.hasRights(h) || - noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) - { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) - { - if (prefixMessage != null && !h.getHabboStats().preferOldChat) - { + noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null && !h.getHabboStats().preferOldChat) { h.getClient().sendResponse(prefixMessage); } h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) - { + if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { h.getClient().sendResponse(clearPrefixMessage); } } } } - } - else if(chatType == RoomChatType.SHOUT) - { + } else if (chatType == RoomChatType.SHOUT) { ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose(); - for (Habbo h : this.getHabbos()) - { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) - { - if (prefixMessage != null && !h.getHabboStats().preferOldChat){ h.getClient().sendResponse(prefixMessage); } + for (Habbo h : this.getHabbos()) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + if (prefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(prefixMessage); + } h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat){ h.getClient().sendResponse(clearPrefixMessage); } + if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(clearPrefixMessage); + } } } } - if(chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) - { - synchronized (this.currentBots) - { + if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { + synchronized (this.currentBots) { TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) - { - try - { + for (int i = this.currentBots.size(); i-- > 0; ) { + try { botIterator.advance(); Bot bot = botIterator.value(); bot.onUserSay(roomChatMessage); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } } } - if(roomChatMessage.getBubble().triggersTalkingFurniture()) - { + if (roomChatMessage.getBubble().triggersTalkingFurniture()) { THashSet items = this.roomSpecialTypes.getItemsOfType(InteractionTalkingFurniture.class); - for (HabboItem item : items) - { - if (this.layout.getTile(item.getX(), item.getY()).distance(habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("furniture.talking.range")) - { + for (HabboItem item : items) { + if (this.layout.getTile(item.getX(), item.getY()).distance(habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("furniture.talking.range")) { int count = Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.count", 0); - if (count > 0) - { + if (count > 0) { int randomValue = Emulator.getRandom().nextInt(count + 1); RoomChatMessage itemMessage = new RoomChatMessage(Emulator.getTexts().getValue(item.getBaseItem().getName() + ".message." + randomValue, item.getBaseItem().getName() + ".message." + randomValue + " not found!"), habbo, RoomChatMessageBubbles.getBubble(Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.bubble", RoomChatMessageBubbles.PARROT.getType()))); this.sendComposer(new RoomUserShoutComposer(itemMessage).compose()); - try - { + try { item.onClick(habbo.getClient(), this, new Object[0]); break; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -3962,22 +3167,17 @@ public class Room implements Comparable, ISerialize, Runnable } } - public THashSet getLockedTiles() - { + public THashSet getLockedTiles() { THashSet lockedTiles = new THashSet<>(); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { + for (int i = this.roomItems.size(); i-- > 0; ) { HabboItem item; - try - { + try { iterator.advance(); item = iterator.value(); - } - catch (Exception e) - { + } catch (Exception e) { break; } @@ -3985,43 +3185,31 @@ public class Room implements Comparable, ISerialize, Runnable continue; boolean found = false; - for(RoomTile tile : lockedTiles) - { - if(tile.x == item.getX() && - tile.y == item.getY()) - { + for (RoomTile tile : lockedTiles) { + if (tile.x == item.getX() && + tile.y == item.getY()) { found = true; break; } } - if(!found) - { - if(item.getRotation() == 0 || item.getRotation() == 4) - { - for(short y = 0; y < item.getBaseItem().getLength(); y++) - { - for(short x = 0; x < item.getBaseItem().getWidth(); x++) - { + if (!found) { + if (item.getRotation() == 0 || item.getRotation() == 4) { + for (short y = 0; y < item.getBaseItem().getLength(); y++) { + for (short x = 0; x < item.getBaseItem().getWidth(); x++) { RoomTile tile = this.layout.getTile((short) (item.getX() + x), (short) (item.getY() + y)); - if (tile != null) - { + if (tile != null) { lockedTiles.add(tile); } } } - } - else - { - for(short y = 0; y < item.getBaseItem().getWidth(); y++) - { - for(short x = 0; x < item.getBaseItem().getLength(); x++) - { + } else { + for (short y = 0; y < item.getBaseItem().getWidth(); y++) { + for (short x = 0; x < item.getBaseItem().getLength(); x++) { RoomTile tile = this.layout.getTile((short) (item.getX() + x), (short) (item.getY() + y)); - if (tile != null) - { + if (tile != null) { lockedTiles.add(tile); } } @@ -4034,23 +3222,19 @@ public class Room implements Comparable, ISerialize, Runnable } @Deprecated - public THashSet getItemsAt(int x, int y) - { - RoomTile tile = this.getLayout().getTile((short)x, (short)y); + public THashSet getItemsAt(int x, int y) { + RoomTile tile = this.getLayout().getTile((short) x, (short) y); - if (tile != null) - { + if (tile != null) { return this.getItemsAt(tile); } return new THashSet<>(0); } - public THashSet getItemsAt(RoomTile tile) - { - if (this.loaded) - { - if (this.tileCache.containsKey(tile)) - { + + public THashSet getItemsAt(RoomTile tile) { + if (this.loaded) { + if (this.tileCache.containsKey(tile)) { return this.tileCache.get(tile); } } @@ -4062,16 +3246,12 @@ public class Room implements Comparable, ISerialize, Runnable TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { + for (int i = this.roomItems.size(); i-- > 0; ) { HabboItem item; - try - { + try { iterator.advance(); item = iterator.value(); - } - catch (Exception e) - { + } catch (Exception e) { break; } @@ -4081,59 +3261,45 @@ public class Room implements Comparable, ISerialize, Runnable if (item.getBaseItem().getType() != FurnitureType.FLOOR) continue; - if (item.getX() == tile.x && item.getY() == tile.y) - { + if (item.getX() == tile.x && item.getY() == tile.y) { items.add(item); - } - else - { - if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) - { + } else { + if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) { continue; } THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - for (RoomTile t : tiles) - { - if ((t.x == tile.x) && (t.y == tile.y) && (!items.contains(item))) - { + for (RoomTile t : tiles) { + if ((t.x == tile.x) && (t.y == tile.y) && (!items.contains(item))) { items.add(item); } } } } - if (this.loaded) - { + if (this.loaded) { this.tileCache.put(tile, items); } return items; } - public THashSet getItemsAt(int x, int y, double minZ) - { + public THashSet getItemsAt(int x, int y, double minZ) { THashSet items = new THashSet<>(); - for(HabboItem item : this.getItemsAt(x, y)) - { - if(item.getZ() < minZ) + for (HabboItem item : this.getItemsAt(x, y)) { + if (item.getZ() < minZ) continue; - if(item.getX() == x && item.getY() == y && item.getZ() >= minZ) - { + if (item.getX() == x && item.getY() == y && item.getZ() >= minZ) { items.add(item); - } - else - { - if(item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) - { + } else { + if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) { continue; } THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - for (RoomTile tile : tiles) - { + for (RoomTile tile : tiles) { if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) { items.add(item); } @@ -4143,39 +3309,30 @@ public class Room implements Comparable, ISerialize, Runnable return items; } - public THashSet getItemsAt(Class type, int x, int y) - { + public THashSet getItemsAt(Class type, int x, int y) { THashSet items = new THashSet<>(); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { + for (int i = this.roomItems.size(); i-- > 0; ) { HabboItem item; - try - { + try { iterator.advance(); item = iterator.value(); - } catch (Exception e) - { + } catch (Exception e) { break; } - if(item.getClass().equals(type)) - { - if(item.getX() == x && item.getY() == y) - { + if (item.getClass().equals(type)) { + if (item.getX() == x && item.getY() == y) { items.add(item); - } - else - { - if(item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) - { + } else { + if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) { continue; } THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - for (RoomTile tile : tiles){ + for (RoomTile tile : tiles) { if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) { items.add(item); } @@ -4187,19 +3344,15 @@ public class Room implements Comparable, ISerialize, Runnable return items; } - public boolean hasItemsAt(int x, int y) - { + public boolean hasItemsAt(int x, int y) { TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { + for (int i = this.roomItems.size(); i-- > 0; ) { HabboItem habboItem; - try - { + try { iterator.advance(); habboItem = iterator.value(); - } catch (Exception e) - { + } catch (Exception e) { break; } @@ -4209,50 +3362,38 @@ public class Room implements Comparable, ISerialize, Runnable return false; } - public HabboItem getTopItemAt(int x, int y) - { + public HabboItem getTopItemAt(int x, int y) { return this.getTopItemAt(x, y, null); } - public HabboItem getTopItemAt(int x, int y, HabboItem exclude) - { + public HabboItem getTopItemAt(int x, int y, HabboItem exclude) { HabboItem item = null; TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { + for (int i = this.roomItems.size(); i-- > 0; ) { HabboItem habboItem; - try - { + try { iterator.advance(); habboItem = iterator.value(); - } - catch (Exception e) - { + } catch (Exception e) { break; } if (habboItem.getBaseItem().getType() != FurnitureType.FLOOR) continue; - if (exclude != null) - { + if (exclude != null) { if (exclude == habboItem) continue; } - if (habboItem.getX() == x && habboItem.getY() == y) - { - if (item == null || (habboItem.getZ() + Item.getCurrentHeight(habboItem)) > (item.getZ() + Item.getCurrentHeight(item))) - { + if (habboItem.getX() == x && habboItem.getY() == y) { + if (item == null || (habboItem.getZ() + Item.getCurrentHeight(habboItem)) > (item.getZ() + Item.getCurrentHeight(item))) { item = habboItem; } - } - else - { - if (habboItem.getBaseItem().getWidth() <= 1 && habboItem.getBaseItem().getLength() <= 1) - { + } else { + if (habboItem.getBaseItem().getWidth() <= 1 && habboItem.getBaseItem().getLength() <= 1) { continue; } @@ -4262,10 +3403,8 @@ public class Room implements Comparable, ISerialize, Runnable habboItem.getBaseItem().getLength(), habboItem.getRotation()); - for (RoomTile tile : tiles) - { - if (((tile.x == x) && (tile.y == y))) - { + for (RoomTile tile : tiles) { + if (((tile.x == x) && (tile.y == y))) { if (item == null || item.getZ() < habboItem.getZ()) item = habboItem; } @@ -4276,50 +3415,40 @@ public class Room implements Comparable, ISerialize, Runnable return item; } - public double getTopHeightAt(int x, int y) - { + public double getTopHeightAt(int x, int y) { HabboItem item = this.getTopItemAt(x, y); - if(item != null) + if (item != null) return (item.getZ() + Item.getCurrentHeight(item)); else return this.layout.getHeightAtSquare(x, y); } @Deprecated - public HabboItem getLowestChair(int x, int y) - { - RoomTile tile = this.layout.getTile((short)x, (short)y); + public HabboItem getLowestChair(int x, int y) { + RoomTile tile = this.layout.getTile((short) x, (short) y); - if (tile != null) - { + if (tile != null) { return this.getLowestChair(tile); } return null; } - public HabboItem getLowestChair(RoomTile tile) - { + public HabboItem getLowestChair(RoomTile tile) { HabboItem lowestChair = null; THashSet items = this.getItemsAt(tile); - if (items != null && !items.isEmpty()) - { - for (HabboItem item : items) - { - if (item.getBaseItem().allowSit()) - { - if (lowestChair == null || item.getZ() < lowestChair.getZ()) - { + if (items != null && !items.isEmpty()) { + for (HabboItem item : items) { + if (item.getBaseItem().allowSit()) { + if (lowestChair == null || item.getZ() < lowestChair.getZ()) { lowestChair = item; } } - if (lowestChair != null) - { - if (item.getZ() > lowestChair.getZ() && item.getZ() - lowestChair.getZ() < 1.5) - { + if (lowestChair != null) { + if (item.getZ() > lowestChair.getZ() && item.getZ() - lowestChair.getZ() < 1.5) { lowestChair = null; } } @@ -4329,67 +3458,56 @@ public class Room implements Comparable, ISerialize, Runnable return lowestChair; } - public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) - { - if(x < 0 || y < 0 || this.layout == null) + public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) { + if (x < 0 || y < 0 || this.layout == null) return calculateHeightmap ? Short.MAX_VALUE : 0.0; double height = this.layout.getHeightAtSquare(x, y); boolean canStack = true; boolean stackHelper = false; THashSet items = this.getItemsAt(x, y); - if (items != null) - { - for (HabboItem item : items) - { + if (items != null) { + for (HabboItem item : items) { if (item == exclude) continue; - if (item instanceof InteractionStackHelper) - { + if (item instanceof InteractionStackHelper) { stackHelper = true; height = item.getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(item.getExtradata()) / 100); canStack = true; } } - if (!stackHelper) - { + if (!stackHelper) { HabboItem item = this.getTopItemAt(x, y, exclude); - if (item != null) - { + if (item != null) { canStack = item.getBaseItem().allowStack(); height = item.getZ() + Item.getCurrentHeight(item); } HabboItem lowestChair = this.getLowestChair(x, y); - if(lowestChair != null && lowestChair != exclude) { + if (lowestChair != null && lowestChair != exclude) { canStack = true; height = lowestChair.getZ() + Item.getCurrentHeight(lowestChair); } } } - if(calculateHeightmap) - { + if (calculateHeightmap) { return (canStack ? height * 256.0D : Short.MAX_VALUE); } return canStack ? height : -1; } - public double getStackHeight(short x, short y, boolean calculateHeightmap) - { + public double getStackHeight(short x, short y, boolean calculateHeightmap) { return this.getStackHeight(x, y, calculateHeightmap, null); } - public boolean hasObjectTypeAt(Class type, int x, int y) - { + public boolean hasObjectTypeAt(Class type, int x, int y) { THashSet items = this.getItemsAt(x, y); - for(HabboItem item : items) - { - if(item.getClass() == type) - { + for (HabboItem item : items) { + if (item.getClass() == type) { return true; } } @@ -4397,27 +3515,24 @@ public class Room implements Comparable, ISerialize, Runnable return false; } - public boolean canSitOrLayAt(int x, int y) - { - if(this.hasHabbosAt(x, y)) + public boolean canSitOrLayAt(int x, int y) { + if (this.hasHabbosAt(x, y)) return false; THashSet items = this.getItemsAt(x, y); return this.canSitAt(items) || this.canLayAt(items); } - public boolean canSitAt(int x, int y) - { - if(this.hasHabbosAt(x, y)) + + public boolean canSitAt(int x, int y) { + if (this.hasHabbosAt(x, y)) return false; return this.canSitAt(this.getItemsAt(x, y)); } - boolean canWalkAt(RoomTile roomTile) - { - if (roomTile == null) - { + boolean canWalkAt(RoomTile roomTile) { + if (roomTile == null) { return false; } @@ -4427,24 +3542,17 @@ public class Room implements Comparable, ISerialize, Runnable HabboItem topItem = null; boolean canWalk = true; THashSet items = this.getItemsAt(roomTile); - if (items != null) - { - for (HabboItem item : items) - { - if (topItem == null) - { + if (items != null) { + for (HabboItem item : items) { + if (topItem == null) { topItem = item; } - if (item.getZ() > topItem.getZ()) - { + if (item.getZ() > topItem.getZ()) { topItem = item; canWalk = topItem.isWalkable() || topItem.getBaseItem().allowWalk(); - } - else if (item.getZ() == topItem.getZ() && canWalk) - { - if ((!topItem.isWalkable() && !topItem.getBaseItem().allowWalk()) || (!item.getBaseItem().allowWalk() && !item.isWalkable())) - { + } else if (item.getZ() == topItem.getZ() && canWalk) { + if ((!topItem.isWalkable() && !topItem.getBaseItem().allowWalk()) || (!item.getBaseItem().allowWalk() && !item.isWalkable())) { canWalk = false; } } @@ -4454,8 +3562,7 @@ public class Room implements Comparable, ISerialize, Runnable return canWalk; } - boolean canSitAt(THashSet items) - { + boolean canSitAt(THashSet items) { if (items == null) return false; @@ -4463,61 +3570,51 @@ public class Room implements Comparable, ISerialize, Runnable HabboItem lowestSitItem = null; boolean canSitUnder = false; - for(HabboItem item : items) - { - if((lowestSitItem == null || lowestSitItem.getZ() > item.getZ()) && item.getBaseItem().allowSit()) - { + for (HabboItem item : items) { + if ((lowestSitItem == null || lowestSitItem.getZ() > item.getZ()) && item.getBaseItem().allowSit()) { lowestSitItem = item; canSitUnder = true; } - if(lowestSitItem != null && canSitUnder) - { - if (item != lowestSitItem) - { + if (lowestSitItem != null && canSitUnder) { + if (item != lowestSitItem) { double distance = item.getZ() - lowestSitItem.getZ(); - if (distance >= 0 && distance < 0.8) - { + if (distance >= 0 && distance < 0.8) { canSitUnder = false; } } } - if(topItem == null || Item.getCurrentHeight(item) > Item.getCurrentHeight(topItem)) - { + if (topItem == null || Item.getCurrentHeight(item) > Item.getCurrentHeight(topItem)) { topItem = item; } } - if(topItem == null) + if (topItem == null) return false; - if(lowestSitItem == null) + if (lowestSitItem == null) return false; - if(topItem == lowestSitItem) + if (topItem == lowestSitItem) return true; return topItem.getZ() <= lowestSitItem.getZ() || (canSitUnder); } - public boolean canLayAt(int x, int y) - { + public boolean canLayAt(int x, int y) { return this.canLayAt(this.getItemsAt(x, y)); } - boolean canLayAt(THashSet items) - { + boolean canLayAt(THashSet items) { if (items == null || items.isEmpty()) return true; HabboItem topItem = null; - for(HabboItem item : items) - { - if((topItem == null || item.getZ() > topItem.getZ())) - { + for (HabboItem item : items) { + if ((topItem == null || item.getZ() > topItem.getZ())) { topItem = item; } } @@ -4525,13 +3622,10 @@ public class Room implements Comparable, ISerialize, Runnable return (topItem == null || topItem.getBaseItem().allowLay()); } - public RoomTile getRandomWalkableTile() - { - for (int i = 0; i < 10; i++) - { + public RoomTile getRandomWalkableTile() { + for (int i = 0; i < 10; i++) { RoomTile tile = this.layout.getTile((short) (Math.random() * this.layout.getMapSizeX()), (short) (Math.random() * this.layout.getMapSizeY())); - if (tile.isWalkable()) - { + if (tile.isWalkable()) { return tile; } } @@ -4539,136 +3633,105 @@ public class Room implements Comparable, ISerialize, Runnable return null; } - public Habbo getHabbo(String username) - { - for (Habbo habbo : this.getHabbos()) - { + public Habbo getHabbo(String username) { + for (Habbo habbo : this.getHabbos()) { if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)) return habbo; } return null; } - public Habbo getHabbo(RoomUnit roomUnit) - { - for (Habbo habbo : this.getHabbos()) - { + public Habbo getHabbo(RoomUnit roomUnit) { + for (Habbo habbo : this.getHabbos()) { if (habbo.getRoomUnit() == roomUnit) return habbo; } return null; } - public Habbo getHabbo(int userId) - { + public Habbo getHabbo(int userId) { return this.currentHabbos.get(userId); } - public Habbo getHabboByRoomUnitId(int roomUnitId) - { - for (Habbo habbo : this.getHabbos()) - { - if(habbo.getRoomUnit().getId() == roomUnitId) + public Habbo getHabboByRoomUnitId(int roomUnitId) { + for (Habbo habbo : this.getHabbos()) { + if (habbo.getRoomUnit().getId() == roomUnitId) return habbo; } return null; } - public void sendComposer(ServerMessage message) - { - for (Habbo habbo : this.getHabbos()) - { + public void sendComposer(ServerMessage message) { + for (Habbo habbo : this.getHabbos()) { habbo.getClient().sendResponse(message); } } - public void sendComposerToHabbosWithRights(ServerMessage message) - { - for (Habbo habbo : this.getHabbos()) - { - if (this.hasRights(habbo)) - { + public void sendComposerToHabbosWithRights(ServerMessage message) { + for (Habbo habbo : this.getHabbos()) { + if (this.hasRights(habbo)) { habbo.getClient().sendResponse(message); } } } - public void petChat(ServerMessage message) - { - for (Habbo habbo : this.getHabbos()) - { + public void petChat(ServerMessage message) { + for (Habbo habbo : this.getHabbos()) { if (!habbo.getHabboStats().ignorePets) habbo.getClient().sendResponse(message); } } - public void botChat(ServerMessage message) - { - for (Habbo habbo : this.getHabbos()) - { + public void botChat(ServerMessage message) { + for (Habbo habbo : this.getHabbos()) { if (!habbo.getHabboStats().ignoreBots) habbo.getClient().sendResponse(message); } } - private void loadRights(Connection connection) - { + private void loadRights(Connection connection) { this.rights.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.rights.add(set.getInt("user_id")); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private void loadBans(Connection connection) - { + private void loadBans(Connection connection) { this.bannedHabbos.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.setInt(2, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { if (this.bannedHabbos.containsKey(set.getInt("user_id"))) continue; this.bannedHabbos.put(set.getInt("user_id"), new RoomBan(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } //TODO: Return Enum - public int guildRightLevel(Habbo habbo) - { - if(this.guild > 0 && habbo.getHabboStats().hasGuild(this.guild)) - { + public int guildRightLevel(Habbo habbo) { + if (this.guild > 0 && habbo.getHabboStats().hasGuild(this.guild)) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); - if(Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(habbo.getHabboInfo().getId()) != null) + if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(habbo.getHabboInfo().getId()) != null) return 3; - if(guild.getRights()) - { + if (guild.getRights()) { return 2; } } @@ -4676,165 +3739,125 @@ public class Room implements Comparable, ISerialize, Runnable return 0; } - public boolean isOwner(Habbo habbo) - { + public boolean isOwner(Habbo habbo) { return habbo.getHabboInfo().getId() == this.ownerId || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); } - public boolean hasRights(Habbo habbo) - { + public boolean hasRights(Habbo habbo) { return this.isOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())); } - public void giveRights(Habbo habbo) - { - if(habbo != null) - { + public void giveRights(Habbo habbo) { + if (habbo != null) { this.giveRights(habbo.getHabboInfo().getId()); } } - public void giveRights(int userId) - { + public void giveRights(int userId) { if (this.rights.contains(userId)) return; - if(this.rights.add(userId)) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) - { + if (this.rights.add(userId)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { statement.setInt(1, this.id); statement.setInt(2, userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } Habbo habbo = this.getHabbo(userId); - if(habbo != null) - { + if (habbo != null) { this.refreshRightsForHabbo(habbo); this.sendComposer(new RoomAddRightsListComposer(this, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername()).compose()); - } - else - { + } else { Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.ownerId); - if(owner != null) - { + if (owner != null) { MessengerBuddy buddy = owner.getMessenger().getFriend(userId); - if(buddy != null) - { + if (buddy != null) { this.sendComposer(new RoomAddRightsListComposer(this, userId, buddy.getUsername()).compose()); } } } } - public void removeRights(int userId) - { + public void removeRights(int userId) { Habbo habbo = this.getHabbo(userId); - if(Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.getHabbo(this.getOwnerId()), userId, habbo)).isCancelled()) + if (Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.getHabbo(this.getOwnerId()), userId, habbo)).isCancelled()) return; this.sendComposer(new RoomRemoveRightsListComposer(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 = ?")) - { + 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) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - if(habbo != null) - { + if (habbo != null) { habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); this.refreshRightsForHabbo(habbo); } } - public void removeAllRights() - { + public void removeAllRights() { this.rights.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { statement.setInt(1, this.id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } this.refreshRightsInRoom(); } - void refreshRightsInRoom() - { + void refreshRightsInRoom() { Room room = this; - for (Habbo habbo : this.getHabbos()) - { - if(habbo.getHabboInfo().getCurrentRoom() == room) - { + for (Habbo habbo : this.getHabbos()) { + if (habbo.getHabboInfo().getCurrentRoom() == room) { this.refreshRightsForHabbo(habbo); } } } - public void refreshRightsForHabbo(Habbo habbo) - { + public void refreshRightsForHabbo(Habbo habbo) { HabboItem item; RoomRightLevels flatCtrl = RoomRightLevels.NONE; - if (habbo.getHabboStats().isRentingSpace()) - { + if (habbo.getHabboStats().isRentingSpace()) { item = this.getHabboItem(habbo.getHabboStats().getRentedItemId()); - if (item != null) - { + if (item != null) { return; } } - if (habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) { habbo.getClient().sendResponse(new RoomOwnerComposer()); flatCtrl = RoomRightLevels.MODERATOR; - } - else if (this.isOwner(habbo)) - { + } else if (this.isOwner(habbo)) { habbo.getClient().sendResponse(new RoomOwnerComposer()); flatCtrl = RoomRightLevels.MODERATOR; - } - else if (this.hasRights(habbo) && !this.hasGuild()) - { + } else if (this.hasRights(habbo) && !this.hasGuild()) { flatCtrl = RoomRightLevels.RIGHTS; - } - else if (this.hasGuild()) - { + } else if (this.hasGuild()) { int level = this.guildRightLevel(habbo); - if(level == 3) - { + if (level == 3) { flatCtrl = RoomRightLevels.GUILD_ADMIN; - } - else if(level == 2) - { + } else if (level == 2) { flatCtrl = RoomRightLevels.GUILD_RIGHTS; } } @@ -4845,31 +3868,23 @@ public class Room implements Comparable, ISerialize, Runnable habbo.getRoomUnit().setRightsLevel(flatCtrl); habbo.getRoomUnit().statusUpdate(true); - if (flatCtrl.equals(RoomRightLevels.MODERATOR)) - { + if (flatCtrl.equals(RoomRightLevels.MODERATOR)) { habbo.getClient().sendResponse(new RoomRightsListComposer(this)); } } - public THashMap getUsersWithRights() - { + public THashMap getUsersWithRights() { THashMap rightsMap = new THashMap<>(); - if(!this.rights.isEmpty()) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) - { + if (!this.rights.isEmpty()) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { rightsMap.put(set.getInt("user_id"), set.getString("username")); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -4877,46 +3892,38 @@ public class Room implements Comparable, ISerialize, Runnable return rightsMap; } - public void unbanHabbo(int userId) - { + public void unbanHabbo(int userId) { RoomBan ban = this.bannedHabbos.remove(userId); - if(ban != null) - { + if (ban != null) { ban.delete(); } this.sendComposer(new RoomUserUnbannedComposer(this, userId).compose()); } - public boolean isBanned(Habbo habbo) - { + 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"); - if (!banned && ban != null) - { + if (!banned && ban != null) { this.unbanHabbo(habbo.getHabboInfo().getId()); } return banned; } - public TIntObjectHashMap getBannedHabbos() - { + public TIntObjectHashMap getBannedHabbos() { return this.bannedHabbos; } - public void addRoomBan(RoomBan roomBan) - { + public void addRoomBan(RoomBan roomBan) { this.bannedHabbos.put(roomBan.userId, roomBan); } - public void makeSit(Habbo habbo) - { - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) - { + public void makeSit(Habbo habbo) { + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { return; } @@ -4928,58 +3935,42 @@ public class Room implements Comparable, ISerialize, Runnable this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); } - public void giveEffect(Habbo habbo, int effectId, int duration) - { - if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) - { + public void giveEffect(Habbo habbo, int effectId, int duration) { + if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { this.giveEffect(habbo.getRoomUnit(), effectId, duration); } } - public void giveEffect(RoomUnit roomUnit, int effectId, int duration) - { - if (duration == - 1 || duration == Integer.MAX_VALUE) - { + public void giveEffect(RoomUnit roomUnit, int effectId, int duration) { + if (duration == -1 || duration == Integer.MAX_VALUE) { duration = Integer.MAX_VALUE; - } - else - { + } else { duration += Emulator.getIntUnixTimestamp(); } - if (this.allowEffects && roomUnit != null) - { + if (this.allowEffects && roomUnit != null) { roomUnit.setEffectId(effectId, duration); this.sendComposer(new RoomUserEffectComposer(roomUnit).compose()); } } - public void giveHandItem(Habbo habbo, int handItem) - { + public void giveHandItem(Habbo habbo, int handItem) { this.giveHandItem(habbo.getRoomUnit(), handItem); } - public void giveHandItem(RoomUnit roomUnit, int handItem) - { + public void giveHandItem(RoomUnit roomUnit, int handItem) { roomUnit.setHandItem(handItem); this.sendComposer(new RoomUserHandItemComposer(roomUnit).compose()); } - public void updateItem(HabboItem item) - { - if (this.isLoaded()) - { - if (item != null && item.getRoomId() == this.id) - { - if (item.getBaseItem() != null) - { - if (item.getBaseItem().getType() == FurnitureType.FLOOR) - { + public void updateItem(HabboItem item) { + if (this.isLoaded()) { + if (item != null && item.getRoomId() == this.id) { + if (item.getBaseItem() != null) { + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.sendComposer(new FloorItemUpdateComposer(item).compose()); this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - } - else if (item.getBaseItem().getType() == FurnitureType.WALL) - { + } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new WallItemUpdateComposer(item).compose()); } } @@ -4987,47 +3978,35 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void updateItemState(HabboItem item) - { - if (!item.isLimited()) - { + public void updateItemState(HabboItem item) { + if (!item.isLimited()) { this.sendComposer(new ItemStateComposer(item).compose()); - } - else - { + } else { this.sendComposer(new FloorItemUpdateComposer(item).compose()); } - if (item.getBaseItem().getType() == FurnitureType.FLOOR) - { + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } } - public int getUserFurniCount(int userId) - { + public int getUserFurniCount(int userId) { return this.furniOwnerCount.get(userId); } - public void ejectUserFurni(int userId) - { + public void ejectUserFurni(int userId) { THashSet items = new THashSet<>(); TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } - if (iterator.value().getUserId() == userId) - { + if (iterator.value().getUserId() == userId) { items.add(iterator.value()); iterator.value().setRoomId(0); } @@ -5035,54 +4014,43 @@ public class Room implements Comparable, ISerialize, Runnable Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.getInventory().getItemsComponent().addItems(items); habbo.getClient().sendResponse(new AddHabboItemComposer(items)); } - for (HabboItem i : items) - { + for (HabboItem i : items) { this.pickUpItem(i, null); } } - public void ejectUserItem(HabboItem item) - { + public void ejectUserItem(HabboItem item) { this.pickUpItem(item, null); } - public void ejectAll() - { + public void ejectAll() { this.ejectAll(null); } - public void ejectAll(Habbo habbo) - { + public void ejectAll(Habbo habbo) { THashMap> userItemsMap = new THashMap<>(); - synchronized (this.roomItems) - { + synchronized (this.roomItems) { TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } if (habbo != null && iterator.value().getUserId() == habbo.getHabboInfo().getId()) continue; - if (userItemsMap.get(iterator.value().getUserId()) == null) - { + if (userItemsMap.get(iterator.value().getUserId()) == null) { userItemsMap.put(iterator.value().getUserId(), new THashSet<>()); } @@ -5090,31 +4058,25 @@ public class Room implements Comparable, ISerialize, Runnable } } - for (Map.Entry> entrySet : userItemsMap.entrySet()) - { - for (HabboItem i : entrySet.getValue()) - { + for (Map.Entry> entrySet : userItemsMap.entrySet()) { + for (HabboItem i : entrySet.getValue()) { this.pickUpItem(i, null); } Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey()); - if (user != null) - { + if (user != null) { user.getInventory().getItemsComponent().addItems(entrySet.getValue()); user.getClient().sendResponse(new AddHabboItemComposer(entrySet.getValue())); } } } - public void refreshGuild(Guild guild) - { - if(guild.getRoomId() == this.id) - { + public void refreshGuild(Guild guild) { + if (guild.getRoomId() == this.id) { THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); - for (Habbo habbo : this.getHabbos()) - { + for (Habbo habbo : this.getHabbos()) { Optional member = members.stream().filter(m -> m.getUserId() == habbo.getHabboInfo().getId()).findAny(); if (!member.isPresent()) continue; @@ -5126,27 +4088,20 @@ public class Room implements Comparable, ISerialize, Runnable this.refreshGuildRightsInRoom(); } - public void refreshGuildColors(Guild guild) - { - if(guild.getRoomId() == this.id) - { + public void refreshGuildColors(Guild guild) { + if (guild.getRoomId() == this.id) { TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) - { - try - { + for (int i = this.roomItems.size(); i-- > 0; ) { + try { iterator.advance(); - } - catch (Exception e) - { + } catch (Exception e) { break; } HabboItem habboItem = iterator.value(); - if (habboItem instanceof InteractionGuildFurni) - { + if (habboItem instanceof InteractionGuildFurni) { if (((InteractionGuildFurni) habboItem).getGuildId() == guild.getId()) this.updateItem(habboItem); } @@ -5154,14 +4109,10 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void refreshGuildRightsInRoom() - { - for (Habbo habbo : this.getHabbos()) - { - if (habbo.getHabboInfo().getCurrentRoom() == this) - { - if (habbo.getHabboInfo().getId() != this.ownerId) - { + public void refreshGuildRightsInRoom() { + for (Habbo habbo : this.getHabbos()) { + if (habbo.getHabboInfo().getCurrentRoom() == this) { + if (habbo.getHabboInfo().getId() != this.ownerId) { if (!(habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission("acc_moverotate"))) this.refreshRightsForHabbo(habbo); } @@ -5169,57 +4120,45 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void idle(Habbo habbo) - { + public void idle(Habbo habbo) { habbo.getRoomUnit().setIdle(); this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } - public void unIdle(Habbo habbo) - { + public void unIdle(Habbo habbo) { habbo.getRoomUnit().resetIdleTimer(); this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } - public void dance(Habbo habbo, DanceType danceType) - { + public void dance(Habbo habbo, DanceType danceType) { this.dance(habbo.getRoomUnit(), danceType); } - public void dance(RoomUnit unit, DanceType danceType) - { + public void dance(RoomUnit unit, DanceType danceType) { boolean isDancing = !unit.getDanceType().equals(DanceType.NONE); unit.setDanceType(danceType); this.sendComposer(new RoomUserDanceComposer(unit).compose()); - if (danceType.equals(DanceType.NONE) && isDancing) - { + if (danceType.equals(DanceType.NONE) && isDancing) { WiredHandler.handle(WiredTriggerType.STOPS_DANCING, unit, this, new Object[]{unit}); - } - else if (!danceType.equals(DanceType.NONE) && !isDancing) - { + } else if (!danceType.equals(DanceType.NONE) && !isDancing) { WiredHandler.handle(WiredTriggerType.STARTS_DANCING, unit, this, new Object[]{unit}); } } - public void addToWordFilter(String word) - { - synchronized (this.wordFilterWords) - { + public void addToWordFilter(String word) { + synchronized (this.wordFilterWords) { if (this.wordFilterWords.contains(word)) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO room_wordfilter VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO room_wordfilter VALUES (?, ?)")) { statement.setInt(1, this.getId()); statement.setString(2, word); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); return; } @@ -5228,42 +4167,33 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void removeFromWordFilter(String word) - { - synchronized (this.wordFilterWords) - { + public void removeFromWordFilter(String word) { + synchronized (this.wordFilterWords) { this.wordFilterWords.remove(word); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ? AND word = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ? AND word = ?")) { statement.setInt(1, this.getId()); statement.setString(2, word); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public THashSet getWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) - { - if(!this.wiredHighscoreData.containsKey(scoreType)) - { + public THashSet getWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) { + if (!this.wiredHighscoreData.containsKey(scoreType)) { this.loadWiredHighscoreData(scoreType, clearType); } return this.wiredHighscoreData.get(scoreType).get(clearType); } - public void loadWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) - { + public void loadWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) { this.wiredHighscoreData.clear(); THashSet wiredData = new THashSet<>(); - try - { + try { String query = "SELECT " + "SUM(score + team_score) as total_score, " + "COUNT(*) as wins, " + @@ -5275,54 +4205,38 @@ public class Room implements Comparable, ISerialize, Runnable "WHERE room_id = ? AND game_start_timestamp >= ? "; int timestamp = 0; - if(clearType != WiredHighscoreClearType.ALLTIME) - { - if(clearType == WiredHighscoreClearType.MONTHLY) - { + if (clearType != WiredHighscoreClearType.ALLTIME) { + if (clearType == WiredHighscoreClearType.MONTHLY) { timestamp = Emulator.getIntUnixTimestamp() - (31 * 24 * 60 * 60); - } - else if(clearType == WiredHighscoreClearType.WEEKLY) - { + } else if (clearType == WiredHighscoreClearType.WEEKLY) { timestamp = Emulator.getIntUnixTimestamp() - (7 * 24 * 60 * 60); - } - else if(clearType == WiredHighscoreClearType.DAILY) - { + } else if (clearType == WiredHighscoreClearType.DAILY) { timestamp = Emulator.getIntUnixTimestamp() - (24 * 60 * 60); } } - if(scoreType == WiredHighscoreScoreType.CLASSIC) - { + if (scoreType == WiredHighscoreScoreType.CLASSIC) { query += "GROUP BY game_start_timestamp, user_id, team_id ORDER BY total_score DESC"; - } - else if(scoreType == WiredHighscoreScoreType.MOSTWIN) - { + } else if (scoreType == WiredHighscoreScoreType.MOSTWIN) { query += "GROUP BY game_start_timestamp, game_name, team_id ORDER BY wins DESC, total_score ASC"; - } - else if(scoreType == WiredHighscoreScoreType.PERTEAM) - { + } else if (scoreType == WiredHighscoreScoreType.PERTEAM) { query += "GROUP BY game_start_timestamp, team_id ORDER BY team_score DESC"; } query += " LIMIT " + Emulator.getConfig().getValue("wired.highscores.displaycount"); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { statement.setInt(1, this.id); statement.setInt(2, timestamp); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { wiredData.add(new WiredHighscoreData(set.getString("usernames").split(","), set.getInt("score"), set.getInt("team_score"), set.getInt("total_score"))); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -5331,20 +4245,14 @@ public class Room implements Comparable, ISerialize, Runnable this.wiredHighscoreData.put(scoreType, dataMap); } - public void handleWordQuiz(Habbo habbo, String answer) - { - synchronized (this.userVotes) - { - if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) - { + public void handleWordQuiz(Habbo habbo, String answer) { + synchronized (this.userVotes) { + if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { answer = answer.replace(":", ""); - if (answer.equals("0")) - { + if (answer.equals("0")) { this.noVotes++; - } - else if (answer.equals("1")) - { + } else if (answer.equals("1")) { this.yesVotes++; } @@ -5354,10 +4262,8 @@ public class Room implements Comparable, ISerialize, Runnable } } - public void startWordQuiz(String question, int duration) - { - if (!this.hasActiveWordQuiz()) - { + public void startWordQuiz(String question, int duration) { + if (!this.hasActiveWordQuiz()) { this.wordQuiz = question; this.noVotes = 0; this.yesVotes = 0; @@ -5367,66 +4273,52 @@ public class Room implements Comparable, ISerialize, Runnable } } - public boolean hasActiveWordQuiz() - { + public boolean hasActiveWordQuiz() { return Emulator.getIntUnixTimestamp() < this.wordQuizEnd; } - public boolean hasVotedInWordQuiz(Habbo habbo) - { + public boolean hasVotedInWordQuiz(Habbo habbo) { return this.userVotes.contains(habbo.getHabboInfo().getId()); } - public void alert(String message) - { + public void alert(String message) { this.sendComposer(new GenericAlertComposer(message).compose()); } - public int itemCount() - { + public int itemCount() { return this.roomItems.size(); } - public void setJukeBoxActive(boolean jukeBoxActive) - { + public void setJukeBoxActive(boolean jukeBoxActive) { this.jukeboxActive = jukeBoxActive; this.needsUpdate = true; } - public boolean isHideWired() - { + public boolean isHideWired() { return this.hideWired; } - public void setHideWired(boolean hideWired) - { + public void setHideWired(boolean hideWired) { this.hideWired = hideWired; - if (this.hideWired) - { + if (this.hideWired) { ServerMessage response = null; - for (HabboItem item : this.roomSpecialTypes.getTriggers()) - { + for (HabboItem item : this.roomSpecialTypes.getTriggers()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getEffects()) - { + for (HabboItem item : this.roomSpecialTypes.getEffects()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getConditions()) - { + for (HabboItem item : this.roomSpecialTypes.getConditions()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getExtras()) - { + for (HabboItem item : this.roomSpecialTypes.getExtras()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - } - else - { + } else { this.sendComposer(new RoomFloorItemsComposer(this.furniOwnerNames, this.roomSpecialTypes.getTriggers()).compose()); this.sendComposer(new RoomFloorItemsComposer(this.furniOwnerNames, this.roomSpecialTypes.getEffects()).compose()); this.sendComposer(new RoomFloorItemsComposer(this.furniOwnerNames, this.roomSpecialTypes.getConditions()).compose()); @@ -5434,26 +4326,19 @@ public class Room implements Comparable, ISerialize, Runnable } } - public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) - { + public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) { rotation %= 8; - if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) - { + if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) { return FurnitureMovementError.NONE; } - if(habbo.getHabboStats().isRentingSpace()) - { + if (habbo.getHabboStats().isRentingSpace()) { HabboItem rentSpace = this.getHabboItem(habbo.getHabboStats().rentedItemId); - 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 (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))) { return FurnitureMovementError.NO_RIGHTS; - } - else - { + } else { return FurnitureMovementError.NONE; } } @@ -5462,9 +4347,8 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.NO_RIGHTS; } - public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) - { - if(!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) + public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { + if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); @@ -5477,7 +4361,7 @@ public class Room implements Comparable, ISerialize, Runnable boolean magicTile = item instanceof InteractionStackHelper; - if(!magicTile) { + if (!magicTile) { List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); @@ -5495,14 +4379,13 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.NONE; } - public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) throws Exception - { - if(Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) - { + + public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) throws Exception { + if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, tile); Emulator.getPluginManager().fireEvent(furniturePlacedEvent); - if(furniturePlacedEvent.isCancelled()) + if (furniturePlacedEvent.isCancelled()) return FurnitureMovementError.CANCEL_PLUGIN_PLACE; } @@ -5510,8 +4393,7 @@ public class Room implements Comparable, ISerialize, Runnable FurnitureMovementError fits = furnitureFitsAt(tile, item, rotation); - if (!fits.equals(FurnitureMovementError.NONE)) - { + if (!fits.equals(FurnitureMovementError.NONE)) { return fits; } @@ -5519,8 +4401,7 @@ public class Room implements Comparable, ISerialize, Runnable item.setX(tile.x); item.setY(tile.y); item.setRotation(rotation); - if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) - { + if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) { this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername()); } @@ -5531,8 +4412,7 @@ public class Room implements Comparable, ISerialize, Runnable this.updateTiles(occupiedTiles); this.sendComposer(new AddFloorItemComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); - for (RoomTile t : occupiedTiles) - { + for (RoomTile t : occupiedTiles) { this.updateHabbosAt(t.x, t.y); this.updateBotsAt(t.x, t.y); } @@ -5541,25 +4421,21 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.NONE; } - public FurnitureMovementError placeWallFurniAt(HabboItem item, String wallPosition, Habbo owner) - { - if (!(this.hasRights(owner) || this.guildRightLevel(owner) >= 2)) - { + public FurnitureMovementError placeWallFurniAt(HabboItem item, String wallPosition, Habbo owner) { + if (!(this.hasRights(owner) || this.guildRightLevel(owner) >= 2)) { return FurnitureMovementError.NO_RIGHTS; } - if(Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, null); Emulator.getPluginManager().fireEvent(furniturePlacedEvent); - if(furniturePlacedEvent.isCancelled()) + if (furniturePlacedEvent.isCancelled()) return FurnitureMovementError.CANCEL_PLUGIN_PLACE; } item.setWallPosition(wallPosition); - if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) - { + if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) { this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername()); } this.sendComposer(new AddWallItemComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); @@ -5571,11 +4447,9 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.NONE; } - public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) - { + public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) { RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY()); - if(Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) - { + if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) { if (Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile)).isCancelled()) return FurnitureMovementError.CANCEL_PLUGIN_MOVE; } @@ -5586,10 +4460,8 @@ public class Room implements Comparable, ISerialize, Runnable //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - if (topItem != item) - { - for (RoomTile t : occupiedTiles) - { + if (topItem != item) { + for (RoomTile t : occupiedTiles) { if (!magicTile && ((this.getTopItemAt(t.x, t.y) != item ? t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) return FurnitureMovementError.CANT_STACK; if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; @@ -5599,13 +4471,11 @@ public class Room implements Comparable, ISerialize, Runnable } List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) - { + for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } - if (!magicTile && !item.canStackAt(this, tileFurniList)) - { + if (!magicTile && !item.canStackAt(this, tileFurniList)) { return FurnitureMovementError.CANT_STACK; } @@ -5614,15 +4484,12 @@ public class Room implements Comparable, ISerialize, Runnable int oldRotation = item.getRotation(); item.setRotation(rotation); - if (oldRotation != rotation) - { - if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) - { + if (oldRotation != rotation) { + if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) { Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); - if (furnitureRotatedEvent.isCancelled()) - { + if (furnitureRotatedEvent.isCancelled()) { item.setRotation(oldRotation); return FurnitureMovementError.CANCEL_PLUGIN_ROTATE; } @@ -5632,13 +4499,11 @@ public class Room implements Comparable, ISerialize, Runnable item.setX(tile.x); item.setY(tile.y); item.setZ(this.getStackHeight(tile.x, tile.y, false, item)); - if (magicTile) - { + if (magicTile) { item.setZ(tile.z); item.setExtradata("" + item.getZ() * 100); } - if (item.getZ() > 40d) - { + if (item.getZ() > 40d) { item.setZ(40); } @@ -5655,16 +4520,14 @@ public class Room implements Comparable, ISerialize, Runnable this.updateTiles(occupiedTiles); //Update Habbos at old position - for (RoomTile t : occupiedTiles) - { + for (RoomTile t : occupiedTiles) { this.updateHabbosAt(t.x, t.y); this.updateBotsAt(t.x, t.y); } return FurnitureMovementError.NONE; } - public FurnitureMovementError slideFurniTo(HabboItem item, RoomTile tile, int rotation) - { + 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); @@ -5675,13 +4538,11 @@ public class Room implements Comparable, ISerialize, Runnable THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) - { + for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } - if (!magicTile && !item.canStackAt(this, tileFurniList)) - { + if (!magicTile && !item.canStackAt(this, tileFurniList)) { return FurnitureMovementError.CANT_STACK; } @@ -5691,21 +4552,18 @@ public class Room implements Comparable, ISerialize, Runnable item.setRotation(rotation); //Place at new position - if (magicTile) - { + if (magicTile) { item.setZ(tile.z); item.setExtradata("" + item.getZ() * 100); } - if (item.getZ() > 40d) - { + if (item.getZ() > 40d) { item.setZ(40); } double offset = this.getStackHeight(tile.x, tile.y, false, item) - item.getZ(); this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose()); //Update Habbos at old position - for (RoomTile t : occupiedTiles) - { + for (RoomTile t : occupiedTiles) { this.updateHabbosAt(t.x, t.y); this.updateBotsAt(t.x, t.y); } 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 895076dd..806b5c23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java @@ -7,8 +7,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class RoomBan -{ +public class RoomBan { public final int roomId; @@ -21,16 +20,14 @@ public class RoomBan public final int endTimestamp; - public RoomBan(int roomId, int userId, String username, int endTimestamp) - { + public RoomBan(int roomId, int userId, String username, int endTimestamp) { this.roomId = roomId; this.userId = userId; this.username = username; this.endTimestamp = endTimestamp; } - public RoomBan(ResultSet set) throws SQLException - { + public RoomBan(ResultSet set) throws SQLException { this.roomId = set.getInt("room_id"); this.userId = set.getInt("user_id"); this.username = set.getString("username"); @@ -38,32 +35,24 @@ public class RoomBan } - public void insert() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_bans (room_id, user_id, ends) VALUES (?, ?, ?)")) - { + public void insert() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_bans (room_id, user_id, ends) VALUES (?, ?, ?)")) { statement.setInt(1, this.roomId); statement.setInt(2, this.userId); statement.setInt(3, this.endTimestamp); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void delete() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_bans WHERE room_id = ? AND user_id = ?")) - { + public void delete() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_bans WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, this.roomId); statement.setInt(2, this.userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 06e6669f..59b7b920 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCategory.java @@ -18,8 +18,7 @@ public class RoomCategory implements Comparable { private ListMode displayMode; private int order; - public RoomCategory(ResultSet set) throws SQLException - { + public RoomCategory(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.minRank = set.getInt("min_rank"); this.caption = set.getString("caption"); @@ -39,13 +38,11 @@ public class RoomCategory implements Comparable { return this.minRank; } - public String getCaption() - { + public String getCaption() { return this.caption; } - public String getCaptionSave() - { + public String getCaptionSave() { return this.captionSave; } @@ -53,23 +50,19 @@ public class RoomCategory implements Comparable { return this.canTrade; } - public int getMaxUserCount() - { + public int getMaxUserCount() { return this.maxUserCount; } - public boolean isPublic() - { + public boolean isPublic() { return this.official; } - public ListMode getDisplayMode() - { + public ListMode getDisplayMode() { return this.displayMode; } - public int getOrder() - { + public int getOrder() { return this.order; } 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 9f1559c1..c6ed428e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -13,54 +13,42 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.List; -public class RoomChatMessage implements Runnable, ISerialize, Loggable -{ +public class RoomChatMessage implements Runnable, ISerialize, Loggable { + private static final List chatColors = Arrays.asList("@red@", "@cyan@", "@blue@", "@green@", "@purple@"); public static String insertQuery = "INSERT INTO chatlogs_room (user_from_id, user_to_id, message, timestamp, room_id) VALUES (?, ?, ?, ?, ?)"; public static int MAXIMUM_LENGTH = 100; //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_ROOM_CHATS = false; public static int[] BANNED_BUBBLES = {}; - + private final Habbo habbo; + public int roomId; + public boolean isCommand = false; + public boolean filtered = false; private int roomUnitId; private String message; private String unfilteredMessage; private int timestamp = 0; private RoomChatMessageBubbles bubble; - private final Habbo habbo; - public int roomId; private Habbo targetHabbo; private byte emotion; - public boolean isCommand = false; - public boolean filtered = false; - private static final List chatColors = Arrays.asList("@red@", "@cyan@", "@blue@", "@green@", "@purple@"); - public RoomChatMessage(MessageHandler message) - { - if (message.packet.getMessageId() == Incoming.RoomUserWhisperEvent) - { + public RoomChatMessage(MessageHandler message) { + if (message.packet.getMessageId() == Incoming.RoomUserWhisperEvent) { String data = message.packet.readString(); this.targetHabbo = message.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(data.split(" ")[0]); this.message = data.substring(data.split(" ")[0].length() + 1); - } - else - { + } else { this.message = message.packet.readString(); } - try - { + try { this.bubble = RoomChatMessageBubbles.getBubble(message.packet.readInt()); - } - catch (Exception e) - { + } catch (Exception e) { this.bubble = RoomChatMessageBubbles.NORMAL; } - if (!message.client.getHabbo().hasPermission("acc_anychatcolor")) - { - for (Integer i : RoomChatMessage.BANNED_BUBBLES) - { - if (i == this.bubble.getType()) - { + if (!message.client.getHabbo().hasPermission("acc_anychatcolor")) { + for (Integer i : RoomChatMessage.BANNED_BUBBLES) { + if (i == this.bubble.getType()) { this.bubble = RoomChatMessageBubbles.NORMAL; } } @@ -76,19 +64,17 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable this.filter(); } - public RoomChatMessage(RoomChatMessage chatMessage) - { + public RoomChatMessage(RoomChatMessage chatMessage) { this.message = chatMessage.getMessage(); this.unfilteredMessage = chatMessage.getUnfilteredMessage(); this.habbo = chatMessage.getHabbo(); this.targetHabbo = chatMessage.getTargetHabbo(); this.bubble = chatMessage.getBubble(); this.roomUnitId = chatMessage.roomUnitId; - this.emotion = (byte)chatMessage.getEmotion(); + this.emotion = (byte) chatMessage.getEmotion(); } - public RoomChatMessage(String message, RoomUnit roomUnit, RoomChatMessageBubbles bubble) - { + public RoomChatMessage(String message, RoomUnit roomUnit, RoomChatMessageBubbles bubble) { this.message = message; this.unfilteredMessage = message; this.habbo = null; @@ -96,8 +82,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable this.roomUnitId = roomUnit.getId(); } - public RoomChatMessage(String message, Habbo habbo, RoomChatMessageBubbles bubble) - { + public RoomChatMessage(String message, Habbo habbo, RoomChatMessageBubbles bubble) { this.message = message; this.unfilteredMessage = message; this.habbo = habbo; @@ -106,12 +91,11 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable this.roomUnitId = habbo.getRoomUnit().getId(); this.message = this.message.replace("\r", "").replace("\n", ""); - if(this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) + if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) this.bubble = this.getHabbo().getHabboStats().chatColor; } - public RoomChatMessage(String message, Habbo habbo, Habbo targetHabbo, RoomChatMessageBubbles bubble) - { + public RoomChatMessage(String message, Habbo habbo, Habbo targetHabbo, RoomChatMessageBubbles bubble) { this.message = message; this.unfilteredMessage = message; this.habbo = habbo; @@ -121,67 +105,50 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable this.roomUnitId = this.habbo.getRoomUnit().getId(); this.message = this.message.replace("\r", "").replace("\n", ""); - if(this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) + if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().chatColor != RoomChatMessageBubbles.NORMAL) this.bubble = this.getHabbo().getHabboStats().chatColor; } - private void checkEmotion() - { - if(this.message.contains(":)") || this.message.contains(":-)") || this.message.contains(":]")) - { + private void checkEmotion() { + if (this.message.contains(":)") || this.message.contains(":-)") || this.message.contains(":]")) { this.emotion = 1; - } - else if(this.message.contains(":@") || this.message.contains(">:(")) - { + } else if (this.message.contains(":@") || this.message.contains(">:(")) { this.emotion = 2; - } - else if(this.message.contains(":o") || this.message.contains(":O") || this.message.contains(":0") || this.message.contains("O.o") || this.message.contains("o.O") || this.message.contains("O.O")) - { + } else if (this.message.contains(":o") || this.message.contains(":O") || this.message.contains(":0") || this.message.contains("O.o") || this.message.contains("o.O") || this.message.contains("O.O")) { this.emotion = 3; - } - else if(this.message.contains(":(") || this.message.contains(":-(") || this.message.contains(":[")) - { + } else if (this.message.contains(":(") || this.message.contains(":-(") || this.message.contains(":[")) { this.emotion = 4; } } @Override - public void run() - { - if(this.habbo == null) + public void run() { + if (this.habbo == null) return; - if(this.message.length() > RoomChatMessage.MAXIMUM_LENGTH) - { - try - { - this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH-1); - } - catch (Exception e) - { + if (this.message.length() > RoomChatMessage.MAXIMUM_LENGTH) { + try { + this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH - 1); + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } Emulator.getLogging().addChatLog(this); } - public String getMessage() - { + public String getMessage() { return this.message; } - public String getUnfilteredMessage() - { - return this.unfilteredMessage; - } - - public void setMessage(String message) - { + public void setMessage(String message) { this.message = message; } - public RoomChatMessageBubbles getBubble() - { + public String getUnfilteredMessage() { + return this.unfilteredMessage; + } + + public RoomChatMessageBubbles getBubble() { return this.bubble; } @@ -189,27 +156,20 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable return this.habbo; } - public Habbo getTargetHabbo() - { + public Habbo getTargetHabbo() { return this.targetHabbo; } - public int getEmotion() - { + public int getEmotion() { return this.emotion; } @Override - public void serialize(ServerMessage message) - { - if(this.habbo != null && this.bubble.isOverridable()) - { - if (!this.habbo.hasPermission("acc_anychatcolor")) - { - for (Integer i : RoomChatMessage.BANNED_BUBBLES) - { - if (i == this.bubble.getType()) - { + public void serialize(ServerMessage message) { + if (this.habbo != null && this.bubble.isOverridable()) { + if (!this.habbo.hasPermission("acc_anychatcolor")) { + for (Integer i : RoomChatMessage.BANNED_BUBBLES) { + if (i == this.bubble.getType()) { this.bubble = RoomChatMessageBubbles.NORMAL; break; } @@ -217,52 +177,39 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable } } - if (!this.getBubble().getPermission().isEmpty()) - { - if (this.habbo != null && !this.habbo.hasPermission(this.getBubble().getPermission())) - { + if (!this.getBubble().getPermission().isEmpty()) { + if (this.habbo != null && !this.habbo.hasPermission(this.getBubble().getPermission())) { this.bubble = RoomChatMessageBubbles.NORMAL; } } - try - { + try { message.appendInt(this.roomUnitId); message.appendString(this.getMessage()); message.appendInt(this.getEmotion()); message.appendInt(this.getBubble().getType()); message.appendInt(0); message.appendInt(this.getMessage().length()); - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - public void filter() - { - if(!this.habbo.getHabboStats().hasActiveClub()) - { + public void filter() { + if (!this.habbo.getHabboStats().hasActiveClub()) { for (String chatColor : chatColors) { this.message = this.message.replace(chatColor, ""); } } - - if(Emulator.getConfig().getBoolean("hotel.wordfilter.enabled") && Emulator.getConfig().getBoolean("hotel.wordfilter.rooms")) - { - if(!this.habbo.hasPermission("acc_chat_no_filter")) - { - if (!Emulator.getGameEnvironment().getWordFilter().autoReportCheck(this)) - { - if (!Emulator.getGameEnvironment().getWordFilter().hideMessageCheck(this.message)) - { + + if (Emulator.getConfig().getBoolean("hotel.wordfilter.enabled") && Emulator.getConfig().getBoolean("hotel.wordfilter.rooms")) { + if (!this.habbo.hasPermission("acc_chat_no_filter")) { + if (!Emulator.getGameEnvironment().getWordFilter().autoReportCheck(this)) { + if (!Emulator.getGameEnvironment().getWordFilter().hideMessageCheck(this.message)) { Emulator.getGameEnvironment().getWordFilter().filter(this, this.habbo); return; } - } - else - { + } else { this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute")); } @@ -272,11 +219,10 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable } @Override - public void log(PreparedStatement statement) throws SQLException - { - statement.setInt(1,this.habbo.getHabboInfo().getId()); + public void log(PreparedStatement statement) throws SQLException { + statement.setInt(1, this.habbo.getHabboInfo().getId()); - if(this.targetHabbo != null) + if (this.targetHabbo != null) statement.setInt(2, this.targetHabbo.getHabboInfo().getId()); else statement.setInt(2, 0); @@ -284,12 +230,9 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable statement.setString(3, this.unfilteredMessage); statement.setInt(4, this.timestamp); - if(this.habbo.getHabboInfo().getCurrentRoom() != null) - { + if (this.habbo.getHabboInfo().getCurrentRoom() != null) { statement.setInt(5, this.habbo.getHabboInfo().getCurrentRoom().getId()); - } - else - { + } else { statement.setInt(5, 0); } 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 42086bef..31b7e905 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomChatMessageBubbles -{ +public enum RoomChatMessageBubbles { NORMAL(0, "", true, true), ALERT(1, "", true, true), BOT(2, "", true, true), @@ -54,42 +53,34 @@ public enum RoomChatMessageBubbles private final boolean overridable; private final boolean triggersTalkingFurniture; - RoomChatMessageBubbles(int type, String permission, boolean overridable, boolean triggersTalkingFurniture) - { + RoomChatMessageBubbles(int type, String permission, boolean overridable, boolean triggersTalkingFurniture) { this.type = type; this.permission = permission; this.overridable = overridable; this.triggersTalkingFurniture = triggersTalkingFurniture; } - public int getType() - { - return this.type; - } - - public String getPermission() - { - return this.permission; - } - - public boolean isOverridable() - { - return this.overridable; - } - - public boolean triggersTalkingFurniture() - { - return this.triggersTalkingFurniture; - } - public static RoomChatMessageBubbles getBubble(int bubbleId) - { - try - { + public static RoomChatMessageBubbles getBubble(int bubbleId) { + try { return values()[bubbleId]; - } - catch (Exception e) - { + } catch (Exception e) { return NORMAL; } } + + 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/RoomChatType.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatType.java index 641e35c5..cb252f56 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatType.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomChatType -{ +public enum RoomChatType { TALK, SHOUT, WHISPER 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 1bcbdf0b..7da2e518 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -1,25 +1,22 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; import java.awt.*; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Deque; +import java.util.LinkedList; import java.util.List; -public class RoomLayout -{ - public static double MAXIMUM_STEP_HEIGHT = 1.1; - public static boolean ALLOW_FALLING = true; +public class RoomLayout { protected static final int BASICMOVEMENTCOST = 10; protected static final int DIAGONALMOVEMENTCOST = 14; - - public boolean CANMOVEDIAGONALY = true; + public static double MAXIMUM_STEP_HEIGHT = 1.1; + public static boolean ALLOW_FALLING = true; + public boolean CANMOVEDIAGONALY = true; private String name; private short doorX; private short doorY; @@ -33,11 +30,9 @@ public class RoomLayout private RoomTile doorTile; private Room room; - public RoomLayout(ResultSet set, Room room) throws SQLException - { + public RoomLayout(ResultSet set, Room room) throws SQLException { this.room = room; - try - { + try { this.name = set.getString("name"); this.doorX = set.getShort("door_x"); this.doorY = set.getShort("door_y"); @@ -46,15 +41,57 @@ public class RoomLayout this.heightmap = set.getString("heightmap"); this.parse(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - public void parse() - { + public static boolean squareInSquare(Rectangle outerSquare, Rectangle innerSquare) { + if (outerSquare.x > innerSquare.x) + return false; + + if (outerSquare.y > innerSquare.y) + return false; + + if (outerSquare.x + outerSquare.width < innerSquare.x + innerSquare.width) + return false; + + if (outerSquare.y + outerSquare.height < innerSquare.y + innerSquare.height) + return false; + + return true; + } + + public static boolean tileInSquare(Rectangle square, RoomTile tile) { + return (square.contains(tile.x, tile.y)); + } + + public static boolean pointInSquare(int x1, int y1, int x2, int y2, int pointX, int pointY) { + return (pointX >= x1 && pointY >= y1) && (pointX <= x2 && pointY <= y2); + } + + 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); + } + + public static Rectangle getRectangle(int x, int y, int width, int length, int rotation) { + rotation = (rotation % 8); + + if (rotation == 2 || rotation == 6) { + return new Rectangle(x, y, length, width); + } + + return new Rectangle(x, y, width, length); + } + + 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 = new Rectangle(rectangle.x - 1, rectangle.y - 1, rectangle.width + 2, rectangle.height + 2); + + return rectangle.contains(tile.x, tile.y); + } + + public void parse() { String[] modelTemp = this.heightmap.replace("\n", "").split(Character.toString('\r')); this.mapSize = 0; @@ -62,38 +99,27 @@ public class RoomLayout this.mapSizeY = modelTemp.length; this.roomTiles = new RoomTile[this.mapSizeX][this.mapSizeY]; - for (short y = 0; y < this.mapSizeY; y++) - { - if(modelTemp[y].isEmpty() || modelTemp[y].equalsIgnoreCase("\r")) - { + for (short y = 0; y < this.mapSizeY; y++) { + if (modelTemp[y].isEmpty() || modelTemp[y].equalsIgnoreCase("\r")) { continue; } - for (short x = 0; x < this.mapSizeX; x++) - { - if(modelTemp[y].length() != this.mapSizeX) - { + for (short x = 0; x < this.mapSizeX; x++) { + if (modelTemp[y].length() != this.mapSizeX) { break; } String square = modelTemp[y].substring(x, x + 1).trim().toLowerCase(); RoomTileState state = RoomTileState.OPEN; short height = 0; - if (square.equalsIgnoreCase("x")) - { + if (square.equalsIgnoreCase("x")) { state = RoomTileState.INVALID; - } - else - { + } else { if (square.isEmpty()) { height = 0; - } - else if (Emulator.isNumeric(square)) - { + } else if (Emulator.isNumeric(square)) { height = Short.parseShort(square); - } - else - { + } else { height = (short) (10 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(square.toUpperCase())); } } @@ -105,17 +131,13 @@ public class RoomLayout this.doorTile = this.roomTiles[this.doorX][this.doorY]; - if (this.doorTile != null) - { + if (this.doorTile != null) { 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) - { + 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; } @@ -124,90 +146,74 @@ public class RoomLayout } } - public String getName() - { + public String getName() { return this.name; } - public short getDoorX() - { + public short getDoorX() { return this.doorX; } - public void setDoorX(short doorX) - { + public void setDoorX(short doorX) { this.doorX = doorX; } - public short getDoorY() - { + public short getDoorY() { return this.doorY; } - public void setDoorY(short doorY) - { + public void setDoorY(short doorY) { this.doorY = doorY; } - public int getDoorZ() - { + public int getDoorZ() { return this.doorZ; } - public RoomTile getDoorTile() - { + public RoomTile getDoorTile() { return this.doorTile; } - public int getDoorDirection() - { + public int getDoorDirection() { return this.doorDirection; } - public void setDoorDirection(int doorDirection) - { + public void setDoorDirection(int doorDirection) { this.doorDirection = doorDirection; } - public void setHeightmap(String heightMap) - { - this.heightmap = heightMap; - } - - public String getHeightmap() - { + public String getHeightmap() { return this.heightmap; } - public int getMapSize() - { + public void setHeightmap(String heightMap) { + this.heightmap = heightMap; + } + + public int getMapSize() { return this.mapSize; } - public int getMapSizeX() - { + public int getMapSizeX() { return this.mapSizeX; } - public int getMapSizeY() - { + public int getMapSizeY() { return this.mapSizeY; } - public short getHeightAtSquare(int x, int y) - { - if(x < 0 || - y < 0 || - x >= this.getMapSizeX() || - y >= this.getMapSizeY()) + public short getHeightAtSquare(int x, int y) { + if (x < 0 || + y < 0 || + x >= this.getMapSizeX() || + y >= this.getMapSizeY()) return 0; return this.roomTiles[x][y].z; } - public double getStackHeightAtSquare(int x, int y) - { - if(x < 0 || + public double getStackHeightAtSquare(int x, int y) { + if (x < 0 || y < 0 || x >= this.getMapSizeX() || y >= this.getMapSizeY()) @@ -216,9 +222,8 @@ public class RoomLayout return this.roomTiles[x][y].getStackHeight(); } - public double getRelativeHeightAtSquare(int x, int y) - { - if(x < 0 || + public double getRelativeHeightAtSquare(int x, int y) { + if (x < 0 || y < 0 || x >= this.getMapSizeX() || y >= this.getMapSizeY()) @@ -227,46 +232,38 @@ public class RoomLayout return this.roomTiles[x][y].relativeHeight(); } - public RoomTile getTile(short x, short y) - { - if (this.tileExists(x, y)) - { + public RoomTile getTile(short x, short y) { + if (this.tileExists(x, y)) { return this.roomTiles[x][y]; } return null; } - public boolean tileExists(short x, short y) - { + public boolean tileExists(short x, short y) { return !(x < 0 || y < 0 || x >= this.getMapSizeX() || y >= this.getMapSizeY()); } - public boolean tileWalkable(short x, short y) - { + public boolean tileWalkable(short x, short y) { return this.tileExists(x, y) && this.roomTiles[x][y].state == RoomTileState.OPEN && this.roomTiles[x][y].isWalkable(); } - public boolean isVoidTile(short x, short y) - { + public boolean isVoidTile(short x, short y) { if (!this.tileExists(x, y)) return true; return this.roomTiles[x][y].state == RoomTileState.INVALID; } - public RoomTileState getStateAt(short x, short y) - { + public RoomTileState getStateAt(short x, short y) { return this.roomTiles[x][y].state; } - public String getRelativeMap() - { + + public String getRelativeMap() { return this.heightmap.replace("\r\n", "\r"); } - public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) - { + public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) { LinkedList openList = new LinkedList<>(); - try - { + try { if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) return openList; @@ -275,28 +272,24 @@ public class RoomLayout openList.add(oldTile.copy()); long startMillis = System.currentTimeMillis(); - while (true) - { - if (System.currentTimeMillis() - startMillis > 50) - { + while (true) { + if (System.currentTimeMillis() - startMillis > 50) { return new LinkedList<>(); } RoomTile current = this.lowestFInOpen(openList); openList.remove(current); - if ((current.x == newTile.x) && (current.y == newTile.y)) - { + if ((current.x == newTile.x) && (current.y == newTile.y)) { return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); } List adjacentNodes = this.getAdjacent(openList, current, newTile); - for (RoomTile currentAdj : adjacentNodes) - { + for (RoomTile currentAdj : adjacentNodes) { if (closedList.contains(currentAdj)) continue; - if(roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) { + if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) { currentAdj.setPrevious(current); currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); currentAdj.setgCosts(current); @@ -305,8 +298,7 @@ public class RoomLayout } //If the tile is sitable or layable and its not our goal tile, we cannot walk over it. - if (!currentAdj.equals(goalLocation) && (currentAdj.state == RoomTileState.BLOCKED || currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY)) - { + if (!currentAdj.equals(goalLocation) && (currentAdj.state == RoomTileState.BLOCKED || currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY)) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -317,14 +309,13 @@ public class RoomLayout double height = currentAdj.getStackHeight() - current.getStackHeight(); //If we are not allowed to fall and the height difference is bigger than the maximum stepheight, continue. - if (!ALLOW_FALLING && height < - MAXIMUM_STEP_HEIGHT) continue; + if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; //If the step difference is bigger than the maximum step height, continue. if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; //Check if the tile has habbos. - if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) - { + if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -332,60 +323,48 @@ public class RoomLayout //if (room.hasPetsAt(currentAdj.x, currentAdj.y)) continue; - if (!openList.contains(currentAdj)) - { + if (!openList.contains(currentAdj)) { currentAdj.setPrevious(current); currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); 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); } } - if (openList.isEmpty()) - { + if (openList.isEmpty()) { return new LinkedList<>(); } } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return new LinkedList<>(); } - private RoomTile findTile(List tiles, short x, short y) - { - for (RoomTile tile : tiles) - { - if (x == tile.x && y == tile.y) - { + private RoomTile findTile(List tiles, short x, short y) { + for (RoomTile tile : tiles) { + if (x == tile.x && y == tile.y) { return tile; } } RoomTile tile = this.getTile(x, y); - if (tile != null) - { + if (tile != null) { return tile.copy(); } return null; } - private Deque calcPath(RoomTile start, RoomTile goal) - { + private Deque calcPath(RoomTile start, RoomTile goal) { LinkedList path = new LinkedList<>(); if (start == null) return path; RoomTile curr = goal; - while (curr != null) - { + while (curr != null) { path.addFirst(this.getTile(curr.x, curr.y)); curr = curr.getPrevious(); if ((curr != null) && (curr.equals(start))) { @@ -395,92 +374,71 @@ public class RoomLayout return path; } - private RoomTile lowestFInOpen(List openList) - { - if(openList == null) + private RoomTile lowestFInOpen(List openList) { + if (openList == null) return null; RoomTile cheapest = openList.get(0); - for (RoomTile anOpenList : openList) - { - if (anOpenList.getfCosts() < cheapest.getfCosts()) - { + for (RoomTile anOpenList : openList) { + if (anOpenList.getfCosts() < cheapest.getfCosts()) { cheapest = anOpenList; } } return cheapest; } - private List getAdjacent(List openList, RoomTile node, RoomTile nextTile) - { + private List getAdjacent(List openList, RoomTile node, RoomTile nextTile) { short x = node.x; short y = node.y; List adj = new LinkedList<>(); - if (x > 0) - { + if (x > 0) { RoomTile temp = this.findTile(openList, (short) (x - 1), y); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); } } } - if (x < this.mapSizeX) - { + if (x < this.mapSizeX) { RoomTile temp = this.findTile(openList, (short) (x + 1), y); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); } } } - if (y > 0) - { + if (y > 0) { RoomTile temp = this.findTile(openList, x, (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); } } } - if (y < this.mapSizeY) - { + if (y < this.mapSizeY) { RoomTile temp = this.findTile(openList, x, (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) adj.add(temp); } } } - if (this.CANMOVEDIAGONALY) - { - if ((x < this.mapSizeX) && (y < this.mapSizeY)) - { + if (this.CANMOVEDIAGONALY) { + if ((x < this.mapSizeX) && (y < this.mapSizeY)) { RoomTile offX = this.findTile(openList, (short) (x + 1), y); - RoomTile offY = this.findTile(openList, x, (short) (y+1)); - if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) - { + RoomTile offY = this.findTile(openList, x, (short) (y + 1)); + if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -488,17 +446,13 @@ public class RoomLayout } } } - if ((x > 0) && (y > 0)) - { + if ((x > 0) && (y > 0)) { RoomTile offX = this.findTile(openList, (short) (x - 1), y); RoomTile offY = this.findTile(openList, x, (short) (y - 1)); - if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) - { + if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -506,17 +460,13 @@ public class RoomLayout } } } - if ((x > 0) && (y < this.mapSizeY)) - { + if ((x > 0) && (y < this.mapSizeY)) { RoomTile offX = this.findTile(openList, (short) (x - 1), y); - RoomTile offY = this.findTile(openList, x, (short) (y+1)); - if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) - { + RoomTile offY = this.findTile(openList, x, (short) (y + 1)); + if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -524,17 +474,13 @@ public class RoomLayout } } } - if ((x < this.mapSizeX) && (y > 0)) - { + if ((x < this.mapSizeX) && (y > 0)) { RoomTile offX = this.findTile(openList, (short) (x + 1), y); RoomTile offY = this.findTile(openList, x, (short) (y - 1)); - if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) - { + if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) - { - if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) - { + if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) adj.add(temp); @@ -546,71 +492,54 @@ public class RoomLayout return adj; } - public void moveDiagonally(boolean value) - { + public void moveDiagonally(boolean value) { this.CANMOVEDIAGONALY = value; } - public static boolean squareInSquare(Rectangle outerSquare, Rectangle innerSquare) - { - if(outerSquare.x > innerSquare.x) - return false; - - if(outerSquare.y > innerSquare.y) - return false; - - if(outerSquare.x + outerSquare.width < innerSquare.x + innerSquare.width) - return false; - - if(outerSquare.y + outerSquare.height < innerSquare.y + innerSquare.height) - return false; - - return true; - } - - public static boolean tileInSquare(Rectangle square, RoomTile tile) - { - return (square.contains(tile.x, tile.y)); - } - - public static boolean pointInSquare(int x1, int y1, int x2, int y2, int pointX, int pointY) - { - return (pointX >= x1 && pointY >= y1) && (pointX <= x2 && pointY <= y2); - } - - 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); - } - - public RoomTile getTileInFront(RoomTile tile, int rotation) - { + public RoomTile getTileInFront(RoomTile tile, int rotation) { return this.getTileInFront(tile, rotation, 0); } - public RoomTile getTileInFront(RoomTile tile, int rotation, int offset) - { + public RoomTile getTileInFront(RoomTile tile, int rotation, int offset) { int offsetX = 0; int offsetY = 0; rotation = rotation % 8; - switch (rotation) - { - case 0: offsetY--; break; - case 1: offsetX++; offsetY--; break; - case 2: offsetX++; break; - case 3: offsetX++; offsetY++; break; - case 4: offsetY++; break; - case 5: offsetX--; offsetY++; break; - case 6: offsetX--; break; - case 7: offsetX--; offsetY--; break; + switch (rotation) { + case 0: + offsetY--; + break; + case 1: + offsetX++; + offsetY--; + break; + case 2: + offsetX++; + break; + case 3: + offsetX++; + offsetY++; + break; + case 4: + offsetY++; + break; + case 5: + offsetX--; + offsetY++; + break; + case 6: + offsetX--; + break; + case 7: + offsetX--; + offsetY--; + break; } short x = tile.x; short y = tile.y; - for (int i = 0; i <= offset; i++) - { + for (int i = 0; i <= offset; i++) { x += offsetX; y += offsetY; } @@ -618,20 +547,15 @@ public class RoomLayout return this.getTile(x, y); } - public List getTilesInFront(RoomTile tile, int rotation, int amount) - { + public List getTilesInFront(RoomTile tile, int rotation, int amount) { List tiles = new ArrayList<>(amount); RoomTile previous = tile; - for (int i = 0; i < amount; i++) - { + for (int i = 0; i < amount; i++) { RoomTile t = this.getTileInFront(previous, rotation, i); - if (t != null) - { + if (t != null) { tiles.add(t); - } - else - { + } else { break; } } @@ -639,22 +563,17 @@ public class RoomLayout return tiles; } - public List getTilesAround(RoomTile tile) - { + public List getTilesAround(RoomTile tile) { return getTilesAround(tile, 0); } - public List getTilesAround(RoomTile tile, int directionOffset) - { + public List getTilesAround(RoomTile tile, int directionOffset) { List tiles = new ArrayList<>(8); - if (tile != null) - { - for (int i = 0; i < 8; i++) - { + if (tile != null) { + for (int i = 0; i < 8; i++) { RoomTile t = this.getTileInFront(tile, (i + directionOffset) % 8); - if (t != null) - { + if (t != null) { tiles.add(t); } } @@ -672,62 +591,39 @@ public class RoomLayout List toRemove = new ArrayList<>(); - for(RoomTile t : availableTiles) { - if(t == null || t.state != RoomTileState.OPEN || !t.isWalkable()) { + for (RoomTile t : availableTiles) { + if (t == null || t.state != RoomTileState.OPEN || !t.isWalkable()) { toRemove.add(t); } } - for(RoomTile t : toRemove) { + for (RoomTile t : toRemove) { availableTiles.remove(t); } return availableTiles; } - public static Rectangle getRectangle(int x, int y, int width, int length, int rotation) - { - rotation = (rotation % 8); - - if(rotation == 2 || rotation == 6) - { - return new Rectangle(x, y, length, width); - } - - return new Rectangle(x, y, width, length); - } - - public boolean fitsOnMap(RoomTile tile, int width, int length, int rotation) - { + public boolean fitsOnMap(RoomTile tile, int width, int length, int rotation) { THashSet pointList = new THashSet<>(width * length, 0.1f); - 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++) - { + 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++) { RoomTile t = this.getTile(i, j); - if (t == null || t.state == RoomTileState.INVALID) - { + if (t == null || t.state == 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++) - { + } 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++) { RoomTile t = this.getTile(i, j); - if (t == null || t.state == RoomTileState.INVALID) - { + if (t == null || t.state == RoomTileState.INVALID) { return false; } } @@ -738,37 +634,26 @@ public class RoomLayout return true; } - public THashSet getTilesAt(RoomTile tile, int width, int length, int rotation) - { + public THashSet getTilesAt(RoomTile tile, int width, int length, int rotation) { THashSet pointList = new THashSet<>(width * length, 0.1f); - 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++) - { + 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++) { RoomTile t = this.getTile(i, j); - if (t != null) - { + if (t != null) { pointList.add(t); } } } - } - 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++) - { + } 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++) { RoomTile t = this.getTile(i, j); - if (t != null) - { + if (t != null) { pointList.add(t); } } @@ -778,12 +663,4 @@ public class RoomLayout return pointList; } - - 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 = new Rectangle(rectangle.x - 1, rectangle.y -1, rectangle.width + 2, rectangle.height + 2); - - return rectangle.contains(tile.x, tile.y); - } } 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 65b7b381..de8e9241 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -55,21 +55,19 @@ import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -public class RoomManager -{ +public class RoomManager { + private static final int page = 0; //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ROOMS_USER = 25; public static int MAXIMUM_ROOMS_VIP = 35; public static int HOME_ROOM_ID = 0; public static boolean SHOW_PUBLIC_IN_POPULAR_TAB = false; - private final THashMap roomCategories; private final List mapNames; private final ConcurrentHashMap activeRooms; private final ArrayList> gameTypes; - public RoomManager() - { + public RoomManager() { long millis = System.currentTimeMillis(); this.roomCategories = new THashMap<>(); this.mapNames = new ArrayList<>(); @@ -90,124 +88,91 @@ public class RoomManager Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void loadRoomModels() - { + public void loadRoomModels() { this.mapNames.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM room_models")) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM room_models")) { + while (set.next()) { this.mapNames.add(set.getString("name")); } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public CustomRoomLayout loadCustomLayout(Room room) - { + public CustomRoomLayout loadCustomLayout(Room room) { CustomRoomLayout layout = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models_custom WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models_custom WHERE id = ? LIMIT 1")) { statement.setInt(1, room.getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { layout = new CustomRoomLayout(set, room); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return layout; } - private void loadRoomCategories() - { + private void loadRoomCategories() { this.roomCategories.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_flatcats")) - { - while(set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_flatcats")) { + while (set.next()) { this.roomCategories.put(set.getInt("id"), new RoomCategory(set)); } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void loadPublicRooms() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE is_public = ? OR is_staff_picked = ? ORDER BY id DESC")) - { + public void loadPublicRooms() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE is_public = ? OR is_staff_picked = ? ORDER BY id DESC")) { statement.setString(1, "1"); statement.setString(2, "1"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Room room = new Room(set); room.preventUncaching = true; this.activeRooms.put(set.getInt("id"), room); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private static final int page = 0; - public THashMap> findRooms(NavigatorFilterField filterField, String value, int category, boolean showInvisible) - { + public THashMap> findRooms(NavigatorFilterField filterField, String value, int category, boolean showInvisible) { THashMap> rooms = new THashMap<>(); - String query = filterField.databaseQuery + " AND rooms.state NOT LIKE " + (showInvisible ? "''" : "'invisible'") + (category >= 0 ? "AND rooms.category = '" + category + "'" : "") + " ORDER BY rooms.users, rooms.id DESC LIMIT " + (page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + "" + ((page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + NavigatorManager.MAXIMUM_RESULTS_PER_PAGE); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) - { + String query = filterField.databaseQuery + " AND rooms.state NOT LIKE " + (showInvisible ? "''" : "'invisible'") + (category >= 0 ? "AND rooms.category = '" + category + "'" : "") + " ORDER BY rooms.users, rooms.id DESC LIMIT " + (page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + "" + ((page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + NavigatorManager.MAXIMUM_RESULTS_PER_PAGE); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { statement.setString(1, (filterField.comparator == NavigatorFilterComparator.EQUALS ? value : "%" + value + "%")); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Room room = this.activeRooms.get(set.getInt("id")); - if (room == null) - { + if (room == null) { room = new Room(set); this.activeRooms.put(set.getInt("id"), room); } - if (!rooms.containsKey(set.getInt("category"))) - { + if (!rooms.containsKey(set.getInt("category"))) { rooms.put(set.getInt("category"), new ArrayList<>()); } rooms.get(set.getInt("category")).add(room); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public RoomCategory getCategory(int id) - { - for (RoomCategory category : this.roomCategories.values()) - { + public RoomCategory getCategory(int id) { + for (RoomCategory category : this.roomCategories.values()) { if (category.getId() == id) return category; } @@ -215,12 +180,9 @@ public class RoomManager return null; } - public RoomCategory getCategory(String name) - { - for (RoomCategory category : this.roomCategories.values()) - { - if (category.getCaption().equalsIgnoreCase(name)) - { + public RoomCategory getCategory(String name) { + for (RoomCategory category : this.roomCategories.values()) { + if (category.getCaption().equalsIgnoreCase(name)) { return category; } } @@ -228,12 +190,9 @@ public class RoomManager return null; } - public RoomCategory getCategoryBySafeCaption(String safeCaption) - { - for (RoomCategory category : this.roomCategories.values()) - { - if (category.getCaptionSave().equalsIgnoreCase(safeCaption)) - { + public RoomCategory getCategoryBySafeCaption(String safeCaption) { + for (RoomCategory category : this.roomCategories.values()) { + if (category.getCaptionSave().equalsIgnoreCase(safeCaption)) { return category; } } @@ -241,12 +200,10 @@ public class RoomManager return null; } - public List roomCategoriesForHabbo(Habbo habbo) - { + public List roomCategoriesForHabbo(Habbo habbo) { List categories = new ArrayList<>(); - for(RoomCategory category : this.roomCategories.values()) - { - if(category.getMinRank() <= habbo.getHabboInfo().getRank().getId()) + for (RoomCategory category : this.roomCategories.values()) { + if (category.getMinRank() <= habbo.getHabboInfo().getRank().getId()) categories.add(category); } @@ -255,14 +212,10 @@ public class RoomManager return categories; } - public boolean hasCategory(int categoryId, Habbo habbo) - { - for(RoomCategory category : this.roomCategories.values()) - { - if(category.getId() == categoryId) - { - if(category.getMinRank() <= habbo.getHabboInfo().getRank().getId()) - { + public boolean hasCategory(int categoryId, Habbo habbo) { + for (RoomCategory category : this.roomCategories.values()) { + if (category.getId() == categoryId) { + if (category.getMinRank() <= habbo.getHabboInfo().getRank().getId()) { return true; } } @@ -271,24 +224,20 @@ public class RoomManager return false; } - public THashMap getRoomCategories() - { + public THashMap getRoomCategories() { return this.roomCategories; } - public List getRoomsByScore() - { + public List getRoomsByScore() { List rooms = new ArrayList<>(this.activeRooms.values()); rooms.sort(Room.SORT_SCORE); return rooms; } - public List getActiveRooms(int categoryId) - { + public List getActiveRooms(int categoryId) { List rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { + for (Room room : this.activeRooms.values()) { if (categoryId == room.getCategory() || categoryId == -1) rooms.add(room); } @@ -297,64 +246,50 @@ public class RoomManager } //TODO Move to HabboInfo class. - public List getRoomsForHabbo(Habbo habbo) - { + public List getRoomsForHabbo(Habbo habbo) { List rooms = new ArrayList<>(); - for(Room room : this.activeRooms.values()) - { - if(room.getOwnerId() == habbo.getHabboInfo().getId()) + for (Room room : this.activeRooms.values()) { + if (room.getOwnerId() == habbo.getHabboInfo().getId()) rooms.add(room); } rooms.sort(Room.SORT_ID); return rooms; } - public List getRoomsForHabbo(String username) - { + public List getRoomsForHabbo(String username) { Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if(h != null) - { + if (h != null) { return this.getRoomsForHabbo(h); } List rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE owner_name = ? ORDER BY id DESC LIMIT 25")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE owner_name = ? ORDER BY id DESC LIMIT 25")) { statement.setString(1, username); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { rooms.add(this.loadRoom(set.getInt("id"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public Room loadRoom(int id) - { + public Room loadRoom(int id) { return loadRoom(id, false); } - public Room loadRoom(int id, boolean loadData) - { + public Room loadRoom(int id, boolean loadData) { Room room = null; - if(this.activeRooms.containsKey(id)) - { + if (this.activeRooms.containsKey(id)) { room = this.activeRooms.get(id); - if (loadData) - { - if (room.isPreLoaded() && !room.isLoaded()) - { + if (loadData) { + if (room.isPreLoaded() && !room.isLoaded()) { room.loadData(); } } @@ -362,29 +297,22 @@ public class RoomManager return room; } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE id = ? LIMIT 1")) { statement.setInt(1, id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { room = new Room(set); - if (loadData) - { + if (loadData) { room.loadData(); } } } - if(room != null) - { + if (room != null) { this.activeRooms.put(room.getId(), room); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -392,12 +320,10 @@ public class RoomManager } - public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId) - { + public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId) { Room room = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category) VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category) VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, ownerId); statement.setString(2, ownerName); statement.setString(3, name); @@ -406,14 +332,11 @@ public class RoomManager statement.setInt(6, usersMax); statement.setInt(7, categoryId); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { + try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) room = this.loadRoom(set.getInt(1)); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -421,8 +344,7 @@ public class RoomManager } - public Room createRoomForHabbo(Habbo habbo, String name, String description, String modelName, int usersMax, int categoryId) - { + public Room createRoomForHabbo(Habbo habbo, String name, String description, String modelName, int usersMax, int categoryId) { Room room = this.createRoom(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), name, description, modelName, usersMax, categoryId); Emulator.getPluginManager().fireEvent(new NavigatorRoomCreatedEvent(habbo, room)); @@ -430,39 +352,29 @@ public class RoomManager return room; } - public void loadRoomsForHabbo(Habbo habbo) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE owner_id = ?")) - { + public void loadRoomsForHabbo(Habbo habbo) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms WHERE owner_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { if (!this.activeRooms.containsKey(set.getInt("id"))) this.activeRooms.put(set.getInt("id"), new Room(set)); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void unloadRoomsForHabbo(Habbo habbo) - { + public void unloadRoomsForHabbo(Habbo habbo) { List roomsToDispose = new ArrayList<>(); - for(Room room : this.activeRooms.values()) - { - if(!room.isPublicRoom() && !room.isStaffPromotedRoom() && room.getOwnerId() == habbo.getHabboInfo().getId() && room.getUserCount() == 0 && !this.roomCategories.get(room.getCategory()).isPublic()) - { + for (Room room : this.activeRooms.values()) { + if (!room.isPublicRoom() && !room.isStaffPromotedRoom() && room.getOwnerId() == habbo.getHabboInfo().getId() && room.getUserCount() == 0 && !this.roomCategories.get(room.getCategory()).isPublic()) { roomsToDispose.add(room); } } - for(Room room : roomsToDispose) - { + for (Room room : roomsToDispose) { if (Emulator.getPluginManager().fireEvent(new RoomUncachedEvent(room)).isCancelled()) continue; @@ -471,198 +383,158 @@ public class RoomManager } } - public void clearInactiveRooms() - { + public void clearInactiveRooms() { THashSet roomsToDispose = new THashSet<>(); - for(Room room : this.activeRooms.values()) - { - if(!room.isPublicRoom() && !room.isStaffPromotedRoom() && !Emulator.getGameServer().getGameClientManager().containsHabbo(room.getOwnerId()) && room.isPreLoaded() && !this.roomCategories.get(room.getCategory()).isPublic()) - { + for (Room room : this.activeRooms.values()) { + if (!room.isPublicRoom() && !room.isStaffPromotedRoom() && !Emulator.getGameServer().getGameClientManager().containsHabbo(room.getOwnerId()) && room.isPreLoaded() && !this.roomCategories.get(room.getCategory()).isPublic()) { roomsToDispose.add(room); } } - for(Room room : roomsToDispose) - { + for (Room room : roomsToDispose) { room.dispose(); - if(room.getUserCount() == 0) + if (room.getUserCount() == 0) this.activeRooms.remove(room.getId()); } } - public boolean layoutExists(String name) - { + public boolean layoutExists(String name) { return this.mapNames.contains(name); } - public RoomLayout loadLayout(String name, Room room) - { + public RoomLayout loadLayout(String name, Room room) { RoomLayout layout = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name LIKE ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name LIKE ? LIMIT 1")) { statement.setString(1, name); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { layout = new RoomLayout(set, room); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return layout; } - public void unloadRoom(Room room) - { + public void unloadRoom(Room room) { room.dispose(); } - public void uncacheRoom(Room room) - { + public void uncacheRoom(Room room) { this.activeRooms.remove(room.getId()); } - public void voteForRoom(Habbo habbo, Room room) - { - if(habbo.getHabboInfo().getCurrentRoom() != null && room != null && habbo.getHabboInfo().getCurrentRoom() == room) - { - if(this.hasVotedForRoom(habbo, room)) + public void voteForRoom(Habbo habbo, Room room) { + if (habbo.getHabboInfo().getCurrentRoom() != null && room != null && habbo.getHabboInfo().getCurrentRoom() == room) { + if (this.hasVotedForRoom(habbo, room)) return; room.setScore(room.getScore() + 1); room.setNeedsUpdate(true); habbo.getHabboStats().votedRooms.push(room.getId()); - for(Habbo h : room.getHabbos()) - { + for (Habbo h : room.getHabbos()) { h.getClient().sendResponse(new RoomScoreComposer(room.getScore(), !this.hasVotedForRoom(h, room))); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_votes VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_votes VALUES (?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, room.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - boolean hasVotedForRoom(Habbo habbo, Room room) - { - if(room.getOwnerId() == habbo.getHabboInfo().getId()) + boolean hasVotedForRoom(Habbo habbo, Room room) { + if (room.getOwnerId() == habbo.getHabboInfo().getId()) return true; - for(int i : habbo.getHabboStats().votedRooms.toArray()) - { - if(i == room.getId()) + for (int i : habbo.getHabboStats().votedRooms.toArray()) { + if (i == room.getId()) return true; } return false; } - public Room getRoom(int roomId) - { + public Room getRoom(int roomId) { return this.activeRooms.get(roomId); } - public ArrayList getActiveRooms() - { + public ArrayList getActiveRooms() { return new ArrayList<>(this.activeRooms.values()); } - public int loadedRoomsCount() - { + public int loadedRoomsCount() { return this.activeRooms.size(); } - public void enterRoom(Habbo habbo, int roomId, String password) - { + public void enterRoom(Habbo habbo, int roomId, String password) { this.enterRoom(habbo, roomId, password, false, null); } - public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks) - { + public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks) { this.enterRoom(habbo, roomId, password, overrideChecks, null); } - public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks, RoomTile doorLocation) - { + public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks, RoomTile doorLocation) { Room room = this.loadRoom(roomId, true); - if(room == null) + if (room == null) return; - if (habbo.getHabboInfo().getLoadingRoom() != 0 && room.getId() != habbo.getHabboInfo().getLoadingRoom()) - { + if (habbo.getHabboInfo().getLoadingRoom() != 0 && room.getId() != habbo.getHabboInfo().getLoadingRoom()) { habbo.getClient().sendResponse(new HotelViewComposer()); habbo.getHabboInfo().setLoadingRoom(0); return; } - if(Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled()) - { - if(habbo.getHabboInfo().getCurrentRoom() == null) - { + if (Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled()) { + if (habbo.getHabboInfo().getCurrentRoom() == null) { habbo.getClient().sendResponse(new HotelViewComposer()); habbo.getHabboInfo().setLoadingRoom(0); return; } } - if (room.isBanned(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermission("acc_enteranyroom")) - { + if (room.isBanned(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermission("acc_enteranyroom")) { habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_BANNED)); return; } - if (habbo.getHabboInfo().getRoomQueueId() != roomId) - { + if (habbo.getHabboInfo().getRoomQueueId() != roomId) { Room queRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if (queRoom != null) - { + if (queRoom != null) { queRoom.removeFromQueue(habbo); } } - if(overrideChecks || - room.isOwner(habbo) || - room.getState() == RoomState.OPEN || - room.getState() == RoomState.INVISIBLE || - habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || - habbo.hasPermission("acc_enteranyroom") || - room.hasRights(habbo) || - (room.hasGuild() && room.guildRightLevel(habbo) > 2)) - { + if (overrideChecks || + room.isOwner(habbo) || + room.getState() == RoomState.OPEN || + room.getState() == RoomState.INVISIBLE || + habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || + habbo.hasPermission("acc_enteranyroom") || + room.hasRights(habbo) || + (room.hasGuild() && room.guildRightLevel(habbo) > 2)) { this.openRoom(habbo, room, doorLocation); - } - else if(room.getState() == RoomState.LOCKED) - { + } else if (room.getState() == RoomState.LOCKED) { boolean rightsFound = false; - synchronized (room.roomUnitLock) - { - for (Habbo current : room.getHabbos()) - { - if (room.hasRights(current) || current.getHabboInfo().getId() == room.getOwnerId() || (room.hasGuild() && room.guildRightLevel(current) >= 2)) - { + synchronized (room.roomUnitLock) { + for (Habbo current : room.getHabbos()) { + if (room.hasRights(current) || current.getHabboInfo().getId() == room.getOwnerId() || (room.hasGuild() && room.guildRightLevel(current) >= 2)) { current.getClient().sendResponse(new DoorbellAddUserComposer(habbo.getHabboInfo().getUsername())); rightsFound = true; } } } - if(!rightsFound) - { + if (!rightsFound) { habbo.getClient().sendResponse(new RoomAccessDeniedComposer("")); habbo.getClient().sendResponse(new HotelViewComposer()); habbo.getHabboInfo().setLoadingRoom(0); @@ -672,13 +544,10 @@ public class RoomManager habbo.getHabboInfo().setRoomQueueId(roomId); habbo.getClient().sendResponse(new DoorbellAddUserComposer("")); room.addToQueue(habbo); - } - else if(room.getState() == RoomState.PASSWORD) - { - if(room.getPassword().equalsIgnoreCase(password)) + } else if (room.getState() == RoomState.PASSWORD) { + if (room.getPassword().equalsIgnoreCase(password)) this.openRoom(habbo, room, doorLocation); - else - { + else { habbo.getClient().sendResponse(new GenericErrorMessagesComposer(-100002)); habbo.getClient().sendResponse(new HotelViewComposer()); habbo.getHabboInfo().setLoadingRoom(0); @@ -686,22 +555,18 @@ public class RoomManager } } - void openRoom(Habbo habbo, Room room, RoomTile doorLocation) - { + void openRoom(Habbo habbo, Room room, RoomTile doorLocation) { if (room == null || room.getLayout() == null) return; - if (Emulator.getConfig().getBoolean("hotel.room.enter.logs")) - { + if (Emulator.getConfig().getBoolean("hotel.room.enter.logs")) { this.logEnter(habbo, room); } - if (habbo.getHabboInfo().getRoomQueueId() > 0) - { + if (habbo.getHabboInfo().getRoomQueueId() > 0) { Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(habbo.getHabboInfo().getRoomQueueId()); - if (r != null) - { + if (r != null) { r.removeFromQueue(habbo); } } @@ -709,41 +574,37 @@ public class RoomManager habbo.getHabboInfo().setRoomQueueId(0); habbo.getClient().sendResponse(new HideDoorbellComposer("")); - if(habbo.getRoomUnit() != null) { + if (habbo.getRoomUnit() != null) { habbo.getRoomUnit().setRoom(null); } habbo.setRoomUnit(new RoomUnit()); habbo.getRoomUnit().clearStatus(); - if (habbo.getRoomUnit().getCurrentLocation() == null) - { + if (habbo.getRoomUnit().getCurrentLocation() == null) { habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile()); habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); - if(doorLocation == null) { + if (doorLocation == null) { habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); - } - else { + } else { habbo.getRoomUnit().setCanLeaveRoomByDoor(false); habbo.getRoomUnit().isTeleporting = true; HabboItem topItem = room.getTopItemAt(doorLocation.x, doorLocation.y); - if(topItem != null) { + if (topItem != null) { habbo.getRoomUnit().setRotation(RoomUserRotation.values()[topItem.getRotation()]); } } } habbo.getRoomUnit().setRoomUnitType(RoomUnitType.USER); - if(room.isBanned(habbo)) - { + if (room.isBanned(habbo)) { habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_BANNED)); return; } - if (room.getUserCount() >= room.getUsersMax() && !habbo.hasPermission("acc_fullrooms") && !room.hasRights(habbo)) - { + if (room.getUserCount() >= room.getUsersMax() && !habbo.hasPermission("acc_fullrooms") && !room.hasRights(habbo)) { habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_GUESTROOM_FULL)); return; } @@ -754,20 +615,15 @@ public class RoomManager habbo.getClient().sendResponse(new RoomOpenComposer()); habbo.getRoomUnit().setInRoom(true); - if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null) - { + if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo); - } - else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null) - { + } else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null) { habbo.getMessenger().connectionChanged(habbo, true, true); } - if (habbo.getHabboInfo().getLoadingRoom() != 0) - { + if (habbo.getHabboInfo().getLoadingRoom() != 0) { Room oldRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(habbo.getHabboInfo().getLoadingRoom()); - if (oldRoom != null) - { + if (oldRoom != null) { oldRoom.removeFromQueue(habbo); } } @@ -790,27 +646,20 @@ public class RoomManager habbo.getRoomUnit().setFastWalk(habbo.getRoomUnit().isFastWalk() && habbo.hasPermission("cmd_fastwalk", room.hasRights(habbo))); - if (room.isPromoted()) - { + if (room.isPromoted()) { habbo.getClient().sendResponse(new RoomPromotionMessageComposer(room, room.getPromotion())); - } - else - { + } else { habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null)); } - if(room.getOwnerId() != habbo.getHabboInfo().getId()) - { + if (room.getOwnerId() != habbo.getHabboInfo().getId()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); } } - public void enterRoom(final Habbo habbo, final Room room) - { - if (habbo.getHabboInfo().getLoadingRoom() != room.getId()) - { - if (habbo.getHabboInfo().getLoadingRoom() != 0) - { + public void enterRoom(final Habbo habbo, final Room room) { + if (habbo.getHabboInfo().getLoadingRoom() != room.getId()) { + if (habbo.getHabboInfo().getLoadingRoom() != 0) { habbo.getClient().sendResponse(new HotelViewComposer()); } return; @@ -824,18 +673,15 @@ public class RoomManager habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); room.refreshRightsForHabbo(habbo); - if (habbo.getRoomUnit().isKicked && !habbo.getRoomUnit().canWalk()) - { + if (habbo.getRoomUnit().isKicked && !habbo.getRoomUnit().canWalk()) { habbo.getRoomUnit().setCanWalk(true); } habbo.getRoomUnit().isKicked = false; - if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting) - { + if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting) { RoomTile doorTile = room.getLayout().getTile(room.getLayout().getDoorX(), room.getLayout().getDoorY()); - if (doorTile != null) - { + if (doorTile != null) { habbo.getRoomUnit().setLocation(doorTile); habbo.getRoomUnit().setZ(doorTile.getStackHeight()); } @@ -851,41 +697,34 @@ public class RoomManager room.addHabbo(habbo); List habbos = new ArrayList<>(); - if (!room.getCurrentHabbos().isEmpty()) - { + if (!room.getCurrentHabbos().isEmpty()) { room.sendComposer(new RoomUsersComposer(habbo).compose()); room.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); - for (Habbo h : room.getHabbos()) - { - if (!h.getRoomUnit().isInvisible()) - { + for (Habbo h : room.getHabbos()) { + if (!h.getRoomUnit().isInvisible()) { habbos.add(h); } } - synchronized (room.roomUnitLock) - { + synchronized (room.roomUnitLock) { habbo.getClient().sendResponse(new RoomUsersComposer(habbos)); habbo.getClient().sendResponse(new RoomUserStatusComposer(habbos)); } - if (habbo.getHabboStats().guild != 0) - { + if (habbo.getHabboStats().guild != 0) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().guild); - if (guild != null) - { + if (guild != null) { room.sendComposer(new RoomUsersAddGuildBadgeComposer(guild).compose()); } } int effect = habbo.getInventory().getEffectsComponent().activatedEffect; - if (effect == 0) - { + if (effect == 0) { effect = habbo.getHabboInfo().getRank().getRoomEffect(); } @@ -894,22 +733,16 @@ public class RoomManager habbo.getClient().sendResponse(new RoomUsersComposer(room.getCurrentBots().valueCollection(), true)); - if (!room.getCurrentBots().isEmpty()) - { + if (!room.getCurrentBots().isEmpty()) { TIntObjectIterator botIterator = room.getCurrentBots().iterator(); - for (int i = room.getCurrentBots().size(); i-- > 0; ) - { - try - { + for (int i = room.getCurrentBots().size(); i-- > 0; ) { + try { botIterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } Bot bot = botIterator.value(); - if (!bot.getRoomUnit().getDanceType().equals(DanceType.NONE)) - { + if (!bot.getRoomUnit().getDanceType().equals(DanceType.NONE)) { habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit())); } @@ -927,17 +760,14 @@ public class RoomManager { final THashSet floorItems = new THashSet<>(); - room.getFloorItems().forEach(new TObjectProcedure() - { + room.getFloorItems().forEach(new TObjectProcedure() { @Override - public boolean execute(HabboItem object) - { + public boolean execute(HabboItem object) { if (room.isHideWired() && object instanceof InteractionWired) return true; floorItems.add(object); - if (floorItems.size() == 250) - { + if (floorItems.size() == 250) { habbo.getClient().sendResponse(new RoomFloorItemsComposer(room.getFurniOwnerNames(), floorItems)); floorItems.clear(); } @@ -950,85 +780,65 @@ public class RoomManager floorItems.clear(); } - if (!room.getCurrentPets().isEmpty()) - { + if (!room.getCurrentPets().isEmpty()) { habbo.getClient().sendResponse(new RoomPetComposer(room.getCurrentPets())); - for (Pet pet : room.getCurrentPets().valueCollection()) - { + for (Pet pet : room.getCurrentPets().valueCollection()) { habbo.getClient().sendResponse(new RoomUserStatusComposer(pet.getRoomUnit())); } } - if (!habbo.getHabboStats().allowTalk()) - { + if (!habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().mutedBubbleTracker = true; int remainingMuteTime = habbo.getHabboStats().remainingMuteTime(); habbo.getClient().sendResponse(new FloodCounterComposer(remainingMuteTime)); habbo.getClient().sendResponse(new MutedWhisperComposer(remainingMuteTime)); room.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); - } - else if (habbo.getHabboStats().mutedBubbleTracker) - { + } else if (habbo.getHabboStats().mutedBubbleTracker) { habbo.getHabboStats().mutedBubbleTracker = false; } THashMap guildBadges = new THashMap<>(); - for (Habbo roomHabbo : habbos) - { + for (Habbo roomHabbo : habbos) { { - if (roomHabbo.getRoomUnit().getDanceType().getType() > 0) - { + if (roomHabbo.getRoomUnit().getDanceType().getType() > 0) { habbo.getClient().sendResponse(new RoomUserDanceComposer(roomHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().getHandItem() > 0) - { + if (roomHabbo.getRoomUnit().getHandItem() > 0) { habbo.getClient().sendResponse(new RoomUserHandItemComposer(roomHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().getEffectId() > 0) - { + if (roomHabbo.getRoomUnit().getEffectId() > 0) { habbo.getClient().sendResponse(new RoomUserEffectComposer(roomHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().isIdle()) - { + if (roomHabbo.getRoomUnit().isIdle()) { habbo.getClient().sendResponse(new RoomUnitIdleComposer(roomHabbo.getRoomUnit())); } - if (roomHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) - { + if (roomHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { roomHabbo.getClient().sendResponse(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.IGNORED)); } - if (!roomHabbo.getHabboStats().allowTalk()) - { + if (!roomHabbo.getHabboStats().allowTalk()) { habbo.getClient().sendResponse(new RoomUserIgnoredComposer(roomHabbo, RoomUserIgnoredComposer.MUTED)); - } - else if (habbo.getHabboStats().userIgnored(roomHabbo.getHabboInfo().getId())) - { + } else if (habbo.getHabboStats().userIgnored(roomHabbo.getHabboInfo().getId())) { habbo.getClient().sendResponse(new RoomUserIgnoredComposer(roomHabbo, RoomUserIgnoredComposer.IGNORED)); } - if (roomHabbo.getHabboStats().guild != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().guild)) - { + if (roomHabbo.getHabboStats().guild != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().guild)) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().guild); - if (guild != null) - { + if (guild != null) { guildBadges.put(roomHabbo.getHabboStats().guild, guild.getBadge()); } } - if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) - { - try - { + if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) { + try { habbo.getClient().sendResponse(new RoomUserRemoveComposer(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().cache.get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().cache.get("pet_race"), (String) roomHabbo.getHabboStats().cache.get("pet_color"), roomHabbo)); + } catch (Exception e) { } } @@ -1037,36 +847,28 @@ public class RoomManager habbo.getClient().sendResponse(new RoomUsersGuildBadgesComposer(guildBadges)); - if (room.hasRights(habbo) || (room.hasGuild() && room.guildRightLevel(habbo) >= 2)) - { - if (!room.getHabboQueue().isEmpty()) - { - for (Habbo waiting : room.getHabboQueue().valueCollection()) - { + if (room.hasRights(habbo) || (room.hasGuild() && room.guildRightLevel(habbo) >= 2)) { + if (!room.getHabboQueue().isEmpty()) { + for (Habbo waiting : room.getHabboQueue().valueCollection()) { habbo.getClient().sendResponse(new DoorbellAddUserComposer(waiting.getHabboInfo().getUsername())); } } } - if (room.getPollId() > 0) - { - if (!PollManager.donePoll(habbo.getClient().getHabbo(), room.getPollId())) - { + if (room.getPollId() > 0) { + if (!PollManager.donePoll(habbo.getClient().getHabbo(), room.getPollId())) { Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(room.getPollId()); - if (poll != null) - { + if (poll != null) { habbo.getClient().sendResponse(new PollStartComposer(poll)); } } } - if (room.hasActiveWordQuiz()) - { + if (room.hasActiveWordQuiz()) { habbo.getClient().sendResponse(new SimplePollStartComposer((Emulator.getIntUnixTimestamp() - room.wordQuizEnd) * 1000, room.wordQuiz)); - if (room.hasVotedInWordQuiz(habbo)) - { + if (room.hasVotedInWordQuiz(habbo)) { habbo.getClient().sendResponse(new SimplePollAnswersComposer(room.noVotes, room.yesVotes)); } } @@ -1074,72 +876,59 @@ 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().nux && (room.isOwner(habbo) || room.isPublicRoom())) { UserNuxEvent.handle(habbo); } - if(Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { + if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room)); } } - void logEnter(Habbo habbo, Room room) - { + void logEnter(Habbo habbo, Room room) { habbo.getHabboStats().roomEnterTimestamp = Emulator.getIntUnixTimestamp(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_enter_log (room_id, user_id, timestamp) VALUES(?, ?, ?)")) - { + 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().roomEnterTimestamp)); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void leaveRoom(Habbo habbo, Room room) - { + public void leaveRoom(Habbo habbo, Room room) { this.leaveRoom(habbo, room, true); } - public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) - { - if(habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) - { + public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) { + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) { habbo.getRoomUnit().setPathFinderRoom(null); this.logExit(habbo); room.removeHabbo(habbo, true); - if (redirectToHotelView) - { + if (redirectToHotelView) { habbo.getClient().sendResponse(new HotelViewComposer()); } habbo.getHabboInfo().setCurrentRoom(null); habbo.getRoomUnit().isKicked = false; - if (room.getOwnerId() != habbo.getHabboInfo().getId()) - { - AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int)Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000)); + if (room.getOwnerId() != habbo.getHabboInfo().getId()) { + AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000)); } } } - public void logExit(Habbo habbo) - { + + public void logExit(Habbo habbo) { Emulator.getPluginManager().fireEvent(new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.DOOR)); - if(habbo.getRoomUnit().getCacheable().containsKey("control")) - { - Habbo control = (Habbo)habbo.getRoomUnit().getCacheable().remove("control"); + if (habbo.getRoomUnit().getCacheable().containsKey("control")) { + Habbo control = (Habbo) habbo.getRoomUnit().getCacheable().remove("control"); control.getRoomUnit().getCacheable().remove("controller"); } - if (habbo.getHabboInfo().getRiding() != null) - { - if (habbo.getHabboInfo().getRiding().getRoomUnit() != null) - { + if (habbo.getHabboInfo().getRiding() != null) { + if (habbo.getHabboInfo().getRiding().getRoomUnit() != null) { habbo.getHabboInfo().getRiding().getRoomUnit().setGoalLocation(habbo.getHabboInfo().getRiding().getRoomUnit().getCurrentLocation()); } habbo.getHabboInfo().getRiding().setTask(PetTasks.FREE); @@ -1148,32 +937,25 @@ public class RoomManager } Room room = habbo.getHabboInfo().getCurrentRoom(); - if(room != null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_enter_log SET exit_timestamp = ? WHERE user_id = ? AND room_id = ? ORDER BY timestamp DESC LIMIT 1")) - { + if (room != null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_enter_log SET exit_timestamp = ? WHERE user_id = ? AND room_id = ? ORDER BY timestamp DESC LIMIT 1")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, room.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public Set getTags() - { + public Set getTags() { Map tagCount = new HashMap<>(); - for(Room room : this.activeRooms.values()) - { - for(String s : room.getTags().split(";")) - { + for (Room room : this.activeRooms.values()) { + for (String s : room.getTags().split(";")) { int i = 0; - if(tagCount.get(s) != null) + if (tagCount.get(s) != null) i++; tagCount.put(s, i++); @@ -1182,14 +964,11 @@ public class RoomManager return new TreeMap<>(tagCount).keySet(); } - public ArrayList getPublicRooms() - { + public ArrayList getPublicRooms() { ArrayList rooms = new ArrayList<>(); - for(Room room : this.activeRooms.values()) - { - if(room.isPublicRoom()) - { + for (Room room : this.activeRooms.values()) { + if (room.isPublicRoom()) { rooms.add(room); } } @@ -1197,22 +976,18 @@ public class RoomManager return rooms; } - public ArrayList getPopularRooms(int count) - { + public ArrayList getPopularRooms(int count) { ArrayList rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { - if (room.getUserCount() > 0) - { + for (Room room : this.activeRooms.values()) { + if (room.getUserCount() > 0) { if (!RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB && room.isPublicRoom()) continue; rooms.add(room); } } - if (rooms.isEmpty()) - { + if (rooms.isEmpty()) { return rooms; } @@ -1221,20 +996,16 @@ public class RoomManager return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count))); } - public ArrayList getPopularRooms(int count, int category) - { + public ArrayList getPopularRooms(int count, int category) { ArrayList rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { - if (!room.isPublicRoom() && room.getCategory() == category) - { + for (Room room : this.activeRooms.values()) { + if (!room.isPublicRoom() && room.getCategory() == category) { rooms.add(room); } } - if (rooms.isEmpty()) - { + if (rooms.isEmpty()) { return rooms; } @@ -1243,16 +1014,12 @@ public class RoomManager return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count))); } - public Map> getPopularRoomsByCategory(int count) - { + public Map> getPopularRoomsByCategory(int count) { Map> rooms = new HashMap<>(); - for (Room room : this.activeRooms.values()) - { - if (!room.isPublicRoom()) - { - if (!rooms.containsKey(room.getCategory())) - { + for (Room room : this.activeRooms.values()) { + if (!room.isPublicRoom()) { + if (!rooms.containsKey(room.getCategory())) { rooms.put(room.getCategory(), new ArrayList<>()); } @@ -1262,8 +1029,7 @@ public class RoomManager Map> result = new HashMap<>(); - for (Map.Entry> set : rooms.entrySet()) - { + for (Map.Entry> set : rooms.entrySet()) { if (set.getValue().isEmpty()) continue; @@ -1275,20 +1041,16 @@ public class RoomManager return result; } - public ArrayList getRoomsWithName(String name) - { + public ArrayList getRoomsWithName(String name) { ArrayList rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { - if (room.getName().toLowerCase().contains(name.toLowerCase())) - { + for (Room room : this.activeRooms.values()) { + if (room.getName().toLowerCase().contains(name.toLowerCase())) { rooms.add(room); } } - if(rooms.size() < 25) - { + if (rooms.size() < 25) { rooms.addAll(this.getOfflineRoomsWithName(name)); } @@ -1297,17 +1059,13 @@ public class RoomManager return rooms; } - private ArrayList getOfflineRoomsWithName(String name) - { + private ArrayList getOfflineRoomsWithName(String name) { ArrayList rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, rooms.* FROM rooms INNER JOIN users ON owner_id = users.id WHERE name LIKE ? ORDER BY id DESC LIMIT 25")) - { - statement.setString(1, "%"+name+"%"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, rooms.* FROM rooms INNER JOIN users ON owner_id = users.id WHERE name LIKE ? ORDER BY id DESC LIMIT 25")) { + statement.setString(1, "%" + name + "%"); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { if (this.activeRooms.containsKey(set.getInt("id"))) continue; @@ -1316,25 +1074,19 @@ public class RoomManager this.activeRooms.put(r.getId(), r); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public ArrayList getRoomsWithTag(String tag) - { + public ArrayList getRoomsWithTag(String tag) { ArrayList rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { - for (String s : room.getTags().split(";")) - { - if (s.toLowerCase().equals(tag.toLowerCase())) - { + for (Room room : this.activeRooms.values()) { + for (String s : room.getTags().split(";")) { + if (s.toLowerCase().equals(tag.toLowerCase())) { rooms.add(room); break; } @@ -1346,12 +1098,10 @@ public class RoomManager return rooms; } - public ArrayList getGroupRoomsWithName(String name) - { + public ArrayList getGroupRoomsWithName(String name) { ArrayList rooms = new ArrayList<>(); - for (Room room : this.activeRooms.values()) - { + for (Room room : this.activeRooms.values()) { if (room.getGuildId() == 0) continue; @@ -1359,8 +1109,7 @@ public class RoomManager rooms.add(room); } - if(rooms.size() < 25) - { + if (rooms.size() < 25) { rooms.addAll(this.getOfflineGroupRoomsWithName(name)); } @@ -1369,17 +1118,13 @@ public class RoomManager return rooms; } - private ArrayList getOfflineGroupRoomsWithName(String name) - { + private ArrayList getOfflineGroupRoomsWithName(String name) { ArrayList rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, rooms.* FROM rooms INNER JOIN users ON rooms.owner_id = users.id WHERE name LIKE ? AND guild_id != 0 ORDER BY id DESC LIMIT 25")) - { - statement.setString(1, "%"+name+"%"); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, rooms.* FROM rooms INNER JOIN users ON rooms.owner_id = users.id WHERE name LIKE ? AND guild_id != 0 ORDER BY id DESC LIMIT 25")) { + statement.setString(1, "%" + name + "%"); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { if (this.activeRooms.containsKey(set.getInt("id"))) continue; @@ -1389,27 +1134,23 @@ public class RoomManager this.activeRooms.put(r.getId(), r); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public ArrayList getRoomsFriendsNow(Habbo habbo) - { + public ArrayList getRoomsFriendsNow(Habbo habbo) { ArrayList rooms = new ArrayList<>(); - for(MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) - { - if(buddy.getOnline() == 0) + for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) { + if (buddy.getOnline() == 0) continue; Habbo friend = Emulator.getGameEnvironment().getHabboManager().getHabbo(buddy.getId()); - if(friend == null || friend.getHabboInfo().getCurrentRoom() == null) + if (friend == null || friend.getHabboInfo().getCurrentRoom() == null) continue; rooms.add(friend.getHabboInfo().getCurrentRoom()); @@ -1420,18 +1161,16 @@ public class RoomManager return rooms; } - public ArrayList getRoomsFriendsOwn(Habbo habbo) - { + public ArrayList getRoomsFriendsOwn(Habbo habbo) { ArrayList rooms = new ArrayList<>(); - for(MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) - { - if(buddy.getOnline() == 0) + for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) { + if (buddy.getOnline() == 0) continue; Habbo friend = Emulator.getGameEnvironment().getHabboManager().getHabbo(buddy.getId()); - if(friend == null) + if (friend == null) continue; rooms.addAll(this.getRoomsForHabbo(friend)); @@ -1442,23 +1181,18 @@ public class RoomManager return rooms; } - public ArrayList getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) - { + public ArrayList getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) { ArrayList rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id WHERE user_id = ? AND timestamp >= ? AND rooms.owner_id != ? GROUP BY rooms.id ORDER BY timestamp DESC LIMIT " + limit)) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id WHERE user_id = ? AND timestamp >= ? AND rooms.owner_id != ? GROUP BY rooms.id ORDER BY timestamp DESC LIMIT " + limit)) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getIntUnixTimestamp() - 259200); statement.setInt(3, (includeSelf ? 0 : habbo.getHabboInfo().getId())); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Room room = this.activeRooms.get(set.getInt("id")); - if (room == null) - { + if (room == null) { room = new Room(set); this.activeRooms.put(room.getId(), room); @@ -1467,9 +1201,7 @@ public class RoomManager rooms.add(room); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -1478,21 +1210,16 @@ public class RoomManager return rooms; } - public ArrayList getRoomsFavourite(Habbo habbo) - { + public ArrayList getRoomsFavourite(Habbo habbo) { final ArrayList rooms = new ArrayList<>(); - habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() - { + habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() { @Override - public boolean execute(int value) - { + public boolean execute(int value) { Room room = RoomManager.this.getRoom(value); - if (room != null) - { - if (room.getState() == RoomState.INVISIBLE) - { + if (room != null) { + if (room.getState() == RoomState.INVISIBLE) { room.loadData(); if (!room.hasRights(habbo)) return true; } @@ -1505,18 +1232,14 @@ public class RoomManager return rooms; } - public List getGroupRooms(Habbo habbo, int limit) - { + public List getGroupRooms(Habbo habbo, int limit) { final ArrayList rooms = new ArrayList<>(); - for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getGuilds(habbo.getHabboInfo().getId())) - { - if (guild.getOwnerId() != habbo.getHabboInfo().getId()) - { + for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getGuilds(habbo.getHabboInfo().getId())) { + if (guild.getOwnerId() != habbo.getHabboInfo().getId()) { Room room = this.getRoom(guild.getRoomId()); - if (room != null) - { + if (room != null) { rooms.add(room); } } @@ -1527,80 +1250,58 @@ public class RoomManager return rooms.subList(0, (rooms.size() > limit ? limit : rooms.size())); } - public ArrayList getRoomsWithRights(Habbo habbo) - { + public ArrayList getRoomsWithRights(Habbo habbo) { ArrayList rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM rooms INNER JOIN room_rights ON room_rights.room_id = rooms.id WHERE room_rights.user_id = ? ORDER BY rooms.id DESC LIMIT 30")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM rooms INNER JOIN room_rights ON room_rights.room_id = rooms.id WHERE room_rights.user_id = ? ORDER BY rooms.id DESC LIMIT 30")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - if (this.activeRooms.containsKey(set.getInt("id"))) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.activeRooms.containsKey(set.getInt("id"))) { rooms.add(this.activeRooms.get(set.getInt("id"))); - } - else - { + } else { rooms.add(new Room(set)); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public ArrayList getRoomsWithAdminRights(Habbo habbo) - { + public ArrayList getRoomsWithAdminRights(Habbo habbo) { ArrayList rooms = new ArrayList<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms INNER JOIN guilds_members ON guilds_members.guild_id = rooms.guild_id WHERE guilds_members.user_id = ? AND level_id = 0")) - { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms INNER JOIN guilds_members ON guilds_members.guild_id = rooms.guild_id WHERE guilds_members.user_id = ? AND level_id = 0")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - if (this.activeRooms.containsKey(set.getInt("id"))) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.activeRooms.containsKey(set.getInt("id"))) { rooms.add(this.activeRooms.get(set.getInt("id"))); - } - else - { + } else { rooms.add(new Room(set)); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return rooms; } - public ArrayList getRoomsInGroup(Habbo habbo) - { + public ArrayList getRoomsInGroup(Habbo habbo) { return new ArrayList<>(); } - public ArrayList getRoomsPromoted() - { + public ArrayList getRoomsPromoted() { ArrayList r = new ArrayList<>(); - for(Room room : this.getActiveRooms()) - { - if(room.isPromoted()) - { + for (Room room : this.getActiveRooms()) { + if (room.isPromoted()) { r.add(room); } } @@ -1611,10 +1312,8 @@ public class RoomManager public ArrayList getRoomsStaffPromoted() { ArrayList r = new ArrayList<>(); - for(Room room : this.getActiveRooms()) - { - if(room.isStaffPromotedRoom()) - { + for (Room room : this.getActiveRooms()) { + if (room.isStaffPromotedRoom()) { r.add(room); } } @@ -1622,57 +1321,48 @@ public class RoomManager return r; } - public List filterRoomsByOwner(List rooms, String filter) - { + public List filterRoomsByOwner(List rooms, String filter) { ArrayList r = new ArrayList<>(); - for(Room room : rooms) - { - if(room.getOwnerName().equalsIgnoreCase(filter)) + for (Room room : rooms) { + if (room.getOwnerName().equalsIgnoreCase(filter)) r.add(room); } return r; } - public List filterRoomsByName(List rooms, String filter) - { + public List filterRoomsByName(List rooms, String filter) { ArrayList r = new ArrayList<>(); - for(Room room : rooms) - { - if(room.getName().toLowerCase().contains(filter.toLowerCase())) + for (Room room : rooms) { + if (room.getName().toLowerCase().contains(filter.toLowerCase())) r.add(room); } return r; } - public List filterRoomsByNameAndDescription(List rooms, String filter) - { + public List filterRoomsByNameAndDescription(List rooms, String filter) { ArrayList r = new ArrayList<>(); - for(Room room : rooms) - { - if(room.getName().toLowerCase().contains(filter.toLowerCase()) || room.getDescription().toLowerCase().contains(filter.toLowerCase())) + for (Room room : rooms) { + if (room.getName().toLowerCase().contains(filter.toLowerCase()) || room.getDescription().toLowerCase().contains(filter.toLowerCase())) r.add(room); } return r; } - public List filterRoomsByTag(List rooms, String filter) - { + public List filterRoomsByTag(List rooms, String filter) { ArrayList r = new ArrayList<>(); - for(Room room : rooms) - { - if(room.getTags().split(";").length == 0) + for (Room room : rooms) { + if (room.getTags().split(";").length == 0) continue; - for(String s : room.getTags().split(";")) - { - if(s.equalsIgnoreCase(filter)) + for (String s : room.getTags().split(";")) { + if (s.equalsIgnoreCase(filter)) r.add(room); } } @@ -1680,26 +1370,22 @@ public class RoomManager return r; } - public List filterRoomsByGroup(List rooms, String filter) - { + public List filterRoomsByGroup(List rooms, String filter) { ArrayList r = new ArrayList<>(); - for(Room room : rooms) - { - if(room.getGuildId() == 0) + for (Room room : rooms) { + if (room.getGuildId() == 0) continue; - if(Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()).getName().toLowerCase().contains(filter.toLowerCase())) + if (Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()).getName().toLowerCase().contains(filter.toLowerCase())) r.add(room); } return r; } - public synchronized void dispose() - { - for (Room room : this.activeRooms.values()) - { + public synchronized void dispose() { + for (Room room : this.activeRooms.values()) { room.dispose(); } @@ -1708,10 +1394,8 @@ public class RoomManager Emulator.getLogging().logShutdownLine("Room Manager -> Disposed!"); } - public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE door_x = ?, door_y = ?, door_dir = ?, heightmap = ?")) - { + public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE door_x = ?, door_y = ?, door_dir = ?, heightmap = ?")) { statement.setInt(1, room.getId()); statement.setString(2, "custom_" + room.getId()); statement.setInt(3, doorX); @@ -1723,17 +1407,14 @@ public class RoomManager statement.setInt(9, doorDirection); statement.setString(10, map); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return this.loadCustomLayout(room); } - public void banUserFromRoom(Habbo rights, int userId, int roomId, RoomBanTypes length) - { + public void banUserFromRoom(Habbo rights, int userId, int roomId, RoomBanTypes length) { Room room = this.getRoom(roomId); if (room == null) @@ -1745,31 +1426,24 @@ public class RoomManager String name = ""; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { - if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) - { + if (habbo != null) { + if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) { return; } name = habbo.getHabboInfo().getUsername(); - } - else - { + } else { HabboInfo info = HabboManager.getOfflineHabboInfo(userId); - if (info != null) - { - if (info.getRank().hasPermission(Permission.ACC_UNKICKABLE, false)) - { + if (info != null) { + if (info.getRank().hasPermission(Permission.ACC_UNKICKABLE, false)) { return; } name = info.getUsername(); } } - if (name.isEmpty()) - { + if (name.isEmpty()) { return; } @@ -1778,30 +1452,14 @@ public class RoomManager room.addRoomBan(roomBan); - if (habbo != null) - { - if (habbo.getHabboInfo().getCurrentRoom() == room) - { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentRoom() == room) { room.removeHabbo(habbo); habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_BANNED)); } } } - 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; - } - } - public void registerGameType(Class gameClass) { gameTypes.add(gameClass); } @@ -1813,4 +1471,16 @@ public class RoomManager public ArrayList> getGameTypes() { return gameTypes; } + + 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; + } + } } \ No newline at end of file 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 c8530bf5..54e12e6d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomMoodlightData.java @@ -1,15 +1,13 @@ package com.eu.habbo.habbohotel.rooms; -public class RoomMoodlightData -{ +public class RoomMoodlightData { private int id; private boolean enabled; private boolean backgroundOnly; private String color; private int intensity; - public RoomMoodlightData(int id, boolean enabled, boolean backgroundOnly, String color, int intensity) - { + public RoomMoodlightData(int id, boolean enabled, boolean backgroundOnly, String color, int intensity) { this.id = id; this.enabled = enabled; this.backgroundOnly = backgroundOnly; @@ -17,77 +15,61 @@ public class RoomMoodlightData this.intensity = intensity; } - 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; - } - - public void disable() - { - 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; - } - - public static RoomMoodlightData fromString(String s) - { + public static RoomMoodlightData fromString(String s) { String[] data = s.split(","); - if(data.length == 5) - { + 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])); - } - else - { + } 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; + } + + public void disable() { + 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 c6dc3e5b..6aeae74f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -7,43 +7,35 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class RoomPromotion -{ +public class RoomPromotion { private final Room room; + public boolean needsUpdate; private String title; private String description; private int endTimestamp; - public boolean needsUpdate; - public RoomPromotion(Room room, String title, String description, int endTimestamp) - { + public RoomPromotion(Room room, String title, String description, int endTimestamp) { this.room = room; this.title = title; this.description = description; this.endTimestamp = endTimestamp; } - public RoomPromotion(Room room, ResultSet set) throws SQLException - { + public RoomPromotion(Room room, ResultSet set) throws SQLException { this.room = room; this.title = set.getString("title"); this.description = set.getString("description"); this.endTimestamp = set.getInt("end_timestamp"); } - public void save() - { - if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ? WHERE room_id = ?")) - { + public void save() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ? WHERE room_id = ?")) { statement.setString(1, this.title); statement.setString(2, this.description); statement.setInt(3, this.room.getId()); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -51,43 +43,35 @@ public class RoomPromotion } } - public Room getRoom() - { + public Room getRoom() { return this.room; } - public String getTitle() - { + public String getTitle() { return this.title; } - public void setTitle(String title) - { + public void setTitle(String title) { this.title = title; } - public String getDescription() - { + public String getDescription() { return this.description; } - public void setDescription(String description) - { + public void setDescription(String description) { this.description = description; } - public int getEndTimestamp() - { + public int getEndTimestamp() { return this.endTimestamp; } - public void setEndTimestamp(int endTimestamp) - { + public void setEndTimestamp(int endTimestamp) { this.endTimestamp = endTimestamp; } - public void addEndTimestamp(int time) - { + public void addEndTimestamp(int time) { this.endTimestamp += time; } } 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 d6865b07..9795ec9c 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,39 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomRightLevels -{ +public enum RoomRightLevels { - NONE (0), + NONE(0), - RIGHTS (1), + RIGHTS(1), GUILD_RIGHTS(2), - GUILD_ADMIN (3), + GUILD_ADMIN(3), - OWNER (4), + OWNER(4), - MODERATOR (5), + MODERATOR(5), - SIX (6), + SIX(6), - SEVEN (7), + SEVEN(7), - EIGHT (8), + EIGHT(8), - NINE (9); + NINE(9); public final int level; - RoomRightLevels(int level) - { + RoomRightLevels(int level) { this.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 0c18a1d3..8f340378 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -9,12 +9,10 @@ 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.InteractionGameTimer; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter; -import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGate; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards.InteractionBattleBanzaiScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.InteractionFootballScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; -import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate; import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard; import com.eu.habbo.habbohotel.users.HabboItem; @@ -30,8 +28,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class RoomSpecialTypes -{ +public class RoomSpecialTypes { private final THashMap banzaiTeleporters; private final THashMap nests; private final THashMap petDrinks; @@ -52,8 +49,7 @@ public class RoomSpecialTypes private final THashMap undefined; private final THashSet cycleTasks; - public RoomSpecialTypes() - { + public RoomSpecialTypes() { this.banzaiTeleporters = new THashMap<>(0); this.nests = new THashMap<>(0); this.petDrinks = new THashMap<>(0); @@ -76,25 +72,20 @@ public class RoomSpecialTypes } - public InteractionBattleBanzaiTeleporter getBanzaiTeleporter(int itemId) - { + public InteractionBattleBanzaiTeleporter getBanzaiTeleporter(int itemId) { return this.banzaiTeleporters.get(itemId); } - public void addBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) - { + public void addBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) { this.banzaiTeleporters.put(item.getId(), item); } - public void removeBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) - { + public void removeBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) { this.banzaiTeleporters.remove(item.getId()); } - public THashSet getBanzaiTeleporters() - { - synchronized (this.banzaiTeleporters) - { + public THashSet getBanzaiTeleporters() { + synchronized (this.banzaiTeleporters) { THashSet battleBanzaiTeleporters = new THashSet<>(); battleBanzaiTeleporters.addAll(this.banzaiTeleporters.values()); @@ -102,21 +93,17 @@ public class RoomSpecialTypes } } - public InteractionBattleBanzaiTeleporter getRandomTeleporter(Item baseItem, InteractionBattleBanzaiTeleporter exclude) - { + public InteractionBattleBanzaiTeleporter getRandomTeleporter(Item baseItem, InteractionBattleBanzaiTeleporter exclude) { List teleporterList = new ArrayList<>(); - for (InteractionBattleBanzaiTeleporter teleporter : this.banzaiTeleporters.values()) - { - if (teleporter.getBaseItem() == baseItem) - { + for (InteractionBattleBanzaiTeleporter teleporter : this.banzaiTeleporters.values()) { + if (teleporter.getBaseItem() == baseItem) { teleporterList.add(teleporter); } } teleporterList.remove(exclude); - if (!teleporterList.isEmpty()) - { + if (!teleporterList.isEmpty()) { Collections.shuffle(teleporterList); return teleporterList.get(0); } @@ -125,25 +112,20 @@ public class RoomSpecialTypes } - public InteractionNest getNest(int itemId) - { + public InteractionNest getNest(int itemId) { return this.nests.get(itemId); } - public void addNest(InteractionNest item) - { + public void addNest(InteractionNest item) { this.nests.put(item.getId(), item); } - public void removeNest(InteractionNest item) - { + public void removeNest(InteractionNest item) { this.nests.remove(item.getId()); } - public THashSet getNests() - { - synchronized (this.nests) - { + public THashSet getNests() { + synchronized (this.nests) { THashSet nests = new THashSet<>(); nests.addAll(this.nests.values()); @@ -152,25 +134,20 @@ public class RoomSpecialTypes } - public InteractionPetDrink getPetDrink(int itemId) - { + public InteractionPetDrink getPetDrink(int itemId) { return this.petDrinks.get(itemId); } - public void addPetDrink(InteractionPetDrink item) - { + public void addPetDrink(InteractionPetDrink item) { this.petDrinks.put(item.getId(), item); } - public void removePetDrink(InteractionPetDrink item) - { + public void removePetDrink(InteractionPetDrink item) { this.petDrinks.remove(item.getId()); } - public THashSet getPetDrinks() - { - synchronized (this.petDrinks) - { + public THashSet getPetDrinks() { + synchronized (this.petDrinks) { THashSet petDrinks = new THashSet<>(); petDrinks.addAll(this.petDrinks.values()); @@ -179,25 +156,20 @@ public class RoomSpecialTypes } - public InteractionPetFood getPetFood(int itemId) - { + public InteractionPetFood getPetFood(int itemId) { return this.petFoods.get(itemId); } - public void addPetFood(InteractionPetFood item) - { + public void addPetFood(InteractionPetFood item) { this.petFoods.put(item.getId(), item); } - public void removePetFood(InteractionPetFood petFood) - { + public void removePetFood(InteractionPetFood petFood) { this.petFoods.remove(petFood.getId()); } - public THashSet getPetFoods() - { - synchronized (this.petFoods) - { + public THashSet getPetFoods() { + synchronized (this.petFoods) { THashSet petFoods = new THashSet<>(); petFoods.addAll(this.petFoods.values()); @@ -206,25 +178,20 @@ public class RoomSpecialTypes } - public InteractionPetToy getPetToy(int itemId) - { + public InteractionPetToy getPetToy(int itemId) { return this.petToys.get(itemId); } - public void addPetToy(InteractionPetToy item) - { + public void addPetToy(InteractionPetToy item) { this.petToys.put(item.getId(), item); } - public void removePetToy(InteractionPetToy petToy) - { + public void removePetToy(InteractionPetToy petToy) { this.petToys.remove(petToy.getId()); } - public THashSet getPetToys() - { - synchronized (this.petToys) - { + public THashSet getPetToys() { + synchronized (this.petToys) { THashSet petToys = new THashSet<>(); petToys.addAll(this.petToys.values()); @@ -233,44 +200,33 @@ public class RoomSpecialTypes } - public InteractionRoller getRoller(int itemId) - { - synchronized (this.rollers) - { + public InteractionRoller getRoller(int itemId) { + synchronized (this.rollers) { return this.rollers.get(itemId); } } - public void addRoller(InteractionRoller item) - { - synchronized (this.rollers) - { + public void addRoller(InteractionRoller item) { + synchronized (this.rollers) { this.rollers.put(item.getId(), item); } } - public void removeRoller(InteractionRoller roller) - { - synchronized (this.rollers) - { + public void removeRoller(InteractionRoller roller) { + synchronized (this.rollers) { this.rollers.remove(roller.getId()); } } - public THashMap getRollers() - { + public THashMap getRollers() { return this.rollers; } - public InteractionWiredTrigger getTrigger(int itemId) - { - synchronized (this.wiredTriggers) - { - for (Map.Entry> map : this.wiredTriggers.entrySet()) - { - for (InteractionWiredTrigger trigger : map.getValue()) - { + public InteractionWiredTrigger getTrigger(int itemId) { + synchronized (this.wiredTriggers) { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { + for (InteractionWiredTrigger trigger : map.getValue()) { if (trigger.getId() == itemId) return trigger; } @@ -280,14 +236,11 @@ public class RoomSpecialTypes } } - public THashSet getTriggers() - { - synchronized (this.wiredTriggers) - { + public THashSet getTriggers() { + synchronized (this.wiredTriggers) { THashSet triggers = new THashSet<>(); - for (Map.Entry> map : this.wiredTriggers.entrySet()) - { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { triggers.addAll(map.getValue()); } @@ -295,21 +248,16 @@ public class RoomSpecialTypes } } - public THashSet getTriggers(WiredTriggerType type) - { + public THashSet getTriggers(WiredTriggerType type) { return this.wiredTriggers.get(type); } - public THashSet getTriggers(int x, int y) - { - synchronized (this.wiredTriggers) - { + public THashSet getTriggers(int x, int y) { + synchronized (this.wiredTriggers) { THashSet triggers = new THashSet<>(); - for (Map.Entry> map : this.wiredTriggers.entrySet()) - { - for (InteractionWiredTrigger trigger : map.getValue()) - { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { + for (InteractionWiredTrigger trigger : map.getValue()) { if (trigger.getX() == x && trigger.getY() == y) triggers.add(trigger); } @@ -319,10 +267,8 @@ public class RoomSpecialTypes } } - public void addTrigger(InteractionWiredTrigger trigger) - { - synchronized (this.wiredTriggers) - { + public void addTrigger(InteractionWiredTrigger trigger) { + synchronized (this.wiredTriggers) { if (!this.wiredTriggers.containsKey(trigger.getType())) this.wiredTriggers.put(trigger.getType(), new THashSet<>()); @@ -330,28 +276,21 @@ public class RoomSpecialTypes } } - public void removeTrigger(InteractionWiredTrigger trigger) - { - synchronized (this.wiredTriggers) - { + public void removeTrigger(InteractionWiredTrigger trigger) { + synchronized (this.wiredTriggers) { this.wiredTriggers.get(trigger.getType()).remove(trigger); - if (this.wiredTriggers.get(trigger.getType()).isEmpty()) - { + if (this.wiredTriggers.get(trigger.getType()).isEmpty()) { this.wiredTriggers.remove(trigger.getType()); } } } - public InteractionWiredEffect getEffect(int itemId) - { - synchronized (this.wiredEffects) - { - for (Map.Entry> map : this.wiredEffects.entrySet()) - { - for (InteractionWiredEffect effect : map.getValue()) - { + public InteractionWiredEffect getEffect(int itemId) { + synchronized (this.wiredEffects) { + for (Map.Entry> map : this.wiredEffects.entrySet()) { + for (InteractionWiredEffect effect : map.getValue()) { if (effect.getId() == itemId) return effect; } @@ -361,14 +300,11 @@ public class RoomSpecialTypes return null; } - public THashSet getEffects() - { - synchronized (this.wiredEffects) - { + public THashSet getEffects() { + synchronized (this.wiredEffects) { THashSet effects = new THashSet<>(); - for (Map.Entry> map : this.wiredEffects.entrySet()) - { + for (Map.Entry> map : this.wiredEffects.entrySet()) { effects.addAll(map.getValue()); } @@ -376,21 +312,16 @@ public class RoomSpecialTypes } } - public THashSet getEffects(WiredEffectType type) - { + public THashSet getEffects(WiredEffectType type) { return this.wiredEffects.get(type); } - public THashSet getEffects(int x, int y) - { - synchronized (this.wiredEffects) - { + public THashSet getEffects(int x, int y) { + synchronized (this.wiredEffects) { THashSet effects = new THashSet<>(); - for (Map.Entry> map : this.wiredEffects.entrySet()) - { - for (InteractionWiredEffect effect : map.getValue()) - { + for (Map.Entry> map : this.wiredEffects.entrySet()) { + for (InteractionWiredEffect effect : map.getValue()) { if (effect.getX() == x && effect.getY() == y) effects.add(effect); } @@ -400,10 +331,8 @@ public class RoomSpecialTypes } } - public void addEffect(InteractionWiredEffect effect) - { - synchronized (this.wiredEffects) - { + public void addEffect(InteractionWiredEffect effect) { + synchronized (this.wiredEffects) { if (!this.wiredEffects.containsKey(effect.getType())) this.wiredEffects.put(effect.getType(), new THashSet<>()); @@ -411,28 +340,21 @@ public class RoomSpecialTypes } } - public void removeEffect(InteractionWiredEffect effect) - { - synchronized (this.wiredEffects) - { + public void removeEffect(InteractionWiredEffect effect) { + synchronized (this.wiredEffects) { this.wiredEffects.get(effect.getType()).remove(effect); - if (this.wiredEffects.get(effect.getType()).isEmpty()) - { + if (this.wiredEffects.get(effect.getType()).isEmpty()) { this.wiredEffects.remove(effect.getType()); } } } - public InteractionWiredCondition getCondition(int itemId) - { - synchronized (this.wiredConditions) - { - for (Map.Entry> map : this.wiredConditions.entrySet()) - { - for (InteractionWiredCondition condition : map.getValue()) - { + public InteractionWiredCondition getCondition(int itemId) { + synchronized (this.wiredConditions) { + for (Map.Entry> map : this.wiredConditions.entrySet()) { + for (InteractionWiredCondition condition : map.getValue()) { if (condition.getId() == itemId) return condition; } @@ -442,14 +364,11 @@ public class RoomSpecialTypes return null; } - public THashSet getConditions() - { - synchronized (this.wiredConditions) - { + public THashSet getConditions() { + synchronized (this.wiredConditions) { THashSet conditions = new THashSet<>(); - for (Map.Entry> map : this.wiredConditions.entrySet()) - { + for (Map.Entry> map : this.wiredConditions.entrySet()) { conditions.addAll(map.getValue()); } @@ -457,24 +376,18 @@ public class RoomSpecialTypes } } - public THashSet getConditions(WiredConditionType type) - { - synchronized (this.wiredConditions) - { + public THashSet getConditions(WiredConditionType type) { + synchronized (this.wiredConditions) { return this.wiredConditions.get(type); } } - public THashSet getConditions(int x, int y) - { - synchronized (this.wiredConditions) - { + public THashSet getConditions(int x, int y) { + synchronized (this.wiredConditions) { THashSet conditions = new THashSet<>(); - for (Map.Entry> map : this.wiredConditions.entrySet()) - { - for (InteractionWiredCondition condition : map.getValue()) - { + for (Map.Entry> map : this.wiredConditions.entrySet()) { + for (InteractionWiredCondition condition : map.getValue()) { if (condition.getX() == x && condition.getY() == y) conditions.add(condition); } @@ -484,10 +397,8 @@ public class RoomSpecialTypes } } - public void addCondition(InteractionWiredCondition condition) - { - synchronized (this.wiredConditions) - { + public void addCondition(InteractionWiredCondition condition) { + synchronized (this.wiredConditions) { if (!this.wiredConditions.containsKey(condition.getType())) this.wiredConditions.put(condition.getType(), new THashSet<>()); @@ -495,28 +406,22 @@ public class RoomSpecialTypes } } - public void removeCondition(InteractionWiredCondition condition) - { - synchronized (this.wiredConditions) - { + public void removeCondition(InteractionWiredCondition condition) { + synchronized (this.wiredConditions) { this.wiredConditions.get(condition.getType()).remove(condition); - if (this.wiredConditions.get(condition.getType()).isEmpty()) - { + if (this.wiredConditions.get(condition.getType()).isEmpty()) { this.wiredConditions.remove(condition.getType()); } } } - public THashSet getExtras() - { - synchronized (this.wiredExtras) - { + public THashSet getExtras() { + synchronized (this.wiredExtras) { THashSet conditions = new THashSet<>(); - for (Map.Entry map : this.wiredExtras.entrySet()) - { + for (Map.Entry map : this.wiredExtras.entrySet()) { conditions.add(map.getValue()); } @@ -524,16 +429,12 @@ public class RoomSpecialTypes } } - public THashSet getExtras(int x, int y) - { - synchronized (this.wiredExtras) - { + public THashSet getExtras(int x, int y) { + synchronized (this.wiredExtras) { THashSet extras = new THashSet<>(); - for (Map.Entry map : this.wiredExtras.entrySet()) - { - if (map.getValue().getX() == x && map.getValue().getY() == y) - { + for (Map.Entry map : this.wiredExtras.entrySet()) { + if (map.getValue().getX() == x && map.getValue().getY() == y) { extras.add(map.getValue()); } } @@ -542,30 +443,22 @@ public class RoomSpecialTypes } } - public void addExtra(InteractionWiredExtra extra) - { - synchronized (this.wiredExtras) - { + public void addExtra(InteractionWiredExtra extra) { + synchronized (this.wiredExtras) { this.wiredExtras.put(extra.getId(), extra); } } - public void removeExtra(InteractionWiredExtra extra) - { - synchronized (this.wiredExtras) - { + public void removeExtra(InteractionWiredExtra extra) { + synchronized (this.wiredExtras) { this.wiredExtras.remove(extra.getId()); } } - public boolean hasExtraType(short x, short y, Class type) - { - synchronized (this.wiredExtras) - { - for (Map.Entry map : this.wiredExtras.entrySet()) - { - if (map.getValue().getX() == x && map.getValue().getY() == y && map.getValue().getClass().isAssignableFrom(type)) - { + public boolean hasExtraType(short x, short y, Class type) { + synchronized (this.wiredExtras) { + for (Map.Entry map : this.wiredExtras.entrySet()) { + if (map.getValue().getX() == x && map.getValue().getY() == y && map.getValue().getClass().isAssignableFrom(type)) { return true; } } @@ -575,31 +468,24 @@ public class RoomSpecialTypes } - public InteractionGameScoreboard getGameScorebord(int itemId) - { + public InteractionGameScoreboard getGameScorebord(int itemId) { return this.gameScoreboards.get(itemId); } - public void addGameScoreboard(InteractionGameScoreboard scoreboard) - { + public void addGameScoreboard(InteractionGameScoreboard scoreboard) { this.gameScoreboards.put(scoreboard.getId(), scoreboard); } - public void removeScoreboard(InteractionGameScoreboard scoreboard) - { + public void removeScoreboard(InteractionGameScoreboard scoreboard) { this.gameScoreboards.remove(scoreboard.getId()); } - public THashMap getFreezeScoreboards() - { - synchronized (this.gameScoreboards) - { + public THashMap getFreezeScoreboards() { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionFreezeScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionFreezeScoreboard) { boards.put(set.getValue().getId(), (InteractionFreezeScoreboard) set.getValue()); } } @@ -608,16 +494,12 @@ public class RoomSpecialTypes } } - public THashMap getFreezeScoreboards(GameTeamColors teamColor) - { - synchronized (this.gameScoreboards) - { + public THashMap getFreezeScoreboards(GameTeamColors teamColor) { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionFreezeScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionFreezeScoreboard) { if (((InteractionFreezeScoreboard) set.getValue()).teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionFreezeScoreboard) set.getValue()); } @@ -627,16 +509,12 @@ public class RoomSpecialTypes } } - public THashMap getBattleBanzaiScoreboards() - { - synchronized (this.gameScoreboards) - { + public THashMap getBattleBanzaiScoreboards() { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionBattleBanzaiScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionBattleBanzaiScoreboard) { boards.put(set.getValue().getId(), (InteractionBattleBanzaiScoreboard) set.getValue()); } } @@ -645,16 +523,12 @@ public class RoomSpecialTypes } } - public THashMap getBattleBanzaiScoreboards(GameTeamColors teamColor) - { - synchronized (this.gameScoreboards) - { + public THashMap getBattleBanzaiScoreboards(GameTeamColors teamColor) { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionBattleBanzaiScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionBattleBanzaiScoreboard) { if (((InteractionBattleBanzaiScoreboard) set.getValue()).teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionBattleBanzaiScoreboard) set.getValue()); } @@ -664,16 +538,12 @@ public class RoomSpecialTypes } } - public THashMap getFootballScoreboards() - { - synchronized (this.gameScoreboards) - { + public THashMap getFootballScoreboards() { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionFootballScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionFootballScoreboard) { boards.put(set.getValue().getId(), (InteractionFootballScoreboard) set.getValue()); } } @@ -682,16 +552,12 @@ public class RoomSpecialTypes } } - public THashMap getFootballScoreboards(GameTeamColors teamColor) - { - synchronized (this.gameScoreboards) - { + public THashMap getFootballScoreboards(GameTeamColors teamColor) { + synchronized (this.gameScoreboards) { THashMap boards = new THashMap<>(); - for (Map.Entry set : this.gameScoreboards.entrySet()) - { - if (set.getValue() instanceof InteractionFootballScoreboard) - { + for (Map.Entry set : this.gameScoreboards.entrySet()) { + if (set.getValue() instanceof InteractionFootballScoreboard) { if (((InteractionFootballScoreboard) set.getValue()).teamColor.equals(teamColor)) boards.put(set.getValue().getId(), (InteractionFootballScoreboard) set.getValue()); } @@ -702,31 +568,24 @@ public class RoomSpecialTypes } - public InteractionGameGate getGameGate(int itemId) - { + public InteractionGameGate getGameGate(int itemId) { return this.gameGates.get(itemId); } - public void addGameGate(InteractionGameGate gameGate) - { + public void addGameGate(InteractionGameGate gameGate) { this.gameGates.put(gameGate.getId(), gameGate); } - public void removeGameGate(InteractionGameGate gameGate) - { + public void removeGameGate(InteractionGameGate gameGate) { this.gameGates.remove(gameGate.getId()); } - public THashMap getFreezeGates() - { - synchronized (this.gameGates) - { + public THashMap getFreezeGates() { + synchronized (this.gameGates) { THashMap gates = new THashMap<>(); - for (Map.Entry set : this.gameGates.entrySet()) - { - if (set.getValue() instanceof InteractionFreezeGate) - { + for (Map.Entry set : this.gameGates.entrySet()) { + if (set.getValue() instanceof InteractionFreezeGate) { gates.put(set.getValue().getId(), (InteractionFreezeGate) set.getValue()); } } @@ -735,16 +594,12 @@ public class RoomSpecialTypes } } - public THashMap getBattleBanzaiGates() - { - synchronized (this.gameGates) - { + public THashMap getBattleBanzaiGates() { + synchronized (this.gameGates) { THashMap gates = new THashMap<>(); - for (Map.Entry set : this.gameGates.entrySet()) - { - if (set.getValue() instanceof InteractionBattleBanzaiGate) - { + for (Map.Entry set : this.gameGates.entrySet()) { + if (set.getValue() instanceof InteractionBattleBanzaiGate) { gates.put(set.getValue().getId(), (InteractionBattleBanzaiGate) set.getValue()); } } @@ -754,88 +609,69 @@ public class RoomSpecialTypes } - public InteractionGameTimer getGameTimer(int itemId) - { + public InteractionGameTimer getGameTimer(int itemId) { return this.gameTimers.get(itemId); } - public void addGameTimer(InteractionGameTimer gameTimer) - { + public void addGameTimer(InteractionGameTimer gameTimer) { this.gameTimers.put(gameTimer.getId(), gameTimer); } - public void removeGameTimer(InteractionGameTimer gameTimer) - { + public void removeGameTimer(InteractionGameTimer gameTimer) { this.gameTimers.remove(gameTimer.getId()); } - public THashMap getGameTimers() - { + public THashMap getGameTimers() { return this.gameTimers; } - public InteractionFreezeExitTile getFreezeExitTile() - { - for(InteractionFreezeExitTile t : this.freezeExitTile.values()) - { + public InteractionFreezeExitTile getFreezeExitTile() { + for (InteractionFreezeExitTile t : this.freezeExitTile.values()) { return t; } return null; } - public InteractionFreezeExitTile getRandomFreezeExitTile() - { - synchronized (this.freezeExitTile) - { + public InteractionFreezeExitTile getRandomFreezeExitTile() { + synchronized (this.freezeExitTile) { return (InteractionFreezeExitTile) this.freezeExitTile.values().toArray()[Emulator.getRandom().nextInt(this.freezeExitTile.size())]; } } - public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) - { + public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile); } - public THashMap getFreezeExitTiles() - { + public THashMap getFreezeExitTiles() { return this.freezeExitTile; } - public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) - { + public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { this.freezeExitTile.remove(freezeExitTile.getId()); } - public boolean hasFreezeExitTile() - { + public boolean hasFreezeExitTile() { return !this.freezeExitTile.isEmpty(); } - public void addUndefined(HabboItem item) - { - synchronized (this.undefined) - { + public void addUndefined(HabboItem item) { + synchronized (this.undefined) { this.undefined.put(item.getId(), item); } } - public void removeUndefined(HabboItem item) - { - synchronized (this.undefined) - { + public void removeUndefined(HabboItem item) { + synchronized (this.undefined) { this.undefined.remove(item.getId()); } } - public THashSet getItemsOfType(Class type) - { + public THashSet getItemsOfType(Class type) { THashSet items = new THashSet<>(); - synchronized (this.undefined) - { - for(HabboItem item : this.undefined.values()) - { - if(item.getClass() == type) + synchronized (this.undefined) { + for (HabboItem item : this.undefined.values()) { + if (item.getClass() == type) items.add(item); } } @@ -843,17 +679,12 @@ public class RoomSpecialTypes return items; } - public HabboItem getLowestItemsOfType(Class type) - { + public HabboItem getLowestItemsOfType(Class type) { HabboItem i = null; - synchronized (this.undefined) - { - for (HabboItem item : this.undefined.values()) - { - if (i == null || item.getZ() < i.getZ()) - { - if (item.getClass().isAssignableFrom(type)) - { + synchronized (this.undefined) { + for (HabboItem item : this.undefined.values()) { + if (i == null || item.getZ() < i.getZ()) { + if (item.getClass().isAssignableFrom(type)) { i = item; } } @@ -863,23 +694,19 @@ public class RoomSpecialTypes return i; } - public THashSet getCycleTasks() - { + public THashSet getCycleTasks() { return this.cycleTasks; } - public void addCycleTask(ICycleable task) - { + public void addCycleTask(ICycleable task) { this.cycleTasks.add(task); } - public void removeCycleTask(ICycleable task) - { + public void removeCycleTask(ICycleable task) { this.cycleTasks.remove(task); } - public synchronized void dispose() - { + public synchronized void dispose() { this.banzaiTeleporters.clear(); this.nests.clear(); this.petDrinks.clear(); @@ -899,13 +726,10 @@ public class RoomSpecialTypes this.cycleTasks.clear(); } - public Rectangle tentAt(RoomTile location) - { - for (HabboItem item : this.getItemsOfType(InteractionTent.class)) - { + public Rectangle tentAt(RoomTile location) { + for (HabboItem item : this.getItemsOfType(InteractionTent.class)) { Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - if (RoomLayout.tileInSquare(rectangle, location)) - { + if (RoomLayout.tileInSquare(rectangle, location)) { return rectangle; } } 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 f673cd7a..d6962bfd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomState -{ +public enum RoomState { OPEN(0), LOCKED(1), PASSWORD(2), @@ -9,13 +8,11 @@ public enum RoomState private final int state; - RoomState(int state) - { + RoomState(int state) { this.state = state; } - public int getState() - { + 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 177db674..61d1db47 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -1,32 +1,26 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; import java.util.ArrayList; import java.util.List; -public class RoomTile -{ +public class RoomTile { public final short x; public final short y; public final short z; + private final THashSet units; public RoomTileState state; - private double stackHeight; private boolean allowStack = true; - private RoomTile previous = null; private boolean diagonally; private short gCosts; private short hCosts; - private final THashSet units; - - public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack) - { + public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack) { this.x = x; this.y = y; this.z = z; @@ -36,8 +30,7 @@ public class RoomTile this.units = new THashSet<>(); } - public RoomTile(RoomTile tile) - { + public RoomTile(RoomTile tile) { this.x = tile.x; this.y = tile.y; this.z = tile.z; @@ -48,62 +41,48 @@ public class RoomTile this.gCosts = tile.gCosts; this.hCosts = tile.hCosts; - if (this.state == RoomTileState.INVALID) - { + if (this.state == RoomTileState.INVALID) { this.allowStack = false; } this.units = tile.units; } - public double getStackHeight() - { + public double getStackHeight() { return this.stackHeight; } - public void setStackHeight(double stackHeight) - { - if (this.state == RoomTileState.INVALID) - { + public void setStackHeight(double stackHeight) { + if (this.state == RoomTileState.INVALID) { this.stackHeight = Short.MAX_VALUE; this.allowStack = false; return; } - if (stackHeight >= 0 && stackHeight != Short.MAX_VALUE) - { + if (stackHeight >= 0 && stackHeight != Short.MAX_VALUE) { this.stackHeight = stackHeight; this.allowStack = true; - } - else - { + } else { this.allowStack = false; this.stackHeight = this.z; } } - public boolean getAllowStack() - { - if (this.state == RoomTileState.INVALID) - { + public boolean getAllowStack() { + if (this.state == RoomTileState.INVALID) { return false; } return this.allowStack; } - public void setAllowStack(boolean allowStack) - { + public void setAllowStack(boolean allowStack) { this.allowStack = allowStack; } - public short relativeHeight() - { - if (this.state == RoomTileState.INVALID) - { + public short relativeHeight() { + if (this.state == RoomTileState.INVALID) { return Short.MAX_VALUE; - } - else if (!this.allowStack && (this.state == RoomTileState.BLOCKED || this.state == RoomTileState.SIT)) - { + } else if (!this.allowStack && (this.state == RoomTileState.BLOCKED || this.state == RoomTileState.SIT)) { return 64 * 256; } @@ -111,102 +90,83 @@ public class RoomTile } @Override - public boolean equals(Object o) - { - return o instanceof RoomTile && + public boolean equals(Object o) { + return o instanceof RoomTile && ((RoomTile) o).x == this.x && ((RoomTile) o).y == this.y; } - public RoomTile copy() - { + public RoomTile copy() { return new RoomTile(this); } - public double distance(RoomTile roomTile) - { + public double distance(RoomTile roomTile) { double x = this.x - roomTile.x; double y = this.y - roomTile.y; return Math.sqrt(x * x + y * y); } - public void isDiagonally(boolean isDiagonally) - { + public void isDiagonally(boolean isDiagonally) { this.diagonally = isDiagonally; } - public RoomTile getPrevious() - { + public RoomTile getPrevious() { return this.previous; } - public void setPrevious(RoomTile previous) - { + public void setPrevious(RoomTile previous) { this.previous = previous; } - public int getfCosts() - { + public int getfCosts() { return this.gCosts + this.hCosts; } - public int getgCosts() - { + public int getgCosts() { return this.gCosts; } - private void setgCosts(short gCosts) - { - this.gCosts = gCosts; - } - - void setgCosts(RoomTile previousRoomTile, int basicCost) - { - this.setgCosts((short)(previousRoomTile.getgCosts() + basicCost)); - } - - public void setgCosts(RoomTile previousRoomTile) - { + public void setgCosts(RoomTile previousRoomTile) { this.setgCosts(previousRoomTile, this.diagonally ? RoomLayout.DIAGONALMOVEMENTCOST : RoomLayout.BASICMOVEMENTCOST); } - public int calculategCosts(RoomTile previousRoomTile) - { - if (this.diagonally) - { + private void setgCosts(short gCosts) { + this.gCosts = gCosts; + } + + void setgCosts(RoomTile previousRoomTile, int basicCost) { + this.setgCosts((short) (previousRoomTile.getgCosts() + basicCost)); + } + + public int calculategCosts(RoomTile previousRoomTile) { + if (this.diagonally) { return previousRoomTile.getgCosts() + 14; } return previousRoomTile.getgCosts() + 10; } - public void sethCosts(RoomTile parent) - { - this.hCosts = (short)((Math.abs(this.x - parent.x) + Math.abs(this.y - parent.y)) * (parent.diagonally ? RoomLayout.DIAGONALMOVEMENTCOST : RoomLayout.BASICMOVEMENTCOST)); + public void sethCosts(RoomTile parent) { + this.hCosts = (short) ((Math.abs(this.x - parent.x) + Math.abs(this.y - parent.y)) * (parent.diagonally ? RoomLayout.DIAGONALMOVEMENTCOST : RoomLayout.BASICMOVEMENTCOST)); } - public String toString() - { + public String toString() { return "RoomTile (" + this.x + ", " + this.y + ", " + this.z + "): h: " + this.hCosts + " g: " + this.gCosts + " f: " + this.getfCosts(); } - public boolean isWalkable() - { + public boolean isWalkable() { return this.state == RoomTileState.OPEN; } - public RoomTileState getState() - { + public RoomTileState getState() { return this.state; } - public void setState(RoomTileState state) - { + public void setState(RoomTileState state) { this.state = state; } - public boolean is(short x, short y) - { + 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/RoomTileState.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java index 955b9f91..634ae4c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java @@ -1,8 +1,7 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomTileState -{ +public enum RoomTileState { OPEN, 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 ebfdd3ac..ba56a8e1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -14,18 +14,16 @@ import java.sql.*; import java.util.ArrayList; import java.util.List; -public class RoomTrade -{ +public class RoomTrade { //Configuration. Loaded from database & updated accordingly. public static boolean TRADING_ENABLED = true; public static boolean TRADING_REQUIRES_PERK = true; private final List users; - private boolean tradeCompleted; private final Room room; + private boolean tradeCompleted; - public RoomTrade(Habbo userOne, Habbo userTwo, Room room) - { + public RoomTrade(Habbo userOne, Habbo userTwo, Room room) { this.users = new ArrayList<>(); this.tradeCompleted = false; @@ -34,35 +32,29 @@ public class RoomTrade this.room = room; } - public void start() - { + public void start() { this.initializeTradeStatus(); this.openTrade(); } - protected void initializeTradeStatus() - { - for(RoomTradeUser roomTradeUser : this.users) - { - if(!roomTradeUser.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) - { + protected void initializeTradeStatus() { + for (RoomTradeUser roomTradeUser : this.users) { + if (!roomTradeUser.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) { roomTradeUser.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.TRADING, ""); - if(!roomTradeUser.getHabbo().getRoomUnit().isWalking()) + if (!roomTradeUser.getHabbo().getRoomUnit().isWalking()) this.room.sendComposer(new RoomUserStatusComposer(roomTradeUser.getHabbo().getRoomUnit()).compose()); } } } - protected void openTrade() - { + protected void openTrade() { this.sendMessageToUsers(new TradeStartComposer(this)); } - public void offerItem(Habbo habbo, HabboItem item) - { + public void offerItem(Habbo habbo, HabboItem item) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); - if(user.getItems().contains(item)) + if (user.getItems().contains(item)) return; habbo.getInventory().getItemsComponent().removeHabboItem(item); @@ -71,15 +63,12 @@ public class RoomTrade this.clearAccepted(); this.updateWindow(); } - - public void offerMultipleItems(Habbo habbo, THashSet items) - { + + public void offerMultipleItems(Habbo habbo, THashSet items) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); - for(HabboItem item : items) - { - if(!user.getItems().contains(item)) - { + for (HabboItem item : items) { + if (!user.getItems().contains(item)) { habbo.getInventory().getItemsComponent().removeHabboItem(item); user.getItems().add(item); } @@ -89,11 +78,10 @@ public class RoomTrade this.updateWindow(); } - public void removeItem(Habbo habbo, HabboItem item) - { + public void removeItem(Habbo habbo, HabboItem item) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); - if(!user.getItems().contains(item)) + if (!user.getItems().contains(item)) return; habbo.getInventory().getItemsComponent().addItem(item); @@ -103,42 +91,35 @@ public class RoomTrade this.updateWindow(); } - public void accept(Habbo habbo, boolean value) - { + public void accept(Habbo habbo, boolean value) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); user.setAccepted(value); this.sendMessageToUsers(new TradeAcceptedComposer(user)); boolean accepted = true; - for(RoomTradeUser roomTradeUser : this.users) - { - if(!roomTradeUser.getAccepted()) + for (RoomTradeUser roomTradeUser : this.users) { + if (!roomTradeUser.getAccepted()) accepted = false; } - if(accepted) - { + if (accepted) { this.sendMessageToUsers(new TradingWaitingConfirmComposer()); } } - public void confirm(Habbo habbo) - { + public void confirm(Habbo habbo) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); user.confirm(); this.sendMessageToUsers(new TradeAcceptedComposer(user)); boolean accepted = true; - for(RoomTradeUser roomTradeUser : this.users) - { - if(!roomTradeUser.getConfirmed()) + for (RoomTradeUser roomTradeUser : this.users) { + if (!roomTradeUser.getConfirmed()) accepted = false; } - if(accepted) - { - if (this.tradeItems()) - { + if (accepted) { + if (this.tradeItems()) { this.closeWindow(); this.sendMessageToUsers(new TradeCompleteComposer()); } @@ -147,14 +128,10 @@ public class RoomTrade } } - boolean tradeItems() - { - for(RoomTradeUser roomTradeUser : this.users) - { - for(HabboItem item : roomTradeUser.getItems()) - { - if(roomTradeUser.getHabbo().getInventory().getItemsComponent().getHabboItem(item.getId()) != null) - { + boolean tradeItems() { + for (RoomTradeUser roomTradeUser : this.users) { + for (HabboItem item : roomTradeUser.getItems()) { + if (roomTradeUser.getHabbo().getInventory().getItemsComponent().getHabboItem(item.getId()) != null) { this.sendMessageToUsers(new TradeClosedComposer(roomTradeUser.getHabbo().getRoomUnit().getId(), TradeClosedComposer.ITEMS_NOT_FOUND)); return false; } @@ -164,16 +141,13 @@ public class RoomTrade RoomTradeUser userOne = this.users.get(0); RoomTradeUser userTwo = this.users.get(1); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { int tradeId = 0; boolean logTrades = Emulator.getConfig().getBoolean("hotel.log.trades"); - if (logTrades) - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trade_log (user_one_id, user_two_id, user_one_ip, user_two_ip, timestamp, user_one_item_count, user_two_item_count) VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + if (logTrades) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trade_log (user_one_id, user_two_id, user_one_ip, user_two_ip, timestamp, user_one_item_count, user_two_item_count) VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userOne.getHabbo().getHabboInfo().getId()); statement.setInt(2, userTwo.getHabbo().getHabboInfo().getId()); statement.setString(3, userOne.getHabbo().getHabboInfo().getIpLogin()); @@ -182,10 +156,8 @@ public class RoomTrade statement.setInt(6, userOne.getItems().size()); statement.setInt(7, userTwo.getItems().size()); statement.executeUpdate(); - try (ResultSet generatedKeys = statement.getGeneratedKeys()) - { - if (generatedKeys.next()) - { + try (ResultSet generatedKeys = statement.getGeneratedKeys()) { + if (generatedKeys.next()) { tradeId = generatedKeys.getInt(1); } } @@ -195,19 +167,15 @@ public class RoomTrade int userOneId = userOne.getHabbo().getHabboInfo().getId(); int userTwoId = userTwo.getHabbo().getHabboInfo().getId(); - try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) - { - try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO room_trade_log_items (id, item_id, user_id) VALUES (?, ?, ?)")) - { - for (HabboItem item : userOne.getItems()) - { + try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) { + try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO room_trade_log_items (id, item_id, user_id) VALUES (?, ?, ?)")) { + for (HabboItem item : userOne.getItems()) { item.setUserId(userTwoId); statement.setInt(1, userTwoId); statement.setInt(2, item.getId()); statement.addBatch(); - if (logTrades) - { + if (logTrades) { stmt.setInt(1, tradeId); stmt.setInt(2, item.getId()); stmt.setInt(3, userOneId); @@ -215,15 +183,13 @@ public class RoomTrade } } - for (HabboItem item : userTwo.getItems()) - { + for (HabboItem item : userTwo.getItems()) { item.setUserId(userOneId); statement.setInt(1, userOneId); statement.setInt(2, item.getId()); statement.addBatch(); - if (logTrades) - { + if (logTrades) { stmt.setInt(1, tradeId); stmt.setInt(2, item.getId()); stmt.setInt(3, userTwoId); @@ -231,17 +197,14 @@ public class RoomTrade } } - if (logTrades) - { + if (logTrades) { stmt.executeBatch(); } } statement.executeBatch(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -262,39 +225,32 @@ public class RoomTrade return true; } - protected void clearAccepted() - { - for(RoomTradeUser user : this.users) - { + protected void clearAccepted() { + for (RoomTradeUser user : this.users) { user.setAccepted(false); } } - protected void updateWindow() - { + protected void updateWindow() { this.sendMessageToUsers(new TradeUpdateComposer(this)); } - private void returnItems() - { - for (RoomTradeUser user : this.users) - { + private void returnItems() { + for (RoomTradeUser user : this.users) { user.putItemsIntoInventory(); } } - private void closeWindow() - { + + private void closeWindow() { this.removeStatusses(); this.sendMessageToUsers(new TradeCloseWindowComposer()); } - public void stopTrade(Habbo habbo) - { + public void stopTrade(Habbo habbo) { this.removeStatusses(); this.clearAccepted(); this.returnItems(); - for (RoomTradeUser user : this.users) - { + for (RoomTradeUser user : this.users) { user.clearItems(); } this.updateWindow(); @@ -302,13 +258,11 @@ public class RoomTrade this.room.stopTrade(this); } - private void removeStatusses() - { - for(RoomTradeUser user : this.users) - { + private void removeStatusses() { + for (RoomTradeUser user : this.users) { Habbo habbo = user.getHabbo(); - if(habbo == null) + if (habbo == null) continue; habbo.getRoomUnit().removeStatus(RoomUnitStatus.TRADING); @@ -316,26 +270,21 @@ public class RoomTrade } } - public RoomTradeUser getRoomTradeUserForHabbo(Habbo habbo) - { - for(RoomTradeUser roomTradeUser : this.users) - { - if(roomTradeUser.getHabbo() == habbo) + public RoomTradeUser getRoomTradeUserForHabbo(Habbo habbo) { + for (RoomTradeUser roomTradeUser : this.users) { + if (roomTradeUser.getHabbo() == habbo) return roomTradeUser; } return null; } - public void sendMessageToUsers(MessageComposer message) - { - for(RoomTradeUser roomTradeUser : this.users) - { + public void sendMessageToUsers(MessageComposer message) { + for (RoomTradeUser roomTradeUser : this.users) { roomTradeUser.getHabbo().getClient().sendResponse(message); } } - public List getRoomTradeUsers() - { + public List getRoomTradeUsers() { return this.users; } } 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 ee0ab783..6b222e32 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java @@ -4,20 +4,17 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -public class RoomTradeUser -{ - private int userId; +public class RoomTradeUser { private final Habbo habbo; + private final THashSet items; + private int userId; private boolean accepted; private boolean confirmed; - private final THashSet items; - public RoomTradeUser(Habbo habbo) - { + public RoomTradeUser(Habbo habbo) { this.habbo = habbo; - if (this.habbo != null) - { + if (this.habbo != null) { this.userId = this.habbo.getHabboInfo().getId(); } @@ -26,52 +23,41 @@ public class RoomTradeUser this.items = new THashSet<>(); } - public int getUserId() - { + public int getUserId() { return this.userId; } - public void setUserId(int userId) - { + public void setUserId(int userId) { this.userId = userId; } - public Habbo getHabbo() - { + public Habbo getHabbo() { return this.habbo; } - public boolean getAccepted() - { + public boolean getAccepted() { return this.accepted; } - public boolean getConfirmed() - { - return this.confirmed; - } - - public void setAccepted(boolean value) - { + public void setAccepted(boolean value) { this.accepted = value; } - public void confirm() - { + public boolean getConfirmed() { + return this.confirmed; + } + + public void confirm() { this.confirmed = true; } - public void addItem(HabboItem item) - { + public void addItem(HabboItem item) { this.items.add(item); } - public HabboItem getItem(int itemId) - { - for (HabboItem item : this.items) - { - if (item.getId() == itemId) - { + public HabboItem getItem(int itemId) { + for (HabboItem item : this.items) { + if (item.getId() == itemId) { return item; } } @@ -79,18 +65,15 @@ public class RoomTradeUser return null; } - public THashSet getItems() - { + public THashSet getItems() { return this.items; } - public void putItemsIntoInventory() - { + public void putItemsIntoInventory() { this.habbo.getInventory().getItemsComponent().addItems(this.items); } - public void clearItems() - { + public void clearItems() { this.items.clear(); } } 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 f6afd05c..b3ed92e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -3,9 +3,6 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; -import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight; -import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; -import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; @@ -23,29 +20,15 @@ import gnu.trove.map.TMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import java.awt.geom.RectangularShape; import java.util.Deque; import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class RoomUnit -{ - private int id; - private RoomTile startLocation; - private RoomTile previousLocation; - private double previousLocationZ; - private RoomTile currentLocation; - private RoomTile goalLocation; - - private double z; - - private int tilesWalked; - - private boolean inRoom; - private boolean canWalk; +public class RoomUnit { + private final ConcurrentHashMap status; + private final THashMap cacheable; public boolean canRotate = true; - private boolean fastWalk = false; public boolean animateWalk = false; public boolean cmdTeleport = false; public boolean cmdSit = false; @@ -54,13 +37,21 @@ public class RoomUnit public boolean isTeleporting = false; public boolean isKicked; public int kickCount = 0; + private int id; + private RoomTile startLocation; + private RoomTile previousLocation; + private double previousLocationZ; + private RoomTile currentLocation; + private RoomTile goalLocation; + private double z; + private int tilesWalked; + private boolean inRoom; + private boolean canWalk; + private boolean fastWalk = false; private boolean statusUpdate = false; private boolean invisible = false; private boolean lastCycleStatus = false; private boolean canLeaveRoomByDoor = true; - - private final ConcurrentHashMap status; - private final THashMap cacheable; private RoomUserRotation bodyRotation = RoomUserRotation.NORTH; private RoomUserRotation headRotation = RoomUserRotation.NORTH; private DanceType danceType; @@ -77,8 +68,7 @@ public class RoomUnit private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private THashSet overridableTiles; - public RoomUnit() - { + public RoomUnit() { this.id = 0; this.inRoom = false; this.canWalk = true; @@ -94,8 +84,7 @@ public class RoomUnit this.overridableTiles = new THashSet<>(); } - public void clearWalking() - { + public void clearWalking() { this.goalLocation = null; this.startLocation = this.currentLocation; this.inRoom = false; @@ -105,34 +94,30 @@ public class RoomUnit this.cacheable.clear(); } - public void stopWalking() - { - synchronized (this.status) - { + public void stopWalking() { + synchronized (this.status) { this.status.remove(RoomUnitStatus.MOVE); this.setGoalLocation(this.currentLocation); } } - public boolean cycle(Room room) - { - try - { + public boolean cycle(Room room) { + try { Habbo rider = null; - if(this.getRoomUnitType() == RoomUnitType.PET) { + if (this.getRoomUnitType() == RoomUnitType.PET) { Pet pet = room.getPet(this); - if(pet instanceof RideablePet) { + if (pet instanceof RideablePet) { rider = ((RideablePet) pet).getRider(); } } - if(rider != null) { + if (rider != null) { // copy things from rider - if(this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) { + if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) { this.status.remove(RoomUnitStatus.MOVE); } - if(rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) { + 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())); this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation()); this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight()); @@ -144,12 +129,10 @@ public class RoomUnit } - if (!this.isWalking() && !this.isKicked) - { - if (this.status.remove(RoomUnitStatus.MOVE) == null) - { + if (!this.isWalking() && !this.isKicked) { + if (this.status.remove(RoomUnitStatus.MOVE) == null) { Habbo habboT = room.getHabbo(this); - if(habboT != null) { + if (habboT != null) { habboT.getHabboInfo().getRiding().getRoomUnit().status.remove(RoomUnitStatus.MOVE); } @@ -161,10 +144,8 @@ public class RoomUnit if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true; - for (Map.Entry set : this.status.entrySet()) - { - if (set.getKey().removeWhenWalking) - { + for (Map.Entry set : this.status.entrySet()) { + if (set.getKey().removeWhenWalking) { this.status.remove(set.getKey()); } } @@ -174,44 +155,38 @@ public class RoomUnit boolean canfastwalk = true; Habbo habboT = room.getHabbo(this); - if(habboT != null) { - if(habboT.getHabboInfo().getRiding() != null) + if (habboT != null) { + if (habboT.getHabboInfo().getRiding() != null) canfastwalk = false; } RoomTile next = this.path.poll(); boolean overrideChecks = next != null && this.canOverrideTile(next); - if (this.path.isEmpty()) - { + if (this.path.isEmpty()) { this.sitUpdate = true; - if (next != null && next.hasUnits() && !overrideChecks) - { + if (next != null && next.hasUnits() && !overrideChecks) { return false; } } Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); - if (peekPath.size() >= 3) - { + if (peekPath.size() >= 3) { path.pop(); //peekPath.pop(); //Start peekPath.removeLast(); //End - if (peekPath.peek() != next) - { + if (peekPath.peek() != next) { next = peekPath.poll(); - for (int i = 0; i < peekPath.size(); i++) - { + for (int i = 0; i < peekPath.size(); i++) { this.path.addFirst(peekPath.removeLast()); } } } - if (canfastwalk && this.fastWalk) - { - if(this.path.size() > 1) { + if (canfastwalk && this.fastWalk) { + if (this.path.size() > 1) { next = this.path.poll(); } } @@ -223,25 +198,20 @@ public class RoomUnit this.status.remove(RoomUnitStatus.DEAD); - if (habbo != null) - { - if (this.isIdle()) - { + if (habbo != null) { + if (this.isIdle()) { UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { room.unIdle(habbo); this.idleTimer = 0; } } } - if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) - { + if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) { Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getX(), this.getY()), next); Emulator.getPluginManager().fireEvent(e); @@ -254,18 +224,14 @@ public class RoomUnit //if(!(this.path.size() == 0 && canSitNextTile)) { - if (!room.tileWalkable(next.x, next.y) && !overrideChecks) - { + if (!room.tileWalkable(next.x, next.y) && !overrideChecks) { this.room = room; this.findPath(); - if (!this.path.isEmpty()) - { + if (!this.path.isEmpty()) { next = this.path.pop(); item = room.getTopItemAt(next.x, next.y); - } - else - { + } else { this.status.remove(RoomUnitStatus.MOVE); return false; } @@ -275,18 +241,15 @@ public class RoomUnit boolean canSitNextTile = room.canSitAt(next.x, next.y); - if (canSitNextTile) - { + if (canSitNextTile) { HabboItem lowestChair = room.getLowestChair(next); if (lowestChair != null) item = lowestChair; } - if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) - { - if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT) - { + if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks) { + if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT) { this.status.remove(RoomUnitStatus.MOVE); return false; } @@ -299,17 +262,14 @@ public class RoomUnit return false; }*/ - if (habbo != null) - { - if (habbo.getHabboInfo().getRiding() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getRiding() != null) { zHeight += 1.0D; } } HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY()); - if (habboItem != null) - { + 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)) habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next}); } @@ -318,16 +278,11 @@ public class RoomUnit RoomUserRotation oldRotation = this.getBodyRotation(); this.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]); - 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)) - { + 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)) { item.onWalkOn(this, room, null); - } - else if (item instanceof InteractionGuildGate) - { + } else if (item instanceof InteractionGuildGate) { this.setRotation(oldRotation); this.tilesWalked--; this.setGoalLocation(this.currentLocation); @@ -335,21 +290,16 @@ public class RoomUnit room.sendComposer(new RoomUserStatusComposer(this).compose()); return false; } - } - else - { + } else { item.onWalk(this, room, null); } zHeight += item.getZ(); - if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) - { + if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { zHeight += Item.getCurrentHeight(item); } - } - else - { + } else { zHeight += room.getLayout().getHeightAtSquare(next.x, next.y); } @@ -357,14 +307,11 @@ public class RoomUnit this.setPreviousLocation(this.getCurrentLocation()); this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight); - if (habbo != null) - { - if (habbo.getHabboInfo().getRiding() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getRiding() != null) { RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit(); - if (ridingUnit != null) - { + 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)]); @@ -382,60 +329,59 @@ public class RoomUnit this.setCurrentLocation(room.getLayout().getTile(next.x, next.y)); this.resetIdleTimer(); - if (habbo != null) - { - if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"))) - { + if (habbo != null) { + if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"))) { Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500); } } return false; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return false; } } - public int getId() - { + + public int getId() { return this.id; } - public void setId(int id) - { + public void setId(int id) { this.id = id; } - public RoomTile getCurrentLocation() - { + public RoomTile getCurrentLocation() { return this.currentLocation; } - public short getX() - { + public void setCurrentLocation(RoomTile location) { + if (location != null) { + if (this.currentLocation != null) { + this.currentLocation.removeUnit(this); + } + this.currentLocation = location; + location.addUnit(this); + } + } + + public short getX() { return this.currentLocation.x; } - public short getY() - { + public short getY() { return this.currentLocation.y; } - public double getZ() - { + public double getZ() { return this.z; } - public void setZ(double z) - { + public void setZ(double z) { this.z = z; } - public boolean isInRoom() - { + public boolean isInRoom() { return this.inRoom; } @@ -451,8 +397,7 @@ public class RoomUnit this.roomUnitType = roomUnitType; } - public void setRotation(RoomUserRotation rotation) - { + public void setRotation(RoomUserRotation rotation) { this.bodyRotation = rotation; this.headRotation = rotation; } @@ -469,13 +414,11 @@ public class RoomUnit return this.headRotation; } - public void setHeadRotation(RoomUserRotation headRotation) - { + public void setHeadRotation(RoomUserRotation headRotation) { this.headRotation = headRotation; } - public DanceType getDanceType() - { + public DanceType getDanceType() { return this.danceType; } @@ -483,56 +426,44 @@ public class RoomUnit this.danceType = danceType; } - public void setCanWalk(boolean value) - { + public void setCanWalk(boolean value) { this.canWalk = value; } - public boolean canWalk() - { + public boolean canWalk() { return this.canWalk; } - public void setFastWalk(boolean fastWalk) - { - this.fastWalk = fastWalk; - } - - public boolean isFastWalk() - { + public boolean isFastWalk() { return this.fastWalk; } - public RoomTile getStartLocation() - { + public void setFastWalk(boolean fastWalk) { + this.fastWalk = fastWalk; + } + + public RoomTile getStartLocation() { return this.startLocation; } - public int tilesWalked() - { + public int tilesWalked() { return this.tilesWalked; } - public RoomTile getGoal() - { + public RoomTile getGoal() { return this.goalLocation; } - public void setGoalLocation(RoomTile goalLocation) - { - if (goalLocation != null) - { - if (goalLocation.state != RoomTileState.INVALID) - { + public void setGoalLocation(RoomTile goalLocation) { + if (goalLocation != null) { + if (goalLocation.state != RoomTileState.INVALID) { this.setGoalLocation(goalLocation, false); } } } - public void setGoalLocation(RoomTile goalLocation, boolean noReset) - { - if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) - { + public void setGoalLocation(RoomTile goalLocation, boolean noReset) { + if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) { Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation); Emulator.getPluginManager().fireEvent(event); @@ -542,269 +473,212 @@ public class RoomUnit this.startLocation = this.currentLocation; - if (goalLocation != null && !noReset) - { + if (goalLocation != null && !noReset) { this.goalLocation = goalLocation; this.findPath(); - if (!this.path.isEmpty()) - { + if (!this.path.isEmpty()) { this.tilesWalked = 0; this.cmdSit = false; - } - else - { + } else { this.goalLocation = this.currentLocation; } } } - public void setLocation(RoomTile location) - { - if (location != null) - { - this.startLocation = location; + public void setLocation(RoomTile location) { + if (location != null) { + this.startLocation = location; setPreviousLocation(location); setCurrentLocation(location); - this.goalLocation = location; + this.goalLocation = location; } } - public void setCurrentLocation(RoomTile location) - { - if (location != null) - { - if(this.currentLocation != null) { - this.currentLocation.removeUnit(this); - } - this.currentLocation = location; - location.addUnit(this); - } - } - - public RoomTile getPreviousLocation() - { + public RoomTile getPreviousLocation() { return this.previousLocation; } - public double getPreviousLocationZ() - { - return this.previousLocationZ; - } - - public void setPreviousLocationZ(double z) - { - this.previousLocationZ = z; - } - - public void setPreviousLocation(RoomTile previousLocation) - { + public void setPreviousLocation(RoomTile previousLocation) { this.previousLocation = previousLocation; this.previousLocationZ = this.z; } - public void setPathFinderRoom(Room room) - { + public double getPreviousLocationZ() { + return this.previousLocationZ; + } + + public void setPreviousLocationZ(double z) { + this.previousLocationZ = z; + } + + public void setPathFinderRoom(Room room) { this.room = room; } - 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))) - { + 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))) { this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); } } - public void setPath(Deque path) - { - this.path = path; - } - - public boolean isAtGoal() - { + public boolean isAtGoal() { return this.currentLocation.equals(this.goalLocation); } - public boolean isWalking() - { + public boolean isWalking() { return !this.isAtGoal() && this.canWalk; } - public String getStatus(RoomUnitStatus key) - { + public String getStatus(RoomUnitStatus key) { return this.status.get(key); } - public ConcurrentHashMap getStatusMap() - { + public ConcurrentHashMap getStatusMap() { return this.status; } - public void removeStatus(RoomUnitStatus key) - { + public void removeStatus(RoomUnitStatus key) { this.status.remove(key); } - public void setStatus(RoomUnitStatus key, String value) - { - if (key != null && value != null) - { + public void setStatus(RoomUnitStatus key, String value) { + if (key != null && value != null) { this.status.put(key, value); } } - public boolean hasStatus(RoomUnitStatus key) - { + public boolean hasStatus(RoomUnitStatus key) { return this.status.containsKey(key); } - public void clearStatus() - { + public void clearStatus() { this.status.clear(); } - public void statusUpdate(boolean update) - { + public void statusUpdate(boolean update) { this.statusUpdate = update; } - public boolean needsStatusUpdate() - { + public boolean needsStatusUpdate() { return this.statusUpdate; } - public TMap getCacheable() - { + public TMap getCacheable() { return this.cacheable; } - public int getHandItem() - { + public int getHandItem() { return this.handItem; } - public void setHandItem(int handItem) - { + public void setHandItem(int handItem) { this.handItem = handItem; this.handItemTimestamp = System.currentTimeMillis(); } - public long getHandItemTimestamp() - { + public long getHandItemTimestamp() { return this.handItemTimestamp; } - public int getEffectId() - { + public int getEffectId() { return this.effectId; } - public void setEffectId(int effectId, int endTimestamp) - { + public void setEffectId(int effectId, int endTimestamp) { this.effectId = effectId; this.effectEndTimestamp = endTimestamp; } - public int getEffectEndTimestamp() - { + public int getEffectEndTimestamp() { return this.effectEndTimestamp; } - public int getWalkTimeOut() - { + public int getWalkTimeOut() { return this.walkTimeOut; } - public void setWalkTimeOut(int walkTimeOut) - { + public void setWalkTimeOut(int walkTimeOut) { this.walkTimeOut = walkTimeOut; } - public void increaseIdleTimer() - { + public void increaseIdleTimer() { this.idleTimer++; } - public boolean isIdle() - { + public boolean isIdle() { return this.idleTimer > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds. } - public int getIdleTimer() - { + public int getIdleTimer() { return this.idleTimer; } - public void resetIdleTimer() - { + public void resetIdleTimer() { this.idleTimer = 0; } - public void setIdle() - { + public void setIdle() { this.idleTimer = Room.IDLE_CYCLES + 1; } - public void lookAtPoint(RoomTile location) - { + public void lookAtPoint(RoomTile location) { if (!this.canRotate) return; - if(Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) - { + if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) { Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location); Emulator.getPluginManager().fireEvent(lookAtPointEvent); - if(lookAtPointEvent.isCancelled()) + if (lookAtPointEvent.isCancelled()) return; } - if (this.status.containsKey(RoomUnitStatus.LAY)) - { + if (this.status.containsKey(RoomUnitStatus.LAY)) { return; } - if (!this.status.containsKey(RoomUnitStatus.SIT)) - { + if (!this.status.containsKey(RoomUnitStatus.SIT)) { this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); } RoomUserRotation rotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); - if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) - { + if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) { this.headRotation = rotation; } } - public Deque getPath() - { + public Deque getPath() { return this.path; } - public RoomRightLevels getRightsLevel() - { + public void setPath(Deque path) { + this.path = path; + } + + public RoomRightLevels getRightsLevel() { return this.rightsLevel; } - public void setRightsLevel(RoomRightLevels rightsLevel) - { + public void setRightsLevel(RoomRightLevels rightsLevel) { this.rightsLevel = rightsLevel; } - public void setInvisible(boolean invisible) - { - this.invisible = invisible; + public boolean isInvisible() { + return this.invisible; } - public boolean isInvisible() - { - return this.invisible; + public void setInvisible(boolean invisible) { + this.invisible = invisible; } public Room getRoom() { return room; } + public void setRoom(Room room) { + this.room = room; + } + public boolean canOverrideTile(RoomTile tile) { if (tile == null || room == null || room.getLayout() == null) return false; @@ -814,7 +688,7 @@ public class RoomUnit public void addOverrideTile(RoomTile tile) { int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1; - if(!this.overridableTiles.contains(tileIndex)) { + if (!this.overridableTiles.contains(tileIndex)) { this.overridableTiles.add(tileIndex); } } @@ -835,8 +709,4 @@ public class RoomUnit public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) { this.canLeaveRoomByDoor = canLeaveRoomByDoor; } - - public void setRoom(Room room) { - this.room = room; - } } 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 0789d712..5ae0885e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomUnitEffect -{ +public enum RoomUnitEffect { //(\w+)\s(\w+)\s(\w+) //\2\(\1\), NONE(0), @@ -202,26 +201,22 @@ public enum RoomUnitEffect CROSSTRAINER(195); private int id; - RoomUnitEffect(int id) - { + + RoomUnitEffect(int id) { this.id = id; } - public int getId() - { - return this.id; - } - - public static RoomUnitEffect fromId(int id) - { - for (RoomUnitEffect effect : RoomUnitEffect.values()) - { - if (effect.id == id) - { + public static RoomUnitEffect fromId(int id) { + for (RoomUnitEffect effect : RoomUnitEffect.values()) { + if (effect.id == id) { return effect; } } 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 44d2b002..7ca637b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomUnitStatus -{ +public enum RoomUnitStatus { MOVE("mv", true), SIT("sit", true), LAY("lay", true), @@ -41,34 +40,28 @@ public enum RoomUnitStatus public final String key; public final boolean removeWhenWalking; - RoomUnitStatus(String key) - { + RoomUnitStatus(String key) { this.key = key; this.removeWhenWalking = false; } - RoomUnitStatus(String key, boolean removeWhenWalking) - { + RoomUnitStatus(String key, boolean removeWhenWalking) { this.key = key; this.removeWhenWalking = removeWhenWalking; } - @Override - public String toString() - { - return this.key; - } - - public static RoomUnitStatus fromString(String key) - { - for (RoomUnitStatus status : values()) - { - if (status.key.equalsIgnoreCase(key)) - { + public static RoomUnitStatus fromString(String key) { + for (RoomUnitStatus status : values()) { + if (status.key.equalsIgnoreCase(key)) { return status; } } return null; } + + @Override + public String toString() { + return this.key; + } } 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 f6efe8bc..83d39029 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomUnitType -{ +public enum RoomUnitType { USER(1), BOT(4), PET(2), @@ -9,13 +8,11 @@ public enum RoomUnitType private final int typeId; - RoomUnitType(int typeId) - { + RoomUnitType(int typeId) { this.typeId = typeId; } - public int getTypeId() - { + 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 52b672a9..03f257b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserAction.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomUserAction -{ +public enum RoomUserAction { NONE(0), WAVE(1), BLOW_KISS(2), @@ -12,26 +11,22 @@ public enum RoomUserAction THUMB_UP(7); private final int action; - RoomUserAction(int action) - { + + RoomUserAction(int action) { this.action = action; } - public int getAction() - { - return this.action; - } - - public static RoomUserAction fromValue(int value) - { - for (RoomUserAction action : RoomUserAction.values()) - { - if (action.getAction() == value) - { + public static RoomUserAction fromValue(int value) { + for (RoomUserAction action : RoomUserAction.values()) { + if (action.getAction() == value) { return action; } } 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 e2f10a01..11f9f775 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.rooms; -public enum RoomUserRotation -{ +public enum RoomUserRotation { NORTH(0), NORTH_EAST(1), EAST(2), @@ -13,13 +12,30 @@ public enum RoomUserRotation private final int direction; - RoomUserRotation(int direction) - { + RoomUserRotation(int direction) { this.direction = direction; } - public int getValue() - { + public static RoomUserRotation fromValue(int rotation) { + rotation %= 8; + for (RoomUserRotation rot : values()) { + if (rot.getValue() == rotation) { + return rot; + } + } + + return NORTH; + } + + public static RoomUserRotation counterClockwise(RoomUserRotation rotation) { + return fromValue(rotation.getValue() + 7); + } + + public static RoomUserRotation clockwise(RoomUserRotation rotation) { + return fromValue(rotation.getValue() + 9); + } + + public int getValue() { return this.direction; } @@ -44,28 +60,4 @@ public enum RoomUserRotation } return null; } - - public static RoomUserRotation fromValue(int rotation) - { - rotation %= 8; - for (RoomUserRotation rot : values()) - { - if (rot.getValue() == rotation) - { - return rot; - } - } - - return NORTH; - } - - public static RoomUserRotation counterClockwise(RoomUserRotation rotation) - { - return fromValue(rotation.getValue() + 7); - } - - public static RoomUserRotation clockwise(RoomUserRotation rotation) - { - return fromValue(rotation.getValue() + 9); - } } 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 db20caac..075ce283 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -19,8 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class TraxManager implements Disposable -{ +public class TraxManager implements Disposable { private final Room room; private final List songs = new ArrayList<>(0); private int totalLength = 0; @@ -32,78 +31,60 @@ public class TraxManager implements Disposable private boolean disposed = false; - public TraxManager(Room room) - { + public TraxManager(Room room) { this.room = room; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_trax_playlist WHERE room_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_trax_playlist WHERE room_id = ?")) { statement.setInt(1, this.room.getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { HabboItem musicDisc = this.room.getHabboItem(set.getInt("item_id")); - if (musicDisc instanceof InteractionMusicDisc) - { + if (musicDisc instanceof InteractionMusicDisc) { SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); - if (track != null) - { + if (track != null) { this.songs.add((InteractionMusicDisc) musicDisc); this.totalLength += track.getLength(); } } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void cycle() - { - if (this.isPlaying()) - { - if (this.timePlaying() >= this.totalLength) - { + public void cycle() { + if (this.isPlaying()) { + if (this.timePlaying() >= this.totalLength) { this.play(0); //restart } - if (this.currentSong() != null && Emulator.getIntUnixTimestamp() >= this.startedTimestamp + this.currentSong().getLength()) - { + if (this.currentSong() != null && Emulator.getIntUnixTimestamp() >= this.startedTimestamp + this.currentSong().getLength()) { this.play((this.playingIndex + 1) % this.songs.size()); } } } - public void play(int index) - { + public void play(int index) { this.play(index, null); } - public void play(int index, Habbo starter) - { - if (this.currentlyPlaying == null) - { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) - { + public void play(int index, Habbo starter) { + if (this.currentlyPlaying == null) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) { item.setExtradata("1"); this.room.updateItem(item); } } - if (!this.songs.isEmpty()) - { + if (!this.songs.isEmpty()) { index = index % this.songs.size(); this.currentlyPlaying = this.songs.get(index); - if (this.currentlyPlaying != null) - { + if (this.currentlyPlaying != null) { this.room.setJukeBoxActive(true); this.startedTimestamp = Emulator.getIntUnixTimestamp(); this.playingIndex = index; @@ -115,15 +96,12 @@ public class TraxManager implements Disposable } this.room.sendComposer(new JukeBoxNowPlayingMessageComposer(Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.currentlyPlaying.getSongId()), this.playingIndex, 0).compose()); - } - else - { + } else { this.stop(); } } - public void stop() - { + public void stop() { if (this.starter != null && this.cycleStartedTimestamp > 0) { AchievementManager.progressAchievement(this.starter, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicPlayer"), (Emulator.getIntUnixTimestamp() - cycleStartedTimestamp) / 60); } @@ -135,8 +113,7 @@ public class TraxManager implements Disposable this.starter = null; this.playingIndex = 0; - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) { item.setExtradata("0"); this.room.updateItem(item); } @@ -144,36 +121,28 @@ public class TraxManager implements Disposable this.room.sendComposer(new JukeBoxNowPlayingMessageComposer(null, -1, 0).compose()); } - public SoundTrack currentSong() - { - if (!this.songs.isEmpty() && this.playingIndex < this.songs.size()) - { + public SoundTrack currentSong() { + if (!this.songs.isEmpty() && this.playingIndex < this.songs.size()) { return Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.songs.get(this.playingIndex).getSongId()); } return null; } - public void addSong(int itemId) - { + public void addSong(int itemId) { HabboItem musicDisc = this.room.getHabboItem(itemId); - if (musicDisc instanceof InteractionMusicDisc) - { + if (musicDisc instanceof InteractionMusicDisc) { SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); - if (track != null) - { + if (track != null) { this.totalLength += track.getLength(); this.songs.add((InteractionMusicDisc) musicDisc); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) { statement.setInt(1, this.room.getId()); statement.setInt(2, itemId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); return; } @@ -184,29 +153,23 @@ public class TraxManager implements Disposable } } - public void removeSong(int itemId) - { + public void removeSong(int itemId) { InteractionMusicDisc musicDisc = this.fromItemId(itemId); - if (musicDisc != null) - { + if (musicDisc != null) { this.songs.remove(musicDisc); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) { statement.setInt(1, this.room.getId()); statement.setInt(2, itemId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); return; } this.totalLength -= Emulator.getGameEnvironment().getItemManager().getSoundTrack(musicDisc.getSongId()).getLength(); - if (this.currentlyPlaying == musicDisc) - { + if (this.currentlyPlaying == musicDisc) { this.play(this.playingIndex); } @@ -215,36 +178,29 @@ public class TraxManager implements Disposable this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose()); } - public int timePlaying() - { + public int timePlaying() { return Emulator.getIntUnixTimestamp() - this.startedTimestamp; } - public int totalLength() - { + public int totalLength() { return this.totalLength; } - public List getSongs() - { + public List getSongs() { return this.songs; } - public boolean isPlaying() - { + public boolean isPlaying() { return this.currentlyPlaying != null; } - public List soundTrackList() - { + public List soundTrackList() { List trax = new ArrayList<>(this.songs.size()); - for (InteractionMusicDisc musicDisc : this.songs) - { + for (InteractionMusicDisc musicDisc : this.songs) { SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(musicDisc.getSongId()); - if (track != null) - { + if (track != null) { trax.add(track); } } @@ -252,14 +208,11 @@ public class TraxManager implements Disposable return trax; } - public List myList() - { + public List myList() { List trax = new ArrayList<>(); - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionMusicDisc.class)) - { - if (!this.songs.contains(item)) - { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionMusicDisc.class)) { + if (!this.songs.contains(item)) { trax.add((InteractionMusicDisc) item); } } @@ -267,12 +220,9 @@ public class TraxManager implements Disposable return trax; } - public InteractionMusicDisc fromItemId(int itemId) - { - for (InteractionMusicDisc musicDisc : this.songs) - { - if (musicDisc.getId() == itemId) - { + public InteractionMusicDisc fromItemId(int itemId) { + for (InteractionMusicDisc musicDisc : this.songs) { + if (musicDisc.getId() == itemId) { return musicDisc; } } @@ -280,41 +230,31 @@ public class TraxManager implements Disposable return null; } - public void clearPlayList() - { + public void clearPlayList() { this.songs.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ?")) { statement.setInt(1, this.room.getId()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void updateCurrentPlayingSong(Habbo habbo) - { - if (this.isPlaying()) - { + public void updateCurrentPlayingSong(Habbo habbo) { + if (this.isPlaying()) { habbo.getClient().sendResponse(new JukeBoxNowPlayingMessageComposer(Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.currentlyPlaying.getSongId()), this.playingIndex, 1000 * (Emulator.getIntUnixTimestamp() - this.startedTimestamp))); - } - else - { + } else { habbo.getClient().sendResponse(new JukeBoxNowPlayingMessageComposer(null, -1, 0)); } } @Override - public void dispose() - { + public void dispose() { this.disposed = true; } @Override - public boolean disposed() - { + public boolean disposed() { return this.disposed; } } 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 c0f5e08e..45097b6d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/DanceType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.users; -public enum DanceType -{ +public enum DanceType { NONE(0), HAB_HOP(1), POGO_MOGO(2), @@ -10,13 +9,11 @@ public enum DanceType private final int type; - DanceType(int type) - { + DanceType(int type) { this.type = type; } - public int getType() - { + 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 f5c3a2fb..84396d67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -25,24 +25,20 @@ import java.net.InetSocketAddress; import java.sql.ResultSet; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class Habbo implements Runnable -{ - private GameClient client; +public class Habbo implements Runnable { private final HabboInfo habboInfo; private final HabboStats habboStats; private final Messenger messenger; private final HabboInventory habboInventory; + private GameClient client; private RoomUnit roomUnit; private volatile boolean update; private volatile boolean disconnected = false; private volatile boolean disconnecting = false; - public Habbo(ResultSet set) - { + public Habbo(ResultSet set) { this.client = null; this.habboInfo = new HabboInfo(set); this.habboStats = HabboStats.load(this.habboInfo); @@ -57,78 +53,63 @@ public class Habbo implements Runnable this.update = false; } - public boolean isOnline() - { + public boolean isOnline() { return this.habboInfo.isOnline(); } - void isOnline(boolean value) - { + void isOnline(boolean value) { this.habboInfo.setOnline(value); this.update(); } - void update() - { + void update() { this.update = true; this.run(); } - void needsUpdate(boolean value) - { + void needsUpdate(boolean value) { this.update = value; } - boolean needsUpdate() - { + boolean needsUpdate() { return this.update; } - public Messenger getMessenger() - { + public Messenger getMessenger() { return this.messenger; } - public HabboInfo getHabboInfo() - { + public HabboInfo getHabboInfo() { return this.habboInfo; } - public HabboStats getHabboStats() - { + public HabboStats getHabboStats() { return this.habboStats; } - public HabboInventory getInventory() - { + public HabboInventory getInventory() { return this.habboInventory; } - public RoomUnit getRoomUnit() - { + public RoomUnit getRoomUnit() { return this.roomUnit; } - public void setRoomUnit(RoomUnit roomUnit) - { + public void setRoomUnit(RoomUnit roomUnit) { this.roomUnit = roomUnit; } - public GameClient getClient() - { + public GameClient getClient() { return this.client; } - public void setClient(GameClient client) - { + public void setClient(GameClient client) { this.client = client; } - public void connect() - { - if (!Emulator.getConfig().getBoolean("networking.tcp.proxy")) - { + public void connect() { + if (!Emulator.getConfig().getBoolean("networking.tcp.proxy")) { this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress()); } @@ -142,11 +123,9 @@ public class Habbo implements Runnable } - public synchronized void disconnect() - { - if (!Emulator.isShuttingDown) - { - if(Emulator.getPluginManager().fireEvent(new UserDisconnectEvent(this)).isCancelled()) return; + public synchronized void disconnect() { + if (!Emulator.isShuttingDown) { + if (Emulator.getPluginManager().fireEvent(new UserDisconnectEvent(this)).isCancelled()) return; } if (this.disconnected || this.disconnecting) @@ -154,28 +133,22 @@ public class Habbo implements Runnable this.disconnecting = true; - try - { - if (this.getHabboInfo().getCurrentRoom() != null) - { + try { + if (this.getHabboInfo().getCurrentRoom() != null) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(this, this.getHabboInfo().getCurrentRoom()); } - if (this.getHabboInfo().getRoomQueueId() > 0) - { + if (this.getHabboInfo().getRoomQueueId() > 0) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getHabboInfo().getRoomQueueId()); - if (room != null) - { + if (room != null) { room.removeFromQueue(this); } } - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { Emulator.getGameEnvironment().getGuideManager().userLogsOut(this); this.isOnline(false); this.needsUpdate(true); @@ -187,12 +160,10 @@ public class Habbo implements Runnable AchievementManager.saveAchievements(this); this.habboStats.dispose(); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return; - } finally - { + } finally { Emulator.getGameEnvironment().getRoomManager().unloadRoomsForHabbo(this); Emulator.getGameEnvironment().getHabboManager().removeHabbo(this); } @@ -201,30 +172,25 @@ public class Habbo implements Runnable } @Override - public void run() - { - if (this.needsUpdate()) - { + public void run() { + if (this.needsUpdate()) { this.habboInfo.run(); this.needsUpdate(false); } } - public boolean hasPermission(String key) - { + public boolean hasPermission(String key) { return this.hasPermission(key, false); } - public boolean hasPermission(String key, boolean hasRoomRights) - { + public boolean hasPermission(String key, boolean hasRoomRights) { return Emulator.getGameEnvironment().getPermissionsManager().hasPermission(this, key, hasRoomRights); } - public void giveCredits(int credits) - { + public void giveCredits(int credits) { if (credits == 0) return; @@ -237,8 +203,7 @@ public class Habbo implements Runnable } - public void givePixels(int pixels) - { + public void givePixels(int pixels) { if (pixels == 0) return; @@ -252,14 +217,12 @@ public class Habbo implements Runnable } - public void givePoints(int points) - { + public void givePoints(int points) { this.givePoints(Emulator.getConfig().getInt("seasonal.primary.type"), points); } - public void givePoints(int type, int points) - { + public void givePoints(int type, int points) { if (points == 0) return; @@ -272,145 +235,119 @@ public class Habbo implements Runnable } - public void whisper(String message) - { + public void whisper(String message) { this.whisper(message, this.habboStats.chatColor); } - public void whisper(String message, RoomChatMessageBubbles bubble) - { - if (this.getRoomUnit().isInRoom()) - { + public void whisper(String message, RoomChatMessageBubbles bubble) { + if (this.getRoomUnit().isInRoom()) { this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble))); } } - public void talk(String message) - { + public void talk(String message) { this.talk(message, this.habboStats.chatColor); } - public void talk(String message, RoomChatMessageBubbles bubble) - { - if (this.getRoomUnit().isInRoom()) - { + public void talk(String message, RoomChatMessageBubbles bubble) { + if (this.getRoomUnit().isInRoom()) { this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTalkComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); } } - public void shout(String message) - { + public void shout(String message) { this.shout(message, this.habboStats.chatColor); } - public void shout(String message, RoomChatMessageBubbles bubble) - { - if (this.getRoomUnit().isInRoom()) - { + public void shout(String message, RoomChatMessageBubbles bubble) { + if (this.getRoomUnit().isInRoom()) { this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserShoutComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); } } - public void alert(String message) - { - if (Emulator.getConfig().getBoolean("hotel.alert.oldstyle")) - { + public void alert(String message) { + if (Emulator.getConfig().getBoolean("hotel.alert.oldstyle")) { this.client.sendResponse(new MessagesForYouComposer(new String[]{message})); - } - else - { + } else { this.client.sendResponse(new GenericAlertComposer(message)); } } - public void alert(String[] messages) - { + public void alert(String[] messages) { this.client.sendResponse(new MessagesForYouComposer(messages)); } - public void alertWithUrl(String message, String url) - { + public void alertWithUrl(String message, String url) { this.client.sendResponse(new StaffAlertWithLinkComposer(message, url)); } - public void goToRoom(int id) - { + public void goToRoom(int id) { this.client.sendResponse(new ForwardToRoomComposer(id)); } - public void addFurniture(HabboItem item) - { + public void addFurniture(HabboItem item) { this.habboInventory.getItemsComponent().addItem(item); this.client.sendResponse(new AddHabboItemComposer(item)); this.client.sendResponse(new InventoryRefreshComposer()); } - public void addFurniture(THashSet items) - { + public void addFurniture(THashSet items) { this.habboInventory.getItemsComponent().addItems(items); this.client.sendResponse(new AddHabboItemComposer(items)); this.client.sendResponse(new InventoryRefreshComposer()); } - public void removeFurniture(HabboItem item) - { + public void removeFurniture(HabboItem item) { this.habboInventory.getItemsComponent().removeHabboItem(item); this.client.sendResponse(new RemoveHabboItemComposer(item.getId())); } - public void addBot(Bot bot) - { + public void addBot(Bot bot) { this.habboInventory.getBotsComponent().addBot(bot); this.client.sendResponse(new AddBotComposer(bot)); } - public void removeBot(Bot bot) - { + public void removeBot(Bot bot) { this.habboInventory.getBotsComponent().removeBot(bot); this.client.sendResponse(new RemoveBotComposer(bot)); } - public void deleteBot(Bot bot) - { + public void deleteBot(Bot bot) { this.removeBot(bot); bot.getRoom().removeBot(bot); Emulator.getGameEnvironment().getBotManager().deleteBot(bot); } - public void addPet(Pet pet) - { + public void addPet(Pet pet) { this.habboInventory.getPetsComponent().addPet(pet); this.client.sendResponse(new AddPetComposer(pet)); } - public void removePet(Pet pet) - { + public void removePet(Pet pet) { this.habboInventory.getPetsComponent().removePet(pet); this.client.sendResponse(new RemovePetComposer(pet)); } - public boolean addBadge(String code) - { - if (this.habboInventory.getBadgesComponent().getBadge(code) == null) - { + public boolean addBadge(String code) { + if (this.habboInventory.getBadgesComponent().getBadge(code) == null) { HabboBadge badge = BadgesComponent.createBadge(code, this); this.habboInventory.getBadgesComponent().addBadge(badge); this.client.sendResponse(new AddUserBadgeComposer(badge)); @@ -429,62 +366,49 @@ public class Habbo implements Runnable } - public void deleteBadge(HabboBadge badge) - { - if (badge != null) - { + public void deleteBadge(HabboBadge badge) { + if (badge != null) { this.habboInventory.getBadgesComponent().removeBadge(badge); BadgesComponent.deleteBadge(this.getHabboInfo().getId(), badge.getCode()); this.client.sendResponse(new InventoryBadgesComposer(this)); } } - public void mute(int seconds) - { - if (!this.hasPermission("acc_no_mute")) - { + public void mute(int seconds) { + if (!this.hasPermission("acc_no_mute")) { int remaining = this.habboStats.addMuteTime(seconds); this.client.sendResponse(new FloodCounterComposer(remaining)); this.client.sendResponse(new MutedWhisperComposer(remaining)); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.MUTED).compose()); } } } - public void unMute() - { + public void unMute() { this.habboStats.unMute(); this.client.sendResponse(new FloodCounterComposer(3)); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.UNIGNORED).compose()); } } - public int noobStatus() - { + public int noobStatus() { - return 1; + return 1; } - public void clearCaches() - { + public void clearCaches() { int timestamp = Emulator.getIntUnixTimestamp(); THashMap> newLog = new THashMap<>(); - for (Map.Entry> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) - { - for (Integer time : ltdLog.getValue()) - { - if (time > timestamp) - { - if (!newLog.containsKey(ltdLog.getKey())) - { + for (Map.Entry> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) { + for (Integer time : ltdLog.getValue()) { + if (time > timestamp) { + if (!newLog.containsKey(ltdLog.getKey())) { newLog.put(ltdLog.getKey(), new ArrayList<>()); } @@ -497,9 +421,8 @@ public class Habbo implements Runnable } - public void respect(Habbo target) - { - if(target != null && target != this.client.getHabbo()) + public void respect(Habbo target) { + if (target != null && target != this.client.getHabbo()) { target.getHabboStats().respectPointsReceived++; 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 300dea99..197f535e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -4,8 +4,7 @@ import com.eu.habbo.Emulator; import java.sql.*; -public class HabboBadge implements Runnable -{ +public class HabboBadge implements Runnable { private int id; private String code; private int slot; @@ -13,8 +12,7 @@ public class HabboBadge implements Runnable private boolean needsUpdate; private boolean needsInsert; - public HabboBadge(ResultSet set, Habbo habbo) throws SQLException - { + public HabboBadge(ResultSet set, Habbo habbo) throws SQLException { this.id = set.getInt("id"); this.code = set.getString("badge_code"); this.slot = set.getInt("slot_id"); @@ -23,8 +21,7 @@ public class HabboBadge implements Runnable this.needsInsert = false; } - public HabboBadge(int id, String code, int slot, Habbo habbo) - { + public HabboBadge(int id, String code, int slot, Habbo habbo) { this.id = id; this.code = code; this.slot = slot; @@ -33,58 +30,44 @@ public class HabboBadge implements Runnable this.needsInsert = true; } - public int getId() - { + public int getId() { return this.id; } - public String getCode() - { + public String getCode() { return this.code; } - public void setCode(String code) - { + public void setCode(String code) { this.code = code; } - public void setSlot(int slot) - { - this.slot = slot; - } - - public int getSlot() - { + public int getSlot() { return this.slot; } + public void setSlot(int slot) { + this.slot = slot; + } + @Override - public void run() - { - try - { - if(this.needsInsert) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, slot_id, badge_code) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + public void run() { + try { + if (this.needsInsert) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, slot_id, badge_code) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.habbo.getHabboInfo().getId()); statement.setInt(2, this.slot); statement.setString(3, this.code); statement.execute(); - try (ResultSet set = statement.getGeneratedKeys()) - { - if (set.next()) - { + try (ResultSet set = statement.getGeneratedKeys()) { + if (set.next()) { this.id = set.getInt(1); } } } this.needsInsert = false; - } - else if(this.needsUpdate) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_badges SET slot_id = ?, badge_code = ? WHERE id = ? AND user_id = ?")) - { + } else if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_badges SET slot_id = ?, badge_code = ? WHERE id = ? AND user_id = ?")) { statement.setInt(1, this.slot); statement.setString(2, this.code); statement.setInt(3, this.id); @@ -93,20 +76,16 @@ public class HabboBadge implements Runnable } this.needsUpdate = false; } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void needsUpdate(boolean needsUpdate) - { + public void needsUpdate(boolean needsUpdate) { this.needsUpdate = needsUpdate; } - public void needsInsert(boolean needsInsert) - { + public void needsInsert(boolean needsInsert) { this.needsInsert = needsInsert; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboGender.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboGender.java index 4a31b81b..c72c45c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboGender.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboGender.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.users; -public enum HabboGender -{ +public enum HabboGender { M, F } 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 4c5cfef1..609b487a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.permissions.Rank; -import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; 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.messages.outgoing.rooms.users.RoomUserStatusComposer; -import com.eu.habbo.threading.runnables.RoomUnitRidePet; -import com.eu.habbo.util.figure.FigureUtil; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.procedure.TIntIntProcedure; @@ -24,8 +21,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class HabboInfo implements Runnable -{ +public class HabboInfo implements Runnable { + public boolean firstVisit = false; private String username; private String motto; private String look; @@ -34,39 +31,29 @@ public class HabboInfo implements Runnable private String sso; private String ipRegister; private String ipLogin; - private int id; private int accountCreated; private Rank rank; - private int credits; private int lastOnline; - private int homeRoom; - private boolean online; private int loadingRoom; private Room currentRoom; private int roomQueueId; - private RideablePet riding; - private Class currentGame; private TIntIntHashMap currencies; private GamePlayer gamePlayer; - private int photoRoomId; private int photoTimestamp; private String photoURL; private String photoJSON; private int webPublishTimestamp; private String machineID; - public boolean firstVisit = false; - public HabboInfo(ResultSet set) - { - try - { + public HabboInfo(ResultSet set) { + try { this.id = set.getInt("id"); this.username = set.getString("username"); this.motto = set.getString("motto"); @@ -78,8 +65,7 @@ public class HabboInfo implements Runnable this.ipLogin = set.getString("ip_current"); this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(set.getInt("rank")); - if (this.rank == null) - { + if (this.rank == null) { Emulator.getLogging().logErrorLine("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); Emulator.getLogging().logUserLine(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(1); @@ -92,127 +78,98 @@ public class HabboInfo implements Runnable this.machineID = set.getString("machine_id"); this.online = false; this.currentRoom = null; - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } this.loadCurrencies(); } - private void loadCurrencies() - { + private void loadCurrencies() { this.currencies = new TIntIntHashMap(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_currency WHERE user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_currency WHERE user_id = ?")) { statement.setInt(1, this.id); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.currencies.put(set.getInt("type"), set.getInt("amount")); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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() - { + 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 - { + 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) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return true; } }); statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public int getCurrencyAmount(int type) - { + public int getCurrencyAmount(int type) { return this.currencies.get(type); } - public TIntIntHashMap getCurrencies() - { + public TIntIntHashMap getCurrencies() { return this.currencies; } - public void addCurrencyAmount(int type, int amount) - { + public void addCurrencyAmount(int type, int amount) { this.currencies.adjustOrPutValue(type, amount, amount); this.run(); } - public void setCurrencyAmount(int type, int amount) - { + public void setCurrencyAmount(int type, int amount) { this.currencies.put(type, amount); this.run(); } - public int getId() - { + public int getId() { return this.id; } - public String getUsername() - { + public String getUsername() { return this.username; } - public void setUsername(String username) - { + public void setUsername(String username) { this.username = username; } - public String getMotto() - { + public String getMotto() { return this.motto; } - public void setMotto(String motto) - { + public void setMotto(String motto) { this.motto = motto; } - public Rank getRank() - { + public Rank getRank() { return this.rank; } - public void setRank(Rank rank) - { + public void setRank(Rank rank) { this.rank = rank; } - public String getLook() - { + public String getLook() { return this.look; } @@ -220,8 +177,7 @@ public class HabboInfo implements Runnable this.look = look; } - public HabboGender getGender() - { + public HabboGender getGender() { return this.gender; } @@ -253,18 +209,15 @@ public class HabboInfo implements Runnable this.ipRegister = ipRegister; } - public String getIpLogin() - { + public String getIpLogin() { return this.ipLogin; } - public void setIpLogin(String ipLogin) - { + public void setIpLogin(String ipLogin) { this.ipLogin = ipLogin; } - public int getAccountCreated() - { + public int getAccountCreated() { return this.accountCreated; } @@ -272,120 +225,104 @@ public class HabboInfo implements Runnable this.accountCreated = accountCreated; } - public boolean canBuy(CatalogItem item) - { + public boolean canBuy(CatalogItem item) { return this.credits >= item.getCredits() && this.getCurrencies().get(item.getPointsType()) >= item.getPoints(); } - public int getCredits() - { + public int getCredits() { return this.credits; } - public void setCredits(int credits) - { + public void setCredits(int credits) { this.credits = credits; this.run(); } - public void addCredits(int credits) - { + public void addCredits(int credits) { this.credits += credits; this.run(); } - public int getPixels() - { + public int getPixels() { return this.getCurrencyAmount(0); } - public void setPixels(int pixels) - { + public void setPixels(int pixels) { this.setCurrencyAmount(0, pixels); this.run(); } - public void addPixels(int pixels) - { + public void addPixels(int pixels) { this.addCurrencyAmount(0, pixels); this.run(); } - public int getLastOnline() - { + public int getLastOnline() { return this.lastOnline; } - public void setLastOnline(int lastOnline) - { + public void setLastOnline(int lastOnline) { this.lastOnline = lastOnline; } - public int getHomeRoom() - { + public int getHomeRoom() { return this.homeRoom; } - public void setHomeRoom(int homeRoom) - { + public void setHomeRoom(int homeRoom) { this.homeRoom = homeRoom; } - public boolean isOnline() - { + public boolean isOnline() { return this.online; } - public void setOnline(boolean value) - { + public void setOnline(boolean value) { this.online = value; } - public int getLoadingRoom() - { + public int getLoadingRoom() { return this.loadingRoom; } - public void setLoadingRoom(int loadingRoom) - { + public void setLoadingRoom(int loadingRoom) { this.loadingRoom = loadingRoom; } - public Room getCurrentRoom() - { + public Room getCurrentRoom() { return this.currentRoom; } - public void setCurrentRoom(Room room) - { + public void setCurrentRoom(Room room) { this.currentRoom = room; } - public int getRoomQueueId() - { + public int getRoomQueueId() { return this.roomQueueId; } - public void setRoomQueueId(int roomQueueId) - { + public void setRoomQueueId(int roomQueueId) { this.roomQueueId = roomQueueId; } - public RideablePet getRiding() - { + public RideablePet getRiding() { return this.riding; } + public void setRiding(RideablePet riding) { + this.riding = riding; + } + public void dismountPet() { this.dismountPet(false); } public void dismountPet(boolean isRemoving) { - if(this.getRiding() == null) + if (this.getRiding() == null) return; Habbo habbo = this.getCurrentRoom().getHabbo(this.getId()); - if(habbo == null) + if (habbo == null) return; RideablePet riding = this.getRiding(); @@ -395,11 +332,11 @@ public class HabboInfo implements Runnable this.setRiding(null); Room room = this.getCurrentRoom(); - if(room != null) + if (room != null) room.giveEffect(habbo, 0, -1); RoomUnit roomUnit = habbo.getRoomUnit(); - if(roomUnit == null) + if (roomUnit == null) return; roomUnit.setZ(riding.getRoomUnit().getZ()); @@ -413,103 +350,79 @@ public class HabboInfo implements Runnable roomUnit.statusUpdate(true); } - public void setRiding(RideablePet riding) - { - this.riding = riding; - } - - public Class getCurrentGame() - { + public Class getCurrentGame() { return this.currentGame; } - public void setCurrentGame(Class currentGame) - { + public void setCurrentGame(Class currentGame) { this.currentGame = currentGame; } - public boolean isInGame() - { + public boolean isInGame() { return this.currentGame != null; } - public synchronized GamePlayer getGamePlayer() - { + public synchronized GamePlayer getGamePlayer() { return this.gamePlayer; } - public synchronized void setGamePlayer(GamePlayer gamePlayer) - { + public synchronized void setGamePlayer(GamePlayer gamePlayer) { this.gamePlayer = gamePlayer; } - public int getPhotoRoomId() - { + public int getPhotoRoomId() { return this.photoRoomId; } - public void setPhotoRoomId(int roomId) - { + public void setPhotoRoomId(int roomId) { this.photoRoomId = roomId; } - public int getPhotoTimestamp() - { + public int getPhotoTimestamp() { return this.photoTimestamp; } - public void setPhotoTimestamp(int photoTimestamp) - { + public void setPhotoTimestamp(int photoTimestamp) { this.photoTimestamp = photoTimestamp; } - public String getPhotoURL() - { + public String getPhotoURL() { return this.photoURL; } - public void setPhotoURL(String photoURL) - { + public void setPhotoURL(String photoURL) { this.photoURL = photoURL; } - public String getPhotoJSON() - { + public String getPhotoJSON() { return this.photoJSON; } - public void setPhotoJSON(String photoJSON) - { + public void setPhotoJSON(String photoJSON) { this.photoJSON = photoJSON; } - public int getWebPublishTimestamp() - { + public int getWebPublishTimestamp() { return this.webPublishTimestamp; } - public void setWebPublishTimestamp(int webPublishTimestamp) - { + public void setWebPublishTimestamp(int webPublishTimestamp) { this.webPublishTimestamp = webPublishTimestamp; } - public String getMachineID() - { + public String getMachineID() { return this.machineID; } - public void setMachineID(String machineID) - { + public void setMachineID(String machineID) { this.machineID = machineID; } @Override - public void run() - { + public void run() { this.saveCurrencies(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ? WHERE id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ? WHERE id = ?")) { statement.setString(1, this.motto); statement.setString(2, this.online ? "1" : "0"); statement.setString(3, this.look); @@ -524,21 +437,18 @@ public class HabboInfo implements Runnable statement.setString(12, this.username); statement.setInt(13, this.id); statement.executeUpdate(); - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public int getBonusRarePoints() - { + public int getBonusRarePoints() { return this.getCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type")); } public HabboStats getHabboStats() { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getId()); - if(habbo != null) { + if (habbo != null) { return habbo.getHabboStats(); } 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 25bdd3c5..e227aaba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -7,11 +7,11 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceState; import com.eu.habbo.habbohotel.users.inventory.*; import gnu.trove.set.hash.THashSet; -public class HabboInventory -{ +public class HabboInventory { //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ITEMS = 10000; - + private final THashSet items; + private final Habbo habbo; private WardrobeComponent wardrobeComponent; private BadgesComponent badgesComponent; private BotsComponent botsComponent; @@ -19,131 +19,96 @@ public class HabboInventory private ItemsComponent itemsComponent; private PetsComponent petsComponent; - private final THashSet items; - private final Habbo habbo; - - public HabboInventory(Habbo habbo) - { + public HabboInventory(Habbo habbo) { this.habbo = habbo; - try - { + try { this.badgesComponent = new BadgesComponent(this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.botsComponent = new BotsComponent(this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.effectsComponent = new EffectsComponent(this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.itemsComponent = new ItemsComponent(this, this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.petsComponent = new PetsComponent(this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - try - { + try { this.wardrobeComponent = new WardrobeComponent(this.habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } this.items = MarketPlace.getOwnOffers(this.habbo); } - public WardrobeComponent getWardrobeComponent() - { + public WardrobeComponent getWardrobeComponent() { return this.wardrobeComponent; } - public void setWardrobeComponent(WardrobeComponent wardrobeComponent) - { + public void setWardrobeComponent(WardrobeComponent wardrobeComponent) { this.wardrobeComponent = wardrobeComponent; } - public BadgesComponent getBadgesComponent() - { + public BadgesComponent getBadgesComponent() { return this.badgesComponent; } - public void setBadgesComponent(BadgesComponent badgesComponent) - { + public void setBadgesComponent(BadgesComponent badgesComponent) { this.badgesComponent = badgesComponent; } - public BotsComponent getBotsComponent() - { + public BotsComponent getBotsComponent() { return this.botsComponent; } - public void setBotsComponent(BotsComponent botsComponent) - { + public void setBotsComponent(BotsComponent botsComponent) { this.botsComponent = botsComponent; } - public EffectsComponent getEffectsComponent() - { + public EffectsComponent getEffectsComponent() { return this.effectsComponent; } - public void setEffectsComponent(EffectsComponent effectsComponent) - { + public void setEffectsComponent(EffectsComponent effectsComponent) { this.effectsComponent = effectsComponent; } - public ItemsComponent getItemsComponent() - { + public ItemsComponent getItemsComponent() { return this.itemsComponent; } - public void setItemsComponent(ItemsComponent itemsComponent) - { + public void setItemsComponent(ItemsComponent itemsComponent) { this.itemsComponent = itemsComponent; } - public PetsComponent getPetsComponent() - { + public PetsComponent getPetsComponent() { return this.petsComponent; } - public void setPetsComponent(PetsComponent petsComponent) - { + public void setPetsComponent(PetsComponent petsComponent) { this.petsComponent = petsComponent; } - public void dispose() - { + public void dispose() { this.badgesComponent.dispose(); this.botsComponent.dispose(); this.effectsComponent.dispose(); @@ -159,47 +124,38 @@ public class HabboInventory this.wardrobeComponent = null; } - public void addMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) - { + public void addMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) { this.items.add(marketPlaceOffer); } - public void removeMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) - { + public void removeMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) { this.items.remove(marketPlaceOffer); } - public THashSet getMarketplaceItems() - { + public THashSet getMarketplaceItems() { return this.items; } - public int getSoldPriceTotal() - { + public int getSoldPriceTotal() { int i = 0; - for(MarketPlaceOffer offer : this.items) - { - if(offer.getState().equals(MarketPlaceState.SOLD)) - { - i+= offer.getPrice(); + for (MarketPlaceOffer offer : this.items) { + if (offer.getState().equals(MarketPlaceState.SOLD)) { + i += offer.getPrice(); } } return i; } - public MarketPlaceOffer getOffer(int id) - { - for(MarketPlaceOffer offer : this.items) - { - if(offer.getOfferId() == id) + public MarketPlaceOffer getOffer(int id) { + for (MarketPlaceOffer offer : this.items) { + if (offer.getOfferId() == id) return offer; } return null; } - public Habbo getHabbo() - { + 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 561bf7c1..5390cb12 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -28,8 +28,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public abstract class HabboItem implements Runnable, IEventTriggers -{ +public abstract class HabboItem implements Runnable, IEventTriggers { private int id; private int userId; private int roomId; @@ -46,8 +45,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers private boolean needsDelete = false; private boolean isFromGift = false; - public HabboItem(ResultSet set, Item baseItem) throws SQLException - { + public HabboItem(ResultSet set, Item baseItem) throws SQLException { this.id = set.getInt("id"); this.userId = set.getInt("user_id"); this.roomId = set.getInt("room_id"); @@ -60,15 +58,13 @@ public abstract class HabboItem implements Runnable, IEventTriggers this.extradata = set.getString("extra_data"); String ltdData = set.getString("limited_data"); - if (!ltdData.isEmpty()) - { + if (!ltdData.isEmpty()) { this.limitedStack = Integer.parseInt(set.getString("limited_data").split(":")[0]); this.limitedSells = Integer.parseInt(set.getString("limited_data").split(":")[1]); } } - public HabboItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) - { + public HabboItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { this.id = id; this.userId = userId; this.roomId = 0; @@ -83,10 +79,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers this.limitedStack = limitedStack; } - public void serializeFloorData(ServerMessage serverMessage) - { - try - { + public static RoomTile getSquareInFront(RoomLayout roomLayout, HabboItem item) { + return roomLayout.getTileInFront(roomLayout.getTile(item.getX(), item.getY()), item.getRotation()); + } + + public void serializeFloorData(ServerMessage serverMessage) { + try { serverMessage.appendInt(this.getId()); serverMessage.appendInt(this.baseItem.getSpriteId()); serverMessage.appendInt(this.x); @@ -97,29 +95,24 @@ public abstract class HabboItem implements Runnable, IEventTriggers 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( ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) : "")); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - public void serializeExtradata(ServerMessage serverMessage) - { - if(this.isLimited()) - { + public void serializeExtradata(ServerMessage serverMessage) { + if (this.isLimited()) { serverMessage.appendInt(this.getLimitedSells()); serverMessage.appendInt(this.getLimitedStack()); } } - public void serializeWallData(ServerMessage serverMessage) - { + public void serializeWallData(ServerMessage serverMessage) { serverMessage.appendString(this.getId() + ""); serverMessage.appendInt(this.baseItem.getSpriteId()); serverMessage.appendString(this.wallPosition); - if(this instanceof InteractionPostIt) + if (this instanceof InteractionPostIt) serverMessage.appendString(this.extradata.split(" ")[0]); else serverMessage.appendString(this.extradata); @@ -128,8 +121,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers serverMessage.appendInt(this.getUserId()); } - public int getId() - { + public int getId() { return this.id; } @@ -139,93 +131,75 @@ public abstract class HabboItem implements Runnable, IEventTriggers return this.id; } - public int getUserId() - { + public int getUserId() { return this.userId; } - public void setUserId(int userId) - { + public void setUserId(int userId) { this.userId = userId; } - public int getRoomId() - { + public int getRoomId() { return this.roomId; } - public void setRoomId(int roomId) - { + public void setRoomId(int roomId) { this.roomId = roomId; } - public Item getBaseItem() - { + public Item getBaseItem() { return this.baseItem; } - public String getWallPosition() - { + public String getWallPosition() { return this.wallPosition; } - public void setWallPosition(String wallPosition) - { + public void setWallPosition(String wallPosition) { this.wallPosition = wallPosition; } - public short getX() - { + public short getX() { return this.x; } - public void setX(short x) - { + public void setX(short x) { this.x = x; } - public short getY() - { + public short getY() { return this.y; } - public void setY(short y) - { + public void setY(short y) { this.y = y; } - public double getZ() - { + public double getZ() { return this.z; } - public void setZ(double z) - { + public void setZ(double z) { this.z = z; } - public int getRotation() - { + public int getRotation() { return this.rotation; } - public void setRotation(int rotation) - { - this.rotation = (byte)(rotation % 8); + public void setRotation(int rotation) { + this.rotation = (byte) (rotation % 8); } - public String getExtradata() - { + public String getExtradata() { return this.extradata; } - public void setExtradata(String extradata) - { + public void setExtradata(String extradata) { this.extradata = extradata; } - public boolean needsUpdate() - { + public boolean needsUpdate() { return this.needsUpdate; } @@ -233,51 +207,39 @@ public abstract class HabboItem implements Runnable, IEventTriggers return needsDelete; } - public void needsUpdate(boolean value) - { + public void needsUpdate(boolean value) { this.needsUpdate = value; } - public void needsDelete(boolean value) - { + public void needsDelete(boolean value) { this.needsDelete = value; } - public boolean isLimited() - { + public boolean isLimited() { return this.limitedStack > 0; } - public int getLimitedStack() - { + public int getLimitedStack() { return this.limitedStack; } - public int getLimitedSells() - { + public int getLimitedSells() { return this.limitedSells; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - if (this.needsDelete) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + if (this.needsDelete) { this.needsUpdate = false; this.needsDelete = false; - try (PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { statement.setInt(1, this.getId()); statement.execute(); } - } - else if (this.needsUpdate) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) - { + } else if (this.needsUpdate) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) { statement.setInt(1, this.userId); statement.setInt(2, this.roomId); statement.setString(3, this.wallPosition); @@ -289,9 +251,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers statement.setString(9, this.limitedStack + ":" + this.limitedSells); statement.setInt(10, this.id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); Emulator.getLogging().logErrorLine("SQLException trying to save HabboItem: " + this.toString()); } @@ -299,31 +259,20 @@ public abstract class HabboItem implements Runnable, IEventTriggers this.needsUpdate = false; } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public static RoomTile getSquareInFront(RoomLayout roomLayout, HabboItem item) - { - return roomLayout.getTileInFront(roomLayout.getTile(item.getX(), item.getY()), item.getRotation()); - } - public abstract boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects); public abstract boolean isWalkable(); @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception - { - if(client != null && this.getBaseItem().getType() == FurnitureType.FLOOR) - { - if (objects != null && objects.length >= 2) - { - if (objects[1] instanceof WiredEffectType) - { + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (client != null && this.getBaseItem().getType() == FurnitureType.FLOOR) { + if (objects != null && objects.length >= 2) { + if (objects[1] instanceof WiredEffectType) { return; } } @@ -334,8 +283,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { if (objects != null && objects.length >= 1 && objects[0] instanceof InteractionWired) return; @@ -348,93 +296,72 @@ public abstract class HabboItem implements Runnable, IEventTriggers } @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception - { + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this}); } public abstract void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception; - public void onPlace(Room room) - { + public void onPlace(Room room) { //TODO: IMPORTANT: MAKE THIS GENERIC. (HOLES, ICE SKATE PATCHES, BLACK HOLE, BUNNY RUN FIELD, FOOTBALL FIELD) Achievement roomDecoAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFurniCount"); Habbo owner = room.getHabbo(this.getUserId()); int furniCollecterProgress; - if (owner == null) - { + if (owner == null) { furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), roomDecoAchievement); - } - else - { + } else { furniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoAchievement); } int difference = room.getUserFurniCount(this.getUserId()) - furniCollecterProgress; - if (difference > 0) - { - if (owner != null) - { + if (difference > 0) { + if (owner != null) { AchievementManager.progressAchievement(owner, roomDecoAchievement, difference); - } - else - { + } else { AchievementManager.progressAchievement(this.getUserId(), roomDecoAchievement, difference); } } } - public void onPickUp(Room room) - { - if(this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { - for (Habbo habbo : room.getHabbosOnItem(this)) - { - if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) - { + public void onPickUp(Room room) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + for (Habbo habbo : room.getHabbosOnItem(this)) { + if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { room.giveEffect(habbo, 0, -1); } - if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { room.giveEffect(habbo, 0, -1); } } - for (Bot bot : room.getBotsAt(room.getLayout().getTile(this.getX(), this.getY()))) - { - if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) - { + for (Bot bot : room.getBotsAt(room.getLayout().getTile(this.getX(), this.getY()))) { + if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { room.giveEffect(bot.getRoomUnit(), 0, -1); } - if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { room.giveEffect(bot.getRoomUnit(), 0, -1); } } } } - public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) - { - if(this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - { + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { List oldHabbos = new ArrayList<>(); List newHabbos = new ArrayList<>(); List oldBots = new ArrayList<>(); List newBots = new ArrayList<>(); - for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) - { + for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) { oldHabbos.addAll(room.getHabbosAt(tile)); oldBots.addAll(room.getBotsAt(tile)); } - for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) - { + for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) { newHabbos.addAll(room.getHabbosAt(tile)); newBots.addAll(room.getBotsAt(tile)); } @@ -442,83 +369,66 @@ public abstract class HabboItem implements Runnable, IEventTriggers oldHabbos.removeAll(newHabbos); oldBots.removeAll(newBots); - for (Habbo habbo : oldHabbos) - { - if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) - { + for (Habbo habbo : oldHabbos) { + if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { room.giveEffect(habbo, 0, -1); } - if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { room.giveEffect(habbo, 0, -1); } } - for (Habbo habbo : newHabbos) - { - if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) - { + for (Habbo habbo : newHabbos) { + if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); } - if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); } } - for (Bot bot : oldBots) - { - if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) - { + for (Bot bot : oldBots) { + if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { room.giveEffect(bot.getRoomUnit(), 0, -1); } - if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { room.giveEffect(bot.getRoomUnit(), 0, -1); } } - for (Bot bot : newBots) - { - if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) - { + for (Bot bot : newBots) { + if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); } - if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) - { + if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); } } } } - public String getDatabaseExtraData() - { + public String getDatabaseExtraData() { return this.getExtradata(); } @Override - public String toString() - { + public String toString() { return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.x + ", Y: " + this.y + ", Z: " + this.z + ", Extradata: " + this.extradata; } - public boolean allowWiredResetState() - { + public boolean allowWiredResetState() { return false; } - public boolean isUsable() - { + public boolean isUsable() { return this.baseItem.getStateCount() > 1; } - public boolean canStackAt(Room room, List>> itemsAtLocation) - { + public boolean canStackAt(Room room, List>> itemsAtLocation) { return true; } 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 6bca1549..0a1a6b00 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Rank; -import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; @@ -25,16 +24,14 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class HabboManager -{ +public class HabboManager { //Configuration. Loaded from database & updated accordingly. public static String WELCOME_MESSAGE = ""; public static boolean NAMECHANGE_ENABLED = false; private final ConcurrentHashMap onlineHabbos; - public HabboManager() - { + public HabboManager() { long millis = System.currentTimeMillis(); this.onlineHabbos = new ConcurrentHashMap<>(); @@ -42,27 +39,55 @@ public class HabboManager Emulator.getLogging().logStart("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public void addHabbo(Habbo habbo) - { + public static HabboInfo getOfflineHabboInfo(int id) { + HabboInfo info = null; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) { + statement.setInt(1, id); + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + info = new HabboInfo(set); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return info; + } + + public static HabboInfo getOfflineHabboInfo(String username) { + HabboInfo info = null; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username = ? LIMIT 1")) { + statement.setString(1, username); + + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + info = new HabboInfo(set); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return info; + } + + public void addHabbo(Habbo habbo) { this.onlineHabbos.put(habbo.getHabboInfo().getId(), habbo); } - public void removeHabbo(Habbo habbo) - { + public void removeHabbo(Habbo habbo) { this.onlineHabbos.remove(habbo.getHabboInfo().getId()); } - public Habbo getHabbo(int id) - { + public Habbo getHabbo(int id) { return this.onlineHabbos.get(id); } - public Habbo getHabbo(String username) - { - synchronized (this.onlineHabbos) - { - for (Map.Entry map : this.onlineHabbos.entrySet()) - { + public Habbo getHabbo(String username) { + synchronized (this.onlineHabbos) { + for (Map.Entry map : this.onlineHabbos.entrySet()) { if (map.getValue().getHabboInfo().getUsername().equalsIgnoreCase(username)) return map.getValue(); } @@ -71,80 +96,61 @@ public class HabboManager return null; } - public Habbo loadHabbo(String sso) - { + public Habbo loadHabbo(String sso) { Habbo habbo; int userId = 0; - try(Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE auth_ticket = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE auth_ticket = ? LIMIT 1")) { statement.setString(1, sso); - try (ResultSet s = statement.executeQuery()) - { - if (s.next()) - { + try (ResultSet s = statement.executeQuery()) { + if (s.next()) { userId = s.getInt("id"); } } statement.close(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } habbo = this.cloneCheck(userId); - if (habbo != null) - { + if (habbo != null) { habbo.alert(Emulator.getTexts().getValue("loggedin.elsewhere")); Emulator.getGameServer().getGameClientManager().disposeClient(habbo.getClient()); habbo = null; } ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(userId); - if (ban != null) - { + if (ban != null) { return null; } - try(Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE auth_ticket = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE auth_ticket = ? LIMIT 1")) { statement.setString(1, sso); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { habbo = new Habbo(set); - if (habbo.getHabboInfo().firstVisit) - { + if (habbo.getHabboInfo().firstVisit) { Emulator.getPluginManager().fireEvent(new UserRegisteredEvent(habbo)); } - if (!Emulator.debugging) - { - try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE id = ? LIMIT 1")) - { + if (!Emulator.debugging) { + try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE id = ? LIMIT 1")) { stmt.setString(1, ""); stmt.setInt(2, habbo.getHabboInfo().getId()); stmt.execute(); - } catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); - } - catch (Exception ex) - { + } catch (Exception ex) { Emulator.getLogging().logErrorLine(ex); } @@ -152,164 +158,76 @@ public class HabboManager } public HabboInfo getHabboInfo(int id) { - if(this.getHabbo(id) == null) { + if (this.getHabbo(id) == null) { return getOfflineHabboInfo(id); } return this.getHabbo(id).getHabboInfo(); } - public static HabboInfo getOfflineHabboInfo(int id) - { - HabboInfo info = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) - { - statement.setInt(1, id); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - info = new HabboInfo(set); - } - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return info; - } - - public static HabboInfo getOfflineHabboInfo(String username) - { - HabboInfo info = null; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username = ? LIMIT 1")) - { - statement.setString(1, username); - - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - info = new HabboInfo(set); - } - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return info; - } - - public int getOnlineCount() - { + public int getOnlineCount() { return this.onlineHabbos.size(); } - public Habbo cloneCheck(int id) - { + public Habbo cloneCheck(int id) { return Emulator.getGameServer().getGameClientManager().getHabbo(id); } - public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) - { - synchronized (this.onlineHabbos) - { - for(Habbo habbo : this.onlineHabbos.values()) - { - if(habbo.hasPermission(perm)) - { + public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) { + synchronized (this.onlineHabbos) { + for (Habbo habbo : this.onlineHabbos.values()) { + if (habbo.hasPermission(perm)) { habbo.getClient().sendResponse(message); } } } } - public ConcurrentHashMap getOnlineHabbos() - { + public ConcurrentHashMap getOnlineHabbos() { return this.onlineHabbos; } - public synchronized void dispose() - { - - - - - - - - - - - - + public synchronized void dispose() { // - - - - - - - - - - Emulator.getLogging().logShutdownLine("Habbo Manager -> Disposed!"); } - public ArrayList getCloneAccounts(Habbo habbo, int limit) - { + public ArrayList getCloneAccounts(Habbo habbo, int limit) { ArrayList habboInfo = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) { statement.setString(1, habbo.getHabboInfo().getIpRegister()); statement.setString(2, habbo.getClient().getChannel().remoteAddress().toString()); statement.setInt(3, habbo.getHabboInfo().getId()); statement.setInt(4, limit); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { habboInfo.add(new HabboInfo(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return habboInfo; } - public List> getNameChanges(int userId, int limit) - { + public List> getNameChanges(int userId, int limit) { List> nameChanges = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT timestamp, new_name FROM namechange_log WHERE user_id = ? ORDER by timestamp DESC LIMIT ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT timestamp, new_name FROM namechange_log WHERE user_id = ? ORDER by timestamp DESC LIMIT ?")) { statement.setInt(1, userId); statement.setInt(2, limit); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { nameChanges.add(new AbstractMap.SimpleEntry<>(set.getInt("timestamp"), set.getString("new_name"))); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -317,36 +235,30 @@ public class HabboManager } - public void setRank(int userId, int rankId) throws Exception - { + public void setRank(int userId, int rankId) throws Exception { Habbo habbo = this.getHabbo(userId); - if (!Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) - { + if (!Emulator.getGameEnvironment().getPermissionsManager().rankExists(rankId)) { throw new Exception("Rank ID (" + rankId + ") does not exist"); } Rank newRank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId); - if(habbo != null && habbo.getHabboStats() != null) - { + if (habbo != null && habbo.getHabboStats() != null) { Rank oldRank = habbo.getHabboInfo().getRank(); - if (!oldRank.getBadge().isEmpty()) - { + if (!oldRank.getBadge().isEmpty()) { habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge())); //BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this } habbo.getHabboInfo().setRank(newRank); - if (!newRank.getBadge().isEmpty()) - { + if (!newRank.getBadge().isEmpty()) { habbo.addBadge(newRank.getBadge()); } habbo.getClient().sendResponse(new UserPermissionsComposer(habbo)); habbo.getClient().sendResponse(new UserPerksComposer(habbo)); - if (habbo.hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (habbo.hasPermission(Permission.ACC_SUPPORTTOOL)) { habbo.getClient().sendResponse(new ModToolComposer(habbo)); } habbo.getHabboInfo().run(); @@ -358,17 +270,12 @@ public class HabboManager habbo.getClient().sendResponse(new GiftConfigurationComposer()); habbo.getClient().sendResponse(new RecyclerLogicComposer()); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_give_rank.new_rank").replace("id", newRank.getName())); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET `rank` = ? WHERE id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET `rank` = ? WHERE id = ? LIMIT 1")) { statement.setInt(1, rankId); statement.setInt(2, userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -376,30 +283,22 @@ public class HabboManager Emulator.getPluginManager().fireEvent(new UserRankChangedEvent(habbo)); } - public void giveCredits(int userId, int credits) - { + public void giveCredits(int userId, int credits) { Habbo habbo = this.getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.giveCredits(credits); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement= connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) { statement.setInt(1, credits); statement.setInt(2, userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public void staffAlert(String message) - { + public void staffAlert(String message) { message = Emulator.getTexts().getValue("commands.generic.cmd_staffalert.title") + "\r\n" + message; ServerMessage msg = new GenericAlertComposer(message).compose(); Emulator.getGameEnvironment().getHabboManager().sendPacketToHabbosWithPermission(msg, "cmd_staffalert"); 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 5f71ccb8..df103c70 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorPersonalDisplayMode.java @@ -6,19 +6,16 @@ import com.eu.habbo.habbohotel.navigation.ListMode; import java.sql.ResultSet; import java.sql.SQLException; -public class HabboNavigatorPersonalDisplayMode -{ +public class HabboNavigatorPersonalDisplayMode { public ListMode listMode; public DisplayMode displayMode; - public HabboNavigatorPersonalDisplayMode(ListMode listMode, DisplayMode collapsed) - { + public HabboNavigatorPersonalDisplayMode(ListMode listMode, DisplayMode collapsed) { this.listMode = listMode; this.displayMode = collapsed; } - public HabboNavigatorPersonalDisplayMode(ResultSet set) throws SQLException - { + public HabboNavigatorPersonalDisplayMode(ResultSet set) throws SQLException { this.listMode = set.getString("list_type").equals("thumbnails") ? ListMode.THUMBNAILS : ListMode.LIST; this.displayMode = DisplayMode.valueOf(set.getString("display").toUpperCase()); } 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 bd4afb83..88c37d56 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java @@ -11,8 +11,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -public class HabboNavigatorWindowSettings -{ +public class HabboNavigatorWindowSettings { + public final THashMap displayModes = new THashMap<>(2); private final int userId; public int x = 100; public int y = 100; @@ -20,15 +20,12 @@ public class HabboNavigatorWindowSettings public int height = 535; public boolean openSearches = false; public int unknown = 0; - public final THashMap displayModes = new THashMap<>(2); - public HabboNavigatorWindowSettings(int userId) - { + public HabboNavigatorWindowSettings(int userId) { this.userId = userId; } - public HabboNavigatorWindowSettings(ResultSet set) throws SQLException - { + public HabboNavigatorWindowSettings(ResultSet set) throws SQLException { this.userId = set.getInt("user_id"); this.x = set.getInt("x"); this.y = set.getInt("y"); @@ -38,31 +35,24 @@ public class HabboNavigatorWindowSettings this.unknown = 0; } - public void addDisplayMode(String category, HabboNavigatorPersonalDisplayMode displayMode) - { + public void addDisplayMode(String category, HabboNavigatorPersonalDisplayMode displayMode) { this.displayModes.put(category, displayMode); } - public boolean hasDisplayMode(String category) - { + public boolean hasDisplayMode(String category) { return this.displayModes.containsKey(category); } - public void insertDisplayMode(String category, ListMode listMode, DisplayMode displayMode) - { - if (!this.displayModes.containsKey(category)) - { + public void insertDisplayMode(String category, ListMode listMode, DisplayMode displayMode) { + if (!this.displayModes.containsKey(category)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("INSERT INTO users_navigator_settings (user_id, caption, list_type, display) VALUES (?, ?, ?, ?)")) - { + PreparedStatement statement = connection.prepareStatement("INSERT INTO users_navigator_settings (user_id, caption, list_type, display) VALUES (?, ?, ?, ?)")) { statement.setInt(1, this.userId); statement.setString(2, category); statement.setString(3, listMode.name().toLowerCase()); statement.setString(4, displayMode.name().toLowerCase()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -70,79 +60,60 @@ public class HabboNavigatorWindowSettings } } - public void setDisplayMode(String category, DisplayMode displayMode) - { + public void setDisplayMode(String category, DisplayMode displayMode) { HabboNavigatorPersonalDisplayMode personalDisplayMode = this.displayModes.get(category); - if (personalDisplayMode != null) - { + if (personalDisplayMode != null) { personalDisplayMode.displayMode = displayMode; - } - else - { + } else { this.insertDisplayMode(category, ListMode.LIST, displayMode); } } - public void setListMode(String category, ListMode listMode) - { + public void setListMode(String category, ListMode listMode) { HabboNavigatorPersonalDisplayMode personalDisplayMode = this.displayModes.get(category); - if (personalDisplayMode != null) - { + if (personalDisplayMode != null) { personalDisplayMode.listMode = listMode; - } - else - { + } else { this.insertDisplayMode(category, listMode, DisplayMode.VISIBLE); } } - public DisplayMode getDisplayModeForCategory(String category) - { + public DisplayMode getDisplayModeForCategory(String category) { return this.getDisplayModeForCategory(category, DisplayMode.VISIBLE); } - public DisplayMode getDisplayModeForCategory(String category, DisplayMode standard) - { - if (this.displayModes.containsKey(category)) - { + public DisplayMode getDisplayModeForCategory(String category, DisplayMode standard) { + if (this.displayModes.containsKey(category)) { return this.displayModes.get(category).displayMode; } return standard; } - public ListMode getListModeForCategory(String category) - { - return this.getListModeForCategory(category, ListMode.LIST); + public ListMode getListModeForCategory(String category) { + return this.getListModeForCategory(category, ListMode.LIST); } - public ListMode getListModeForCategory(String category, ListMode standard) - { - if (this.displayModes.containsKey(category)) - { + public ListMode getListModeForCategory(String category, ListMode standard) { + if (this.displayModes.containsKey(category)) { return this.displayModes.get(category).listMode; } return standard; } - 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()) - { + 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.setInt(3, this.userId); statement.setString(4, set.getKey()); statement.execute(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 058a5e11..edca1192 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -23,39 +23,36 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class HabboStats implements Runnable -{ +public class HabboStats implements Runnable { + public final TIntArrayList secretRecipes; + public final HabboNavigatorWindowSettings navigatorWindowSettings; + public final THashMap cache; + public final TIntArrayList calendarRewardsClaimed; + public final TIntObjectMap offerCache = new TIntObjectHashMap<>(); private final int timeLoggedIn = Emulator.getIntUnixTimestamp(); - - private HabboInfo habboInfo; - + private final THashMap achievementProgress; + private final THashMap achievementCache; + private final THashMap recentPurchases; + private final TIntArrayList favoriteRooms; + private final TIntArrayList ignoredUsers; 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; - private boolean allowTrade; public boolean preferOldChat; public boolean blockCameraFollow; public RoomChatMessageBubbles chatColor; - - private int clubExpireTimestamp; - 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; @@ -63,21 +60,9 @@ public class HabboStats implements Runnable public int hofPoints; public boolean ignorePets; public boolean ignoreBots; - - private final THashMap achievementProgress; - private final THashMap achievementCache; - private final THashMap recentPurchases; - private final TIntArrayList favoriteRooms; - private final TIntArrayList ignoredUsers; - public final TIntArrayList secretRecipes; - public int citizenshipLevel; public int helpersLevel; public boolean perkTrade; - - public final HabboNavigatorWindowSettings navigatorWindowSettings; - public final THashMap cache; - public long roomEnterTimestamp; public int chatCounter; public long lastChat; @@ -85,27 +70,22 @@ public class HabboStats implements Runnable public boolean nux; public boolean nuxReward; public int nuxStep = 1; - - private int muteEndTime; public int mutedCount = 0; public boolean mutedBubbleTracker = false; - public String changeNameChecked = ""; - public final TIntArrayList calendarRewardsClaimed; - public boolean allowNameChange; public boolean isPurchasingFurniture = false; - public int forumPostsCount; - public THashMap> ltdPurchaseLog = new THashMap<>(0); public long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); - public final TIntObjectMap offerCache = new TIntObjectHashMap<>(); + private HabboInfo habboInfo; + private boolean allowTrade; + private int clubExpireTimestamp; + private int muteEndTime; - private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException - { + private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException { this.cache = new THashMap<>(0); this.achievementProgress = new THashMap<>(0); this.achievementCache = new THashMap<>(0); @@ -153,19 +133,13 @@ public class HabboStats implements Runnable this.forumPostsCount = set.getInt("forums_post_count"); this.nuxReward = this.nux; - try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) - { + try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.habboInfo.getId()); - try (ResultSet nSet = statement.executeQuery()) - { - if (nSet.next()) - { + try (ResultSet nSet = statement.executeQuery()) { + if (nSet.next()) { this.navigatorWindowSettings = new HabboNavigatorWindowSettings(nSet); - } - else - { - try (PreparedStatement stmt = statement.getConnection().prepareStatement("INSERT INTO user_window_settings (user_id) VALUES (?)")) - { + } else { + try (PreparedStatement stmt = statement.getConnection().prepareStatement("INSERT INTO user_window_settings (user_id) VALUES (?)")) { stmt.setInt(1, this.habboInfo.getId()); stmt.executeUpdate(); } @@ -175,100 +149,148 @@ public class HabboStats implements Runnable } } - try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_navigator_settings WHERE user_id = ?")) - { + try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_navigator_settings WHERE user_id = ?")) { statement.setInt(1, this.habboInfo.getId()); - try (ResultSet nSet = statement.executeQuery()) - { - while (nSet.next()) - { + try (ResultSet nSet = statement.executeQuery()) { + while (nSet.next()) { this.navigatorWindowSettings.addDisplayMode(nSet.getString("caption"), new HabboNavigatorPersonalDisplayMode(nSet)); } } } - try (PreparedStatement favoriteRoomsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_favorite_rooms WHERE user_id = ?")) - { + try (PreparedStatement favoriteRoomsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_favorite_rooms WHERE user_id = ?")) { favoriteRoomsStatement.setInt(1, this.habboInfo.getId()); - try (ResultSet favoriteSet = favoriteRoomsStatement.executeQuery()) - { - while (favoriteSet.next()) - { + try (ResultSet favoriteSet = favoriteRoomsStatement.executeQuery()) { + while (favoriteSet.next()) { this.favoriteRooms.add(favoriteSet.getInt("room_id")); } } } - try (PreparedStatement recipesStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_recipes WHERE user_id = ?")) - { + try (PreparedStatement recipesStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_recipes WHERE user_id = ?")) { recipesStatement.setInt(1, this.habboInfo.getId()); - try (ResultSet recipeSet = recipesStatement.executeQuery()) - { - while (recipeSet.next()) - { + try (ResultSet recipeSet = recipesStatement.executeQuery()) { + while (recipeSet.next()) { this.secretRecipes.add(recipeSet.getInt("recipe")); } } } - try (PreparedStatement calendarRewardsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM calendar_rewards_claimed WHERE user_id = ?")) - { + try (PreparedStatement calendarRewardsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM calendar_rewards_claimed WHERE user_id = ?")) { calendarRewardsStatement.setInt(1, this.habboInfo.getId()); - try (ResultSet rewardSet = calendarRewardsStatement.executeQuery()) - { - while (rewardSet.next()) - { + try (ResultSet rewardSet = calendarRewardsStatement.executeQuery()) { + while (rewardSet.next()) { this.calendarRewardsClaimed.add(rewardSet.getInt("reward_id")); } } } - try (PreparedStatement ltdPurchaseLogStatement = set.getStatement().getConnection().prepareStatement("SELECT catalog_item_id, timestamp FROM catalog_items_limited WHERE user_id = ? AND timestamp > ?")) - { + try (PreparedStatement ltdPurchaseLogStatement = set.getStatement().getConnection().prepareStatement("SELECT catalog_item_id, timestamp FROM catalog_items_limited WHERE user_id = ? AND timestamp > ?")) { ltdPurchaseLogStatement.setInt(1, this.habboInfo.getId()); ltdPurchaseLogStatement.setInt(2, Emulator.getIntUnixTimestamp() - 86400); - try (ResultSet ltdSet = ltdPurchaseLogStatement.executeQuery()) - { - while (ltdSet.next()) - { + try (ResultSet ltdSet = ltdPurchaseLogStatement.executeQuery()) { + while (ltdSet.next()) { this.addLtdLog(ltdSet.getInt("catalog_item_id"), ltdSet.getInt("timestamp")); } } } - try (PreparedStatement ignoredPlayersStatement = set.getStatement().getConnection().prepareStatement("SELECT target_id FROM users_ignored WHERE user_id = ?")) - { + try (PreparedStatement ignoredPlayersStatement = set.getStatement().getConnection().prepareStatement("SELECT target_id FROM users_ignored WHERE user_id = ?")) { ignoredPlayersStatement.setInt(1, this.habboInfo.getId()); - try (ResultSet ignoredSet = ignoredPlayersStatement.executeQuery()) - { - while (ignoredSet.next()) - { + try (ResultSet ignoredSet = ignoredPlayersStatement.executeQuery()) { + while (ignoredSet.next()) { this.ignoredUsers.add(ignoredSet.getInt(1)); } } } - try (PreparedStatement loadOfferPurchaseStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_target_offer_purchases WHERE user_id = ?")) - { + try (PreparedStatement loadOfferPurchaseStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_target_offer_purchases WHERE user_id = ?")) { loadOfferPurchaseStatement.setInt(1, this.habboInfo.getId()); - try (ResultSet offerSet = loadOfferPurchaseStatement.executeQuery()) - { - while (offerSet.next()) - { + try (ResultSet offerSet = loadOfferPurchaseStatement.executeQuery()) { + while (offerSet.next()) { this.offerCache.put(offerSet.getInt("offer_id"), new HabboOfferPurchase(offerSet)); } } } } + private static HabboStats createNewStats(HabboInfo habboInfo) { + habboInfo.firstVisit = true; + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_settings (user_id) VALUES (?)")) { + statement.setInt(1, habboInfo.getId()); + statement.executeUpdate(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return load(habboInfo); + } + + public static HabboStats load(HabboInfo habboInfo) { + HabboStats stats = null; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_settings WHERE user_id = ? LIMIT 1")) { + statement.setInt(1, habboInfo.getId()); + try (ResultSet set = statement.executeQuery()) { + set.first(); + if (set.getRow() != 0) { + stats = new HabboStats(set, habboInfo); + } else { + stats = createNewStats(habboInfo); + } + } + } + + if (stats != null) { + try (PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM guilds_members WHERE user_id = ? AND level_id < 3 LIMIT 100")) { + statement.setInt(1, habboInfo.getId()); + try (ResultSet set = statement.executeQuery()) { + + int i = 0; + while (set.next()) { + stats.guilds.add(set.getInt("guild_id")); + i++; + } + } + } + + Collections.sort(stats.guilds); + + try (PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM room_votes WHERE user_id = ?")) { + statement.setInt(1, habboInfo.getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + stats.votedRooms.push(set.getInt("room_id")); + } + } + } + + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_achievements WHERE user_id = ?")) { + statement.setInt(1, habboInfo.getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(set.getString("achievement_name")); + + if (achievement != null) { + stats.achievementProgress.put(achievement, set.getInt("progress")); + } + } + } + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return stats; + } + @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ? WHERE user_id = ? LIMIT 1")) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -305,8 +327,7 @@ public class HabboStats implements Runnable statement.executeUpdate(); } - try (PreparedStatement statement = connection.prepareStatement("UPDATE user_window_settings SET x = ?, y = ?, width = ?, height = ?, open_searches = ? WHERE user_id = ? LIMIT 1")) - { + 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); @@ -316,12 +337,9 @@ public class HabboStats implements Runnable statement.executeUpdate(); } - if (!this.offerCache.isEmpty()) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_target_offer_purchases SET state = ?, amount = ?, last_purchase = ? WHERE user_id = ? AND offer_id = ?")) - { - for (HabboOfferPurchase purchase : this.offerCache.valueCollection()) - { + if (!this.offerCache.isEmpty()) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_target_offer_purchases SET state = ?, amount = ?, last_purchase = ? WHERE user_id = ? AND offer_id = ?")) { + for (HabboOfferPurchase purchase : this.offerCache.valueCollection()) { if (!purchase.needsUpdate()) continue; statement.setInt(1, purchase.getState()); @@ -335,247 +353,121 @@ public class HabboStats implements Runnable } this.navigatorWindowSettings.save(connection); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void dispose() - { + public void dispose() { this.run(); this.habboInfo = null; this.recentPurchases.clear(); } - private static HabboStats createNewStats(HabboInfo habboInfo) - { - habboInfo.firstVisit = true; - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_settings (user_id) VALUES (?)")) - { - statement.setInt(1, habboInfo.getId()); - statement.executeUpdate(); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return load(habboInfo); - } - - public static HabboStats load(HabboInfo habboInfo) - { - HabboStats stats = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try(PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_settings WHERE user_id = ? LIMIT 1")) - { - statement.setInt(1, habboInfo.getId()); - try (ResultSet set = statement.executeQuery()) - { - set.first(); - if (set.getRow() != 0) - { - stats = new HabboStats(set, habboInfo); - } - else - { - stats = createNewStats(habboInfo); - } - } - } - - if(stats != null) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM guilds_members WHERE user_id = ? AND level_id < 3 LIMIT 100")) - { - statement.setInt(1, habboInfo.getId()); - try (ResultSet set = statement.executeQuery()) - { - - int i = 0; - while (set.next()) - { - stats.guilds.add(set.getInt("guild_id")); - i++; - } - } - } - - Collections.sort(stats.guilds); - - try (PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM room_votes WHERE user_id = ?")) - { - statement.setInt(1, habboInfo.getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - stats.votedRooms.push(set.getInt("room_id")); - } - } - } - - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_achievements WHERE user_id = ?")) - { - statement.setInt(1, habboInfo.getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(set.getString("achievement_name")); - - if (achievement != null) - { - stats.achievementProgress.put(achievement, set.getInt("progress")); - } - } - } - } - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - return stats; - } - - public void addGuild(int guildId) - { - if (!this.guilds.contains(guildId)) - { + public void addGuild(int guildId) { + if (!this.guilds.contains(guildId)) { this.guilds.add(guildId); } } - public void removeGuild(int guildId) - { - this.guilds.remove((Integer)guildId); + public void removeGuild(int guildId) { + this.guilds.remove((Integer) guildId); } - public boolean hasGuild(int guildId) - { - for(int i : this.guilds) - { - if(i == guildId) + public boolean hasGuild(int guildId) { + for (int i : this.guilds) { + if (i == guildId) return true; } return false; } - public int getAchievementScore() - { + public int getAchievementScore() { return this.achievementScore; } - public void addAchievementScore(int achievementScore) - { + public void addAchievementScore(int achievementScore) { this.achievementScore += achievementScore; } - public int getAchievementProgress(Achievement achievement) - { - if(this.achievementProgress.containsKey(achievement)) + public int getAchievementProgress(Achievement achievement) { + if (this.achievementProgress.containsKey(achievement)) return this.achievementProgress.get(achievement); return -1; } - public void setProgress(Achievement achievement, int progress) - { + public void setProgress(Achievement achievement, int progress) { this.achievementProgress.put(achievement, progress); } - public int getRentedTimeEnd() - { + public int getRentedTimeEnd() { return this.rentedTimeEnd; } - public void setRentedTimeEnd(int rentedTimeEnd) - { + public void setRentedTimeEnd(int rentedTimeEnd) { this.rentedTimeEnd = rentedTimeEnd; } - public int getRentedItemId() - { + public int getRentedItemId() { return this.rentedItemId; } - public void setRentedItemId(int rentedItemId) - { + public void setRentedItemId(int rentedItemId) { this.rentedItemId = rentedItemId; } - public boolean isRentingSpace() - { + public boolean isRentingSpace() { return this.rentedTimeEnd >= Emulator.getIntUnixTimestamp(); } - public int getClubExpireTimestamp() - { + public int getClubExpireTimestamp() { return this.clubExpireTimestamp; } - public void setClubExpireTimestamp(int clubExpireTimestamp) - { + public void setClubExpireTimestamp(int clubExpireTimestamp) { this.clubExpireTimestamp = clubExpireTimestamp; } - public boolean hasActiveClub() - { + public boolean hasActiveClub() { return this.clubExpireTimestamp > Emulator.getIntUnixTimestamp(); } - public THashMap getAchievementProgress() - { + public THashMap getAchievementProgress() { return this.achievementProgress; } - public THashMap getAchievementCache() - { + public THashMap getAchievementCache() { return this.achievementCache; } - public void addPurchase(CatalogItem item) - { - if(!this.recentPurchases.containsKey(item.getId())) - { + public void addPurchase(CatalogItem item) { + if (!this.recentPurchases.containsKey(item.getId())) { this.recentPurchases.put(item.getId(), item); } } - public THashMap getRecentPurchases() - { + public THashMap getRecentPurchases() { return this.recentPurchases; } - public void disposeRecentPurchases() - { + public void disposeRecentPurchases() { this.recentPurchases.clear(); } - public boolean addFavoriteRoom(int roomId) - { + public boolean addFavoriteRoom(int roomId) { if (this.favoriteRooms.contains(roomId)) return false; if (Emulator.getConfig().getInt("hotel.rooms.max.favorite") <= this.favoriteRooms.size()) return false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_favorite_rooms (user_id, room_id) VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_favorite_rooms (user_id, room_id) VALUES (?, ?)")) { statement.setInt(1, this.habboInfo.getId()); statement.setInt(2, roomId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -583,51 +475,39 @@ public class HabboStats implements Runnable return true; } - public void removeFavoriteRoom(int roomId) - { - if (this.favoriteRooms.remove(roomId)) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_favorite_rooms WHERE user_id = ? AND room_id = ? LIMIT 1")) - { + public void removeFavoriteRoom(int roomId) { + if (this.favoriteRooms.remove(roomId)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_favorite_rooms WHERE user_id = ? AND room_id = ? LIMIT 1")) { statement.setInt(1, this.habboInfo.getId()); statement.setInt(2, roomId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public boolean hasFavoriteRoom(int roomId) - { + public boolean hasFavoriteRoom(int roomId) { return this.favoriteRooms.contains(roomId); } - public TIntArrayList getFavoriteRooms() - { + public TIntArrayList getFavoriteRooms() { return this.favoriteRooms; } - public boolean hasRecipe(int id) - { + public boolean hasRecipe(int id) { return this.secretRecipes.contains(id); } - public boolean addRecipe(int id) - { + public boolean addRecipe(int id) { if (this.secretRecipes.contains(id)) return false; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_recipes (user_id, recipe) VALUES (?, ?)")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_recipes (user_id, recipe) VALUES (?, ?)")) { statement.setInt(1, this.habboInfo.getId()); statement.setInt(2, id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -635,8 +515,7 @@ public class HabboStats implements Runnable return true; } - public int talentTrackLevel(TalentTrackType type) - { + public int talentTrackLevel(TalentTrackType type) { if (type == TalentTrackType.CITIZENSHIP) return this.citizenshipLevel; else if (type == TalentTrackType.HELPER) @@ -645,23 +524,19 @@ public class HabboStats implements Runnable return -1; } - public void setTalentLevel(TalentTrackType type, int level) - { + public void setTalentLevel(TalentTrackType type, int level) { if (type == TalentTrackType.CITIZENSHIP) this.citizenshipLevel = level; else if (type == TalentTrackType.HELPER) this.helpersLevel = level; } - public int getMuteEndTime() - { + public int getMuteEndTime() { return this.muteEndTime; } - public int addMuteTime(int seconds) - { - if (this.remainingMuteTime() == 0) - { + public int addMuteTime(int seconds) { + if (this.remainingMuteTime() == 0) { this.muteEndTime = Emulator.getIntUnixTimestamp(); } @@ -671,117 +546,93 @@ public class HabboStats implements Runnable return this.remainingMuteTime(); } - public int remainingMuteTime() - { + public int remainingMuteTime() { return Math.max(0, this.muteEndTime - Emulator.getIntUnixTimestamp()); } - public boolean allowTalk() - { + public boolean allowTalk() { return this.remainingMuteTime() == 0; } - public void unMute() - { + public void unMute() { this.muteEndTime = 0; this.mutedBubbleTracker = false; } - public void addLtdLog(int catalogItemId, int timestamp) - { - if (!this.ltdPurchaseLog.containsKey(catalogItemId)) - { + public void addLtdLog(int catalogItemId, int timestamp) { + if (!this.ltdPurchaseLog.containsKey(catalogItemId)) { this.ltdPurchaseLog.put(catalogItemId, new ArrayList<>(1)); } this.ltdPurchaseLog.get(catalogItemId).add(timestamp); } - public int totalLtds() - { + public int totalLtds() { int total = 0; - for (Map.Entry> entry : this.ltdPurchaseLog.entrySet()) - { + for (Map.Entry> entry : this.ltdPurchaseLog.entrySet()) { total += entry.getValue().size(); } return total; } - public int totalLtds(int catalogItemId) - { - if (this.ltdPurchaseLog.containsKey(catalogItemId)) - { + public int totalLtds(int catalogItemId) { + if (this.ltdPurchaseLog.containsKey(catalogItemId)) { return this.ltdPurchaseLog.get(catalogItemId).size(); } return 0; } - public void ignoreUser(int userId) - { - if (!this.userIgnored(userId)) - { + public void ignoreUser(int userId) { + if (!this.userIgnored(userId)) { this.ignoredUsers.add(userId); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) - { + PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) { statement.setInt(1, this.habboInfo.getId()); statement.setInt(2, userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public void unignoreUser(int userId) - { - if (this.userIgnored(userId)) - { + public void unignoreUser(int userId) { + if (this.userIgnored(userId)) { this.ignoredUsers.remove(userId); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("DELETE FROM users_ignored WHERE user_id = ? AND target_id = ?")) - { + PreparedStatement statement = connection.prepareStatement("DELETE FROM users_ignored WHERE user_id = ? AND target_id = ?")) { statement.setInt(1, this.habboInfo.getId()); statement.setInt(2, userId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public boolean userIgnored(int userId) - { + public boolean userIgnored(int userId) { return this.ignoredUsers.contains(userId); } - public boolean allowTrade() - { + public boolean allowTrade() { if (AchievementManager.TALENTTRACK_ENABLED && RoomTrade.TRADING_REQUIRES_PERK) return this.perkTrade && this.allowTrade; else return this.allowTrade; } - public void setAllowTrade(boolean allowTrade) - { + public void setAllowTrade(boolean allowTrade) { this.allowTrade = allowTrade; } - public HabboOfferPurchase getHabboOfferPurchase(int offerId) - { + public HabboOfferPurchase getHabboOfferPurchase(int offerId) { return this.offerCache.get(offerId); } - public void addHabboOfferPurchase(HabboOfferPurchase offerPurchase) - { + public void addHabboOfferPurchase(HabboOfferPurchase offerPurchase) { this.offerCache.put(offerPurchase.getOfferId(), offerPurchase); } } 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 8e27b0cb..4fc3d094 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/SignType.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/SignType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.users; -public enum SignType -{ +public enum SignType { ZERO(0), ONE(1), TWO(2), @@ -24,13 +23,11 @@ public enum SignType private final int id; - SignType(int id) - { + SignType(int id) { this.id = id; } - public int getId() - { + 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 eebfd2de..93b8e309 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 @@ -8,8 +8,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class HabboOfferPurchase -{ +public class HabboOfferPurchase { private final int userId; private final int offerId; private int state; @@ -17,85 +16,28 @@ public class HabboOfferPurchase private int lastPurchaseTimestamp; private boolean needsUpdate = false; - public HabboOfferPurchase(ResultSet set) throws SQLException - { - this.userId = set.getInt("user_id"); - this.offerId = set.getInt("offer_id"); - this.state = set.getInt("state"); - this.amount = set.getInt("amount"); - this.lastPurchaseTimestamp = set.getInt("last_purchase"); + public HabboOfferPurchase(ResultSet set) throws SQLException { + this.userId = set.getInt("user_id"); + this.offerId = set.getInt("offer_id"); + this.state = set.getInt("state"); + this.amount = set.getInt("amount"); + this.lastPurchaseTimestamp = set.getInt("last_purchase"); } - private HabboOfferPurchase(int userId, int offerId) - { + private HabboOfferPurchase(int userId, int offerId) { this.userId = userId; this.offerId = offerId; } - 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; - } - - public void update(int amount, int timestamp) - { - this.amount += amount; - this.lastPurchaseTimestamp = timestamp; - this.needsUpdate = true; - } - - public boolean needsUpdate() - { - return this.needsUpdate; - } - - public static HabboOfferPurchase getOrCreate(Habbo habbo, int offerId) - { + public static HabboOfferPurchase getOrCreate(Habbo habbo, int offerId) { HabboOfferPurchase purchase = habbo.getHabboStats().getHabboOfferPurchase(offerId); - if (purchase == null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_target_offer_purchases (user_id, offer_id) VALUES (?, ?)")) - { + if (purchase == null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_target_offer_purchases (user_id, offer_id) VALUES (?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, offerId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); return null; } @@ -106,4 +48,45 @@ 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; + } + + public void update(int amount, int timestamp) { + this.amount += amount; + this.lastPurchaseTimestamp = timestamp; + this.needsUpdate = true; + } + + public boolean needsUpdate() { + return this.needsUpdate; + } } \ No newline at end of file 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 25e58d0e..748ff259 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 @@ -14,44 +14,34 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Set; -public class BadgesComponent -{ +public class BadgesComponent { private final THashSet badges = new THashSet<>(); - public BadgesComponent(Habbo habbo) - { + public BadgesComponent(Habbo habbo) { this.badges.addAll(loadBadges(habbo)); } - private static THashSet loadBadges(Habbo habbo) - { + private static THashSet loadBadges(Habbo habbo) { THashSet badgesList = new THashSet<>(); Set staffBadges = Emulator.getGameEnvironment().getPermissionsManager().getStaffBadges(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { HabboBadge badge = new HabboBadge(set, habbo); - if (staffBadges.contains(badge.getCode())) - { + if (staffBadges.contains(badge.getCode())) { boolean delete = true; - for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanksByBadgeCode(badge.getCode())) - { - if (rank.getId() == habbo.getHabboInfo().getRank().getId()) - { + for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanksByBadgeCode(badge.getCode())) { + if (rank.getId() == habbo.getHabboInfo().getRank().getId()) { delete = false; break; } } - if (delete) - { + if (delete) { deleteBadge(habbo.getHabboInfo().getUsername(), badge.getCode()); continue; } @@ -60,20 +50,16 @@ public class BadgesComponent badgesList.add(badge); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return badgesList; } - public static void resetSlots(Habbo habbo) - { - for(HabboBadge badge : habbo.getInventory().getBadgesComponent().getBadges()) - { - if(badge.getSlot() == 0) + public static void resetSlots(Habbo habbo) { + for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getBadges()) { + if (badge.getSlot() == 0) continue; badge.setSlot(0); @@ -82,24 +68,67 @@ public class BadgesComponent } } - public ArrayList getWearingBadges() - { - synchronized (this.badges) - { + public static ArrayList getBadgesOfflineHabbo(int userId) { + ArrayList badgesList = new ArrayList<>(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE slot_id > 0 AND user_id = ? ORDER BY slot_id ASC")) { + statement.setInt(1, userId); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + badgesList.add(new HabboBadge(set, null)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + return badgesList; + } + + public static HabboBadge createBadge(String code, Habbo habbo) { + HabboBadge badge = new HabboBadge(0, code, 0, habbo); + badge.run(); + habbo.getInventory().getBadgesComponent().addBadge(badge); + return badge; + } + + @Deprecated + public static void deleteBadge(String username, HabboBadge badge) { + deleteBadge(username, badge.getCode()); + } + + @Deprecated + public static void deleteBadge(String username, String badge) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges INNER JOIN users ON users_badges.user_id = users.id WHERE users.username LIKE ? AND badge_code LIKE ?")) { + statement.setString(1, username); + statement.setString(2, badge); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public static void deleteBadge(int userId, String badge) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges WHERE user_id = ? AND badge_code LIKE ?")) { + statement.setInt(1, userId); + statement.setString(2, badge); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public ArrayList getWearingBadges() { + synchronized (this.badges) { ArrayList badgesList = new ArrayList<>(); - for (HabboBadge badge : this.badges) - { + for (HabboBadge badge : this.badges) { if (badge.getSlot() == 0) continue; badgesList.add(badge); } - badgesList.sort(new Comparator() - { + badgesList.sort(new Comparator() { @Override - public int compare(HabboBadge o1, HabboBadge o2) - { + public int compare(HabboBadge o1, HabboBadge o2) { return o1.getSlot() - o2.getSlot(); } }); @@ -107,43 +136,17 @@ public class BadgesComponent } } - public THashSet getBadges() - { + public THashSet getBadges() { return this.badges; } - public static ArrayList getBadgesOfflineHabbo(int userId) - { - ArrayList badgesList = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE slot_id > 0 AND user_id = ? ORDER BY slot_id ASC")) - { - statement.setInt(1, userId); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - badgesList.add(new HabboBadge(set, null)); - } - } - } - catch(SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - return badgesList; - } - - public boolean hasBadge(String badge) - { + public boolean hasBadge(String badge) { return this.getBadge(badge) != null; } - public HabboBadge getBadge(String badgeCode) - { - synchronized (this.badges) - { - for (HabboBadge badge : this.badges) - { + public HabboBadge getBadge(String badgeCode) { + synchronized (this.badges) { + for (HabboBadge badge : this.badges) { if (badge.getCode().equalsIgnoreCase(badgeCode)) return badge; } @@ -151,22 +154,16 @@ public class BadgesComponent } } - public void addBadge(HabboBadge badge) - { - synchronized (this.badges) - { + public void addBadge(HabboBadge badge) { + synchronized (this.badges) { this.badges.add(badge); } } - public HabboBadge removeBadge(String badge) - { - synchronized (this.badges) - { - for(HabboBadge b : this.badges) - { - if(b.getCode().equalsIgnoreCase(badge)) - { + public HabboBadge removeBadge(String badge) { + synchronized (this.badges) { + for (HabboBadge b : this.badges) { + if (b.getCode().equalsIgnoreCase(badge)) { this.badges.remove(b); return b; } @@ -176,62 +173,15 @@ public class BadgesComponent return null; } - public void removeBadge(HabboBadge badge) - { - synchronized (this.badges) - { + public void removeBadge(HabboBadge badge) { + synchronized (this.badges) { this.badges.remove(badge); } } - public void dispose() - { - synchronized (this.badges) - { + public void dispose() { + synchronized (this.badges) { this.badges.clear(); } } - - public static HabboBadge createBadge(String code, Habbo habbo) - { - HabboBadge badge = new HabboBadge(0, code, 0, habbo); - badge.run(); - habbo.getInventory().getBadgesComponent().addBadge(badge); - return badge; - } - - @Deprecated - public static void deleteBadge(String username, HabboBadge badge) - { - deleteBadge(username, badge.getCode()); - } - - @Deprecated - public static void deleteBadge(String username, String badge) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges INNER JOIN users ON users_badges.user_id = users.id WHERE users.username LIKE ? AND badge_code LIKE ?")) - { - statement.setString(1, username); - statement.setString(2, badge); - statement.execute(); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - } - - public static void deleteBadge(int userId, String badge) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges WHERE user_id = ? AND badge_code LIKE ?")) - { - statement.setInt(1, userId); - statement.setString(2, badge); - statement.execute(); - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index 6d64fdbf..c919d56e 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 @@ -15,71 +15,52 @@ public class BotsComponent { private final THashMap bots = new THashMap<>(); - public BotsComponent(Habbo habbo) - { + public BotsComponent(Habbo habbo) { this.loadBots(habbo); } - private void loadBots(Habbo habbo) - { - synchronized (this.bots) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.user_id WHERE user_id = ? AND room_id = 0 ORDER BY id ASC")) - { + private void loadBots(Habbo habbo) { + synchronized (this.bots) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.user_id WHERE user_id = ? AND room_id = 0 ORDER BY id ASC")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set); - if (bot != null) - { + if (bot != null) { this.bots.put(set.getInt("id"), bot); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public Bot getBot(int botId) - { + public Bot getBot(int botId) { return this.bots.get(botId); } - public void addBot(Bot bot) - { - synchronized (this.bots) - { + public void addBot(Bot bot) { + synchronized (this.bots) { this.bots.put(bot.getId(), bot); } } - public void removeBot(Bot bot) - { - synchronized (this.bots) - { + public void removeBot(Bot bot) { + synchronized (this.bots) { this.bots.remove(bot.getId()); } } - public THashMap getBots() - { + public THashMap getBots() { return this.bots; } - public void dispose() - { - synchronized (this.bots) - { - for (Map.Entry map : this.bots.entrySet()) - { - if (map.getValue().needsUpdate()) - { + public void dispose() { + synchronized (this.bots) { + for (Map.Entry map : this.bots.entrySet()) { + if (map.getValue().needsUpdate()) { Emulator.getThreading().run(map.getValue()); } } 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 0fe9f02e..6be7b4dd 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 @@ -13,49 +13,36 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class EffectsComponent -{ +public class EffectsComponent { public final THashMap effects; public final Habbo habbo; public int activatedEffect = 0; - public EffectsComponent(Habbo habbo) - { + public EffectsComponent(Habbo habbo) { this.effects = new THashMap<>(); - this.habbo = habbo; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) - { + this.habbo = habbo; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.effects.put(set.getInt("effect"), new HabboEffect(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public HabboEffect createEffect(int effectId) - { + public HabboEffect createEffect(int effectId) { HabboEffect effect; - synchronized (this.effects) - { - if (this.effects.containsKey(effectId)) - { + synchronized (this.effects) { + if (this.effects.containsKey(effectId)) { effect = this.effects.get(effectId); - if (effect.total <= 99) - { + if (effect.total <= 99) { effect.total++; } - } - else - { + } else { effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId()); effect.insert(); } @@ -66,35 +53,26 @@ public class EffectsComponent return effect; } - public void addEffect(HabboEffect effect) - { + public void addEffect(HabboEffect effect) { this.effects.put(effect.effect, effect); this.habbo.getClient().sendResponse(new EffectsListAddComposer(effect)); } - public void dispose() - { - synchronized (this.effects) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) - { - this.effects.forEachValue(new TObjectProcedure() - { + public void dispose() { + synchronized (this.effects) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) { + this.effects.forEachValue(new TObjectProcedure() { @Override - public boolean execute(HabboEffect effect) - { - try - { + public boolean execute(HabboEffect effect) { + try { statement.setInt(1, effect.duration); statement.setInt(2, effect.activationTimestamp); statement.setInt(3, effect.total); statement.setInt(4, effect.userId); statement.setInt(5, effect.effect); statement.addBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -103,9 +81,7 @@ public class EffectsComponent }); statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -113,43 +89,33 @@ public class EffectsComponent } } - public boolean ownsEffect(int effectId) - { + public boolean ownsEffect(int effectId) { return this.effects.containsKey(effectId); } - public void activateEffect(int effectId) - { + public void activateEffect(int effectId) { HabboEffect effect = this.effects.get(effectId); - if (effect != null) - { - if (effect.isRemaining()) - { + if (effect != null) { + if (effect.isRemaining()) { effect.activationTimestamp = Emulator.getIntUnixTimestamp(); - } - else - { + } else { this.habbo.getClient().sendResponse(new EffectsListRemoveComposer(effect)); } } } - public void enableEffect(int effectId) - { + public void enableEffect(int effectId) { HabboEffect effect = this.effects.get(effectId); - if (effect != null) - { - if (!effect.isActivated()) - { + if (effect != null) { + if (!effect.isActivated()) { this.activateEffect(effect.effect); } this.activatedEffect = effectId; - if (this.habbo.getHabboInfo().getCurrentRoom() != null) - { + if (this.habbo.getHabboInfo().getCurrentRoom() != null) { this.habbo.getHabboInfo().getCurrentRoom().giveEffect(this.habbo, effectId, effect.remainingTime()); } @@ -157,20 +123,17 @@ public class EffectsComponent } } - public boolean hasActivatedEffect(int effectId) - { + public boolean hasActivatedEffect(int effectId) { HabboEffect effect = this.effects.get(effectId); - if (effect != null) - { + if (effect != null) { return effect.isActivated(); } return false; } - public static class HabboEffect - { + public static class HabboEffect { public int effect; public int userId; public int duration = 86400; @@ -178,8 +141,7 @@ public class EffectsComponent public int total = 1; public boolean enabled = false; - public HabboEffect(ResultSet set) throws SQLException - { + public HabboEffect(ResultSet set) throws SQLException { this.effect = set.getInt("effect"); this.userId = set.getInt("user_id"); this.duration = set.getInt("duration"); @@ -187,25 +149,19 @@ public class EffectsComponent this.total = set.getInt("total"); } - public HabboEffect(int effect, int userId) - { + public HabboEffect(int effect, int userId) { this.effect = effect; this.userId = userId; } - public boolean isActivated() - { + public boolean isActivated() { return this.activationTimestamp >= 0; } - public boolean isRemaining() - { - if (this.total > 0) - { - if (this.activationTimestamp >= 0) - { - if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) - { + public boolean isRemaining() { + if (this.total > 0) { + if (this.activationTimestamp >= 0) { + if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) { this.activationTimestamp = -1; this.total--; } @@ -215,37 +171,28 @@ public class EffectsComponent return this.total > 0; } - public int remainingTime() - { + public int remainingTime() { return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration; } - public void insert() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_effects (user_id, effect, total, duration) VALUES (?, ?, ?, ?)")) - { + public void insert() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_effects (user_id, effect, total, duration) VALUES (?, ?, ?, ?)")) { statement.setInt(1, this.userId); statement.setInt(2, this.effect); statement.setInt(3, this.total); statement.setInt(4, this.duration); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public void delete() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_effects WHERE user_id = ? AND effect = ?")) - { + public void delete() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_effects WHERE user_id = ? AND effect = ?")) { statement.setInt(1, this.userId); statement.setInt(2, this.effect); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 d83efed7..46f14581 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 @@ -22,92 +22,69 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.NoSuchElementException; -public class ItemsComponent -{ +public class ItemsComponent { private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final HabboInventory inventory; - public ItemsComponent(HabboInventory inventory, Habbo habbo) - { + public ItemsComponent(HabboInventory inventory, Habbo habbo) { this.inventory = inventory; this.items.putAll(loadItems(habbo)); } - public static THashMap loadItems(Habbo habbo) - { + public static THashMap loadItems(Habbo habbo) { THashMap itemsList = new THashMap<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ? AND user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, 0); statement.setInt(2, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { - try - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + try { HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); - if (item != null) - { + if (item != null) { itemsList.put(set.getInt("id"), item); - } - else - { + } else { Emulator.getLogging().logErrorLine("Failed to load HabboItem: " + set.getInt("id")); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return itemsList; } - public void addItem(HabboItem item) - { - if(item == null) - { - return; - } - - InventoryItemAddedEvent event = new InventoryItemAddedEvent(this.inventory, item); - if (Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + public void addItem(HabboItem item) { + if (item == null) { return; } - synchronized (this.items) - { + InventoryItemAddedEvent event = new InventoryItemAddedEvent(this.inventory, item); + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { + return; + } + + synchronized (this.items) { this.items.put(event.item.getId(), event.item); } } - public void addItems(THashSet items) - { + public void addItems(THashSet items) { InventoryItemsAddedEvent event = new InventoryItemsAddedEvent(this.inventory, items); - if (Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; } - synchronized (this.items) - { - for (HabboItem item : event.items) - { - if(item == null) - { - continue; + synchronized (this.items) { + for (HabboItem item : event.items) { + if (item == null) { + continue; } this.items.put(item.getId(), item); @@ -115,23 +92,17 @@ public class ItemsComponent } } - public HabboItem getHabboItem(int itemId) - { + public HabboItem getHabboItem(int itemId) { return this.items.get(Math.abs(itemId)); } - public HabboItem getAndRemoveHabboItem(final Item item) - { + public HabboItem getAndRemoveHabboItem(final Item item) { final HabboItem[] habboItem = {null}; - synchronized (this.items) - { - this.items.forEachValue(new TObjectProcedure() - { + synchronized (this.items) { + this.items.forEachValue(new TObjectProcedure() { @Override - public boolean execute(HabboItem object) - { - if (object.getBaseItem() == item) - { + public boolean execute(HabboItem object) { + if (object.getBaseItem() == item) { habboItem[0] = object; return false; } @@ -144,64 +115,50 @@ public class ItemsComponent return habboItem[0]; } - public void removeHabboItem(int itemId) - { + public void removeHabboItem(int itemId) { this.items.remove(itemId); } - public void removeHabboItem(HabboItem item) - { + public void removeHabboItem(HabboItem item) { InventoryItemRemovedEvent event = new InventoryItemRemovedEvent(this.inventory, item); - if (Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; } - synchronized (this.items) - { + synchronized (this.items) { this.items.remove(event.item.getId()); } } - public TIntObjectMap getItems() - { + public TIntObjectMap getItems() { return this.items; } - public THashSet getItemsAsValueCollection() - { + public THashSet getItemsAsValueCollection() { THashSet items = new THashSet<>(); items.addAll(this.items.valueCollection()); return items; } - public int itemCount() - { + public int itemCount() { return this.items.size(); } - public void dispose() - { - synchronized (this.items) - { + public void dispose() { + synchronized (this.items) { TIntObjectIterator items = this.items.iterator(); - if (items == null) - { + if (items == null) { Emulator.getLogging().logErrorLine(new RuntimeException("Items is NULL!")); return; } - if (!this.items.isEmpty()) - { - for (int i = this.items.size(); i-- > 0; ) - { - try - { + if (!this.items.isEmpty()) { + for (int i = this.items.size(); i-- > 0; ) { + try { items.advance(); - } catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } if (items.value().needsUpdate()) 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 114ce63a..a402f786 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 @@ -16,93 +16,69 @@ import java.sql.SQLException; import java.util.NoSuchElementException; import java.util.Set; -public class PetsComponent -{ +public class PetsComponent { private final TIntObjectMap pets = TCollections.synchronizedMap(new TIntObjectHashMap<>()); - public PetsComponent(Habbo habbo) - { + public PetsComponent(Habbo habbo) { this.loadPets(habbo); } - private void loadPets(Habbo habbo) - { - synchronized (this.pets) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_pets WHERE user_id = ? AND room_id = 0")) - { + private void loadPets(Habbo habbo) { + synchronized (this.pets) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_pets WHERE user_id = ? AND room_id = 0")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.pets.put(set.getInt("id"), PetManager.loadPet(set)); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - public Pet getPet(int id) - { + public Pet getPet(int id) { return this.pets.get(id); } - public void addPet(Pet pet) - { - synchronized (this.pets) - { + public void addPet(Pet pet) { + synchronized (this.pets) { this.pets.put(pet.getId(), pet); } } - public void addPets(Set pets) - { - synchronized (this.pets) - { - for (Pet p : pets) - { + public void addPets(Set pets) { + synchronized (this.pets) { + for (Pet p : pets) { this.pets.put(p.getId(), p); } } } - public void removePet(Pet pet) - { - synchronized (this.pets) - { + public void removePet(Pet pet) { + synchronized (this.pets) { this.pets.remove(pet.getId()); } } - public TIntObjectMap getPets() - { + public TIntObjectMap getPets() { return this.pets; } - public int getPetsCount() - { + public int getPetsCount() { return this.pets.size(); } - public void dispose() - { - synchronized (this.pets) - { + public void dispose() { + synchronized (this.pets) { TIntObjectIterator petIterator = this.pets.iterator(); - for (int i = this.pets.size(); i-- > 0; ) - { - try - { + for (int i = this.pets.size(); i-- > 0; ) { + try { petIterator.advance(); - } catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } if (petIterator.value().needsUpdate) 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 07cee2f3..19bfdf4c 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 @@ -13,67 +13,52 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class WardrobeComponent -{ +public class WardrobeComponent { private final THashMap looks; private final TIntSet clothing; - public WardrobeComponent(Habbo habbo) - { + public WardrobeComponent(Habbo habbo) { this.looks = new THashMap<>(); this.clothing = new TIntHashSet(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_wardrobe WHERE user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_wardrobe WHERE user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { this.looks.put(set.getInt("slot_id"), new WardrobeItem(set, habbo)); } } } - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_clothing WHERE user_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_clothing WHERE user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { int value = set.getInt("clothing_id"); this.clothing.add(value); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - public WardrobeItem createLook(Habbo habbo, int slotId, String look) - { + public WardrobeItem createLook(Habbo habbo, int slotId, String look) { return new WardrobeItem(habbo.getHabboInfo().getGender(), look, slotId, habbo); } - public THashMap getLooks() - { + public THashMap getLooks() { return this.looks; } - public TIntCollection getClothing() - { + public TIntCollection getClothing() { return this.clothing; } - public void dispose() - { + public void dispose() { this.looks.values().stream().filter(item -> item.needsInsert || item.needsUpdate).forEach(item -> { Emulator.getThreading().run(item); }); @@ -81,8 +66,7 @@ public class WardrobeComponent this.looks.clear(); } - public class WardrobeItem implements Runnable - { + public class WardrobeItem implements Runnable { private int slotId; private HabboGender gender; private Habbo habbo; @@ -90,78 +74,63 @@ public class WardrobeComponent private boolean needsInsert = false; private boolean needsUpdate = false; - private WardrobeItem(ResultSet set, Habbo habbo) throws SQLException - { + private WardrobeItem(ResultSet set, Habbo habbo) throws SQLException { this.gender = HabboGender.valueOf(set.getString("gender")); this.look = set.getString("look"); this.slotId = set.getInt("slot_id"); this.habbo = habbo; } - private WardrobeItem(HabboGender gender, String look, int slotId, Habbo habbo) - { + private WardrobeItem(HabboGender gender, String look, int slotId, Habbo habbo) { this.gender = gender; this.look = look; this.slotId = slotId; this.habbo = habbo; } - public HabboGender getGender() - { + public HabboGender getGender() { return this.gender; } - public void setGender(HabboGender gender) - { + public void setGender(HabboGender gender) { this.gender = gender; } - public Habbo getHabbo() - { + public Habbo getHabbo() { return this.habbo; } - public void setHabbo(Habbo habbo) - { + public void setHabbo(Habbo habbo) { this.habbo = habbo; } - public String getLook() - { + public String getLook() { return this.look; } - public void setLook(String look) - { + public void setLook(String look) { this.look = look; } - public void setNeedsInsert(boolean needsInsert) - { + public void setNeedsInsert(boolean needsInsert) { this.needsInsert = needsInsert; } - public void setNeedsUpdate(boolean needsUpdate) - { + public void setNeedsUpdate(boolean needsUpdate) { this.needsUpdate = needsUpdate; } - public int getSlotId() - { + public int getSlotId() { return this.slotId; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - if(this.needsInsert) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + if (this.needsInsert) { this.needsInsert = false; this.needsUpdate = false; - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_wardrobe (slot_id, look, user_id, gender) VALUES (?, ?, ?, ?)")) - { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_wardrobe (slot_id, look, user_id, gender) VALUES (?, ?, ?, ?)")) { statement.setInt(1, this.slotId); statement.setString(2, this.look); statement.setInt(3, this.habbo.getHabboInfo().getId()); @@ -170,20 +139,16 @@ public class WardrobeComponent } } - if(this.needsUpdate) - { + if (this.needsUpdate) { this.needsUpdate = false; - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_wardrobe SET look = ? WHERE slot_id = ? AND user_id = ?")) - { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_wardrobe SET look = ? WHERE slot_id = ? AND user_id = ?")) { statement.setString(1, this.look); statement.setInt(2, this.slotId); statement.setInt(3, this.habbo.getHabboInfo().getId()); statement.execute(); } } - } - catch(SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionOperator.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionOperator.java index 5253e5f9..71b829d2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionOperator.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionOperator.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredConditionOperator -{ +public enum WiredConditionOperator { AND, OR } \ No newline at end of file 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 878ecf0c..86ffa573 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredConditionType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredConditionType -{ +public enum WiredConditionType { MATCH_SSHOT(0), FURNI_HAVE_HABBO(1), TRIGGER_ON_FURNI(2), @@ -29,8 +28,7 @@ public enum WiredConditionType public final int code; - WiredConditionType(int code) - { + WiredConditionType(int code) { this.code = 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 68bc38e3..951e4d0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredEffectType -{ +public enum WiredEffectType { TOGGLE_STATE(0), RESET_TIMERS(1), MATCH_SSHOT(3), @@ -31,8 +30,7 @@ public enum WiredEffectType public final int code; - WiredEffectType(int code) - { + WiredEffectType(int code) { this.code = 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 03cd7111..dd6ac237 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredGiveRewardItem.java @@ -1,22 +1,19 @@ package com.eu.habbo.habbohotel.wired; -public class WiredGiveRewardItem -{ +public class WiredGiveRewardItem { public final int id; public final boolean badge; public final String data; public final int probability; - public WiredGiveRewardItem(int id, boolean badge, String data, 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) - { + public WiredGiveRewardItem(String dataString) { String[] data = dataString.split(","); this.id = Integer.valueOf(data[0]); @@ -26,13 +23,11 @@ public class WiredGiveRewardItem } @Override - public String toString() - { + public String toString() { return this.id + "," + (this.badge ? 0 : 1) + "," + this.data + "," + this.probability; } - public String wiredString() - { + public String wiredString() { return (this.badge ? 0 : 1) + "," + this.data + "," + this.probability; } } 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 dfb6bd2a..ac1b2cc7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -19,10 +19,10 @@ 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.PurchaseOKComposer; -import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; +import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; import com.eu.habbo.plugin.events.furniture.wired.WiredConditionFailedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; @@ -37,14 +37,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class WiredHandler -{ +public class WiredHandler { //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_FURNI_SELECTION = 5; public static int TELEPORT_DELAY = 500; - public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) - { + public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { if (triggerType == WiredTriggerType.CUSTOM) return false; boolean talked = false; @@ -55,28 +53,26 @@ public class WiredHandler if (room == null) return false; - if(!room.isLoaded()) + if (!room.isLoaded()) return false; - if(room.getRoomSpecialTypes() == null) + if (room.getRoomSpecialTypes() == null) return false; - THashSet triggers = room.getRoomSpecialTypes().getTriggers(triggerType); + THashSet triggers = room.getRoomSpecialTypes().getTriggers(triggerType); - if(triggers == null || triggers.isEmpty()) + if (triggers == null || triggers.isEmpty()) return false; List triggeredTiles = new ArrayList<>(); - for(InteractionWiredTrigger trigger : triggers) - { + for (InteractionWiredTrigger trigger : triggers) { RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY()); if (triggeredTiles.contains(tile)) continue; - if(handle(trigger, roomUnit, room, stuff)) - { - if(triggerType.equals(WiredTriggerType.SAY_SOMETHING)) + if (handle(trigger, roomUnit, room, stuff)) { + if (triggerType.equals(WiredTriggerType.SAY_SOMETHING)) talked = true; triggeredTiles.add(tile); @@ -86,8 +82,7 @@ public class WiredHandler return talked; } - public static boolean handleCustomTrigger(Class triggerType, RoomUnit roomUnit, Room room, Object[] stuff) - { + public static boolean handleCustomTrigger(Class triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { boolean talked = false; if (!Emulator.isReady) @@ -96,20 +91,19 @@ public class WiredHandler if (room == null) return false; - if(!room.isLoaded()) + if (!room.isLoaded()) return false; - if(room.getRoomSpecialTypes() == null) + if (room.getRoomSpecialTypes() == null) return false; - THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.CUSTOM); + THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.CUSTOM); - if(triggers == null || triggers.isEmpty()) + if (triggers == null || triggers.isEmpty()) return false; List triggeredTiles = new ArrayList<>(); - for(InteractionWiredTrigger trigger : triggers) - { + for (InteractionWiredTrigger trigger : triggers) { if (trigger.getClass() != triggerType) continue; RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY()); @@ -117,8 +111,7 @@ public class WiredHandler if (triggeredTiles.contains(tile)) continue; - if(handle(trigger, roomUnit, room, stuff)) - { + if (handle(trigger, roomUnit, room, stuff)) { triggeredTiles.add(tile); } } @@ -126,39 +119,30 @@ public class WiredHandler return talked; } - public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) - { + public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) { long millis = System.currentTimeMillis(); - if(Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) - { + if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) { trigger.setCooldown(millis); trigger.activateBox(room); THashSet conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY()); THashSet effects = room.getRoomSpecialTypes().getEffects(trigger.getX(), trigger.getY()); - if(Emulator.getPluginManager().fireEvent(new WiredStackTriggeredEvent(room, roomUnit, trigger, effects, conditions)).isCancelled()) + if (Emulator.getPluginManager().fireEvent(new WiredStackTriggeredEvent(room, roomUnit, trigger, effects, conditions)).isCancelled()) return false; - if (!conditions.isEmpty()) - { + if (!conditions.isEmpty()) { ArrayList matchedConditions = new ArrayList<>(conditions.size()); - for (InteractionWiredCondition searchMatched : conditions) - { - if (!matchedConditions.contains(searchMatched.getType()) && searchMatched.operator() == WiredConditionOperator.OR && searchMatched.execute(roomUnit, room, stuff)) - { + for (InteractionWiredCondition searchMatched : conditions) { + if (!matchedConditions.contains(searchMatched.getType()) && searchMatched.operator() == WiredConditionOperator.OR && searchMatched.execute(roomUnit, room, stuff)) { matchedConditions.add(searchMatched.getType()); } } - for (InteractionWiredCondition condition : conditions) - { + for (InteractionWiredCondition condition : conditions) { if ((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) || - (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) - { + (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) { condition.activateBox(room); - } - else - { + } else { if (!Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) return false; } @@ -170,39 +154,30 @@ public class WiredHandler boolean hasExtraUnseen = room.getRoomSpecialTypes().hasExtraType(trigger.getX(), trigger.getY(), WiredExtraUnseen.class); THashSet extras = room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY()); - for (InteractionWiredExtra extra : extras) - { + for (InteractionWiredExtra extra : extras) { extra.activateBox(room); } List effectList = new ArrayList<>(effects); - if (hasExtraRandom || hasExtraUnseen) - { + if (hasExtraRandom || hasExtraUnseen) { Collections.shuffle(effectList); } - if (hasExtraUnseen) - { - for (InteractionWiredExtra extra : room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY())) - { - if (extra instanceof WiredExtraUnseen) - { + if (hasExtraUnseen) { + for (InteractionWiredExtra extra : room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY())) { + if (extra instanceof WiredExtraUnseen) { extra.setExtradata(extra.getExtradata().equals("1") ? "0" : "1"); InteractionWiredEffect effect = ((WiredExtraUnseen) extra).getUnseenEffect(effectList); triggerEffect(effect, roomUnit, room, stuff, millis); break; } } - } - else - { - for (final InteractionWiredEffect effect : effectList) - { + } else { + for (final InteractionWiredEffect effect : effectList) { boolean executed = triggerEffect(effect, roomUnit, room, stuff, millis); - if (hasExtraRandom && executed) - { + if (hasExtraRandom && executed) { break; } } @@ -214,28 +189,19 @@ public class WiredHandler return false; } - private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis) - { + private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis) { boolean executed = false; - if (effect != null && effect.canExecute(millis)) - { + if (effect != null && effect.canExecute(millis)) { executed = true; - if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) - { - Emulator.getThreading().run(new Runnable() - { + if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - if (room.isLoaded()) - { - try - { + public void run() { + if (room.isLoaded()) { + try { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -246,23 +212,18 @@ public class WiredHandler } } - return executed; + return executed; } - public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) - { - for(RoomTile tile : tiles) - { - if(room != null) - { + public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { + for (RoomTile tile : tiles) { + if (room != null) { THashSet items = room.getItemsAt(tile); long millis = room.getCycleTimestamp(); - for(final HabboItem item : items) - { - if(item instanceof InteractionWiredEffect && !(item instanceof WiredEffectTriggerStacks)) - { + for (final HabboItem item : items) { + if (item instanceof InteractionWiredEffect && !(item instanceof WiredEffectTriggerStacks)) { triggerEffect((InteractionWiredEffect) item, roomUnit, room, stuff, millis); ((InteractionWiredEffect) item).setCooldown(millis); } @@ -273,44 +234,35 @@ public class WiredHandler return true; } - public static void dropRewards(int wiredId) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM wired_rewards_given WHERE wired_item = ?")) - { + public static void dropRewards(int wiredId) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM wired_rewards_given WHERE wired_item = ?")) { statement.setInt(1, wiredId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } - private static void giveReward(Habbo habbo, WiredEffectGiveReward wiredBox, WiredGiveRewardItem reward) - { - if(wiredBox.limit > 0) + private static void giveReward(Habbo habbo, WiredEffectGiveReward wiredBox, WiredGiveRewardItem reward) { + if (wiredBox.limit > 0) wiredBox.given++; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wired_rewards_given (wired_item, user_id, reward_id, timestamp) VALUES ( ?, ?, ?, ?)")) - { + 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(4, Emulator.getIntUnixTimestamp()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if(reward.badge) - { + if (reward.badge) { UserWiredRewardReceived rewardReceived = new UserWiredRewardReceived(habbo, wiredBox, "badge", reward.data); - if(Emulator.getPluginManager().fireEvent(rewardReceived).isCancelled()) + if (Emulator.getPluginManager().fireEvent(rewardReceived).isCancelled()) return; - if(rewardReceived.value.isEmpty()) + if (rewardReceived.value.isEmpty()) return; HabboBadge badge = new HabboBadge(0, rewardReceived.value, 0, habbo); @@ -318,48 +270,39 @@ public class WiredHandler habbo.getInventory().getBadgesComponent().addBadge(badge); habbo.getClient().sendResponse(new AddUserBadgeComposer(badge)); habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_BADGE)); - } - else - { + } else { String[] data = reward.data.split("#"); - if (data.length == 2) - { + if (data.length == 2) { UserWiredRewardReceived rewardReceived = new UserWiredRewardReceived(habbo, wiredBox, data[0], data[1]); - if(Emulator.getPluginManager().fireEvent(rewardReceived).isCancelled()) + if (Emulator.getPluginManager().fireEvent(rewardReceived).isCancelled()) return; - if(rewardReceived.value.isEmpty()) + if (rewardReceived.value.isEmpty()) return; - if(rewardReceived.type.equalsIgnoreCase("credits")) - { + if (rewardReceived.type.equalsIgnoreCase("credits")) { int credits = Integer.valueOf(rewardReceived.value); habbo.giveCredits(credits); - } - else if(rewardReceived.type.equalsIgnoreCase("pixels")) - { + } else if (rewardReceived.type.equalsIgnoreCase("pixels")) { int pixels = Integer.valueOf(rewardReceived.value); habbo.givePixels(pixels); - } - else if(rewardReceived.type.startsWith("points")) - { + } else if (rewardReceived.type.startsWith("points")) { int points = Integer.valueOf(rewardReceived.value); int type = 5; - try { type = Integer.valueOf(rewardReceived.type.replace("points", "")); } catch ( Exception e) {} + try { + type = Integer.valueOf(rewardReceived.type.replace("points", "")); + } catch (Exception e) { + } habbo.givePoints(type, points); - } - else if(rewardReceived.type.equalsIgnoreCase("furni")) - { + } else if (rewardReceived.type.equalsIgnoreCase("furni")) { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(rewardReceived.value)); - if(baseItem != null) - { + if (baseItem != null) { HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), baseItem, 0, 0, ""); - if(item != null) - { + if (item != null) { habbo.getClient().sendResponse(new AddHabboItemComposer(item)); habbo.getClient().getHabbo().getInventory().getItemsComponent().addItem(item); habbo.getClient().sendResponse(new PurchaseOKComposer(null)); @@ -367,17 +310,12 @@ public class WiredHandler habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_ITEM)); } } - } - else if(rewardReceived.type.equalsIgnoreCase("respect")) - { + } else if (rewardReceived.type.equalsIgnoreCase("respect")) { habbo.getHabboStats().respectPointsReceived += Integer.valueOf(rewardReceived.value); - } - else if (rewardReceived.type.equalsIgnoreCase("cata")) - { + } else if (rewardReceived.type.equalsIgnoreCase("cata")) { CatalogItem item = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(Integer.valueOf(rewardReceived.value)); - if (item != null) - { + if (item != null) { Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, habbo, 1, "", true); } habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_ITEM)); @@ -386,105 +324,80 @@ public class WiredHandler } } - public static boolean getReward(Habbo habbo, WiredEffectGiveReward wiredBox) - { - if(wiredBox.limit > 0) - { - if(wiredBox.limit - wiredBox.given == 0) - { + public static boolean getReward(Habbo habbo, WiredEffectGiveReward wiredBox) { + if (wiredBox.limit > 0) { + if (wiredBox.limit - wiredBox.given == 0) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.LIMITED_NO_MORE_AVAILABLE)); return false; } } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, wiredBox.getId()); statement.setInt(3, wiredBox.rewardItems.size()); - try (ResultSet set = statement.executeQuery()) - { - if (set.first()) - { - if (set.getInt("row_count") >= 1) - { - if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_ONCE) - { + try (ResultSet set = statement.executeQuery()) { + if (set.first()) { + if (set.getInt("row_count") >= 1) { + if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_ONCE) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED)); return false; } } set.beforeFirst(); - if (set.next()) - { - if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_MINUTES) - { - if (Emulator.getIntUnixTimestamp() - set.getInt("timestamp") <= 60) - { + if (set.next()) { + if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_MINUTES) { + if (Emulator.getIntUnixTimestamp() - set.getInt("timestamp") <= 60) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED_THIS_MINUTE)); return false; } } - if (wiredBox.uniqueRewards) - { - if (set.getInt("row_count") == wiredBox.rewardItems.size()) - { + if (wiredBox.uniqueRewards) { + if (set.getInt("row_count") == wiredBox.rewardItems.size()) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALL_COLLECTED)); return false; } } - if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_HOURS) - { - if (!(Emulator.getIntUnixTimestamp() - set.getInt("timestamp") >= (3600 * wiredBox.limitationInterval))) - { + if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_HOURS) { + if (!(Emulator.getIntUnixTimestamp() - set.getInt("timestamp") >= (3600 * wiredBox.limitationInterval))) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED_THIS_HOUR)); return false; } } - if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_DAY) - { - if (!(Emulator.getIntUnixTimestamp() - set.getInt("timestamp") >= (86400 * wiredBox.limitationInterval))) - { + if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_N_DAY) { + if (!(Emulator.getIntUnixTimestamp() - set.getInt("timestamp") >= (86400 * wiredBox.limitationInterval))) { habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED_THIS_TODAY)); return false; } } } - if (wiredBox.uniqueRewards) - { - for (WiredGiveRewardItem item : wiredBox.rewardItems) - { + if (wiredBox.uniqueRewards) { + for (WiredGiveRewardItem item : wiredBox.rewardItems) { set.beforeFirst(); boolean found = false; - while (set.next()) - { + while (set.next()) { if (set.getInt("reward_id") == item.id) found = true; } - if (!found) - { + if (!found) { giveReward(habbo, wiredBox, item); return true; } } - } - else - { + } else { int randomNumber = Emulator.getRandom().nextInt(101); int count = 0; - for (WiredGiveRewardItem item : wiredBox.rewardItems) - { - if (randomNumber >= count && randomNumber <= (count + item.probability)) - { + for (WiredGiveRewardItem item : wiredBox.rewardItems) { + if (randomNumber >= count && randomNumber <= (count + item.probability)) { giveReward(habbo, wiredBox, item); return true; } @@ -494,26 +407,21 @@ public class WiredHandler } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } return false; } - public static void resetTimers(Room room) - { - if(!room.isLoaded()) + public static void resetTimers(Room room) { + if (!room.isLoaded()) return; THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.AT_GIVEN_TIME); - if (triggers != null) - { - for (InteractionWiredTrigger trigger : triggers) - { + if (triggers != null) { + for (InteractionWiredTrigger trigger : triggers) { ((WiredTriggerReset) trigger).resetTimer(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java index a13f7134..aead67bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredHighscoreClearType -{ +public enum WiredHighscoreClearType { ALLTIME(0), DAILY(1), WEEKLY(2), @@ -9,8 +8,7 @@ public enum WiredHighscoreClearType public final int type; - WiredHighscoreClearType(int type) - { + WiredHighscoreClearType(int type) { this.type = type; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java index 5fce052a..07221e5b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java @@ -1,14 +1,12 @@ package com.eu.habbo.habbohotel.wired; -public class WiredHighscoreData -{ +public class WiredHighscoreData { public String[] usernames; public int score; public int teamScore; public int totalScore; - public WiredHighscoreData(String[] usernames, int score, int teamScore, int totalScore) - { + public WiredHighscoreData(String[] usernames, int score, int teamScore, int totalScore) { this.usernames = usernames; this.score = score; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java index 10d8334d..cc2e50a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java @@ -1,15 +1,13 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredHighscoreScoreType -{ +public enum WiredHighscoreScoreType { PERTEAM(0), MOSTWIN(1), CLASSIC(2); public final int type; - WiredHighscoreScoreType(int type) - { + WiredHighscoreScoreType(int type) { this.type = type; } } 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 7398afef..ea6797f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java @@ -1,15 +1,13 @@ package com.eu.habbo.habbohotel.wired; -public class WiredMatchFurniSetting -{ +public class WiredMatchFurniSetting { public final int itemId; public final String state; public final int rotation; public final int x; public final int y; - public WiredMatchFurniSetting(int itemId, String state, int rotation, int x, int y) - { + public WiredMatchFurniSetting(int itemId, String state, int rotation, int x, int y) { this.itemId = itemId; this.state = state.replace("\t\t\t", " "); this.rotation = rotation; @@ -18,13 +16,11 @@ public class WiredMatchFurniSetting } @Override - public String toString() - { + public String toString() { return this.toString(true); } - public String toString(boolean includeState) - { + public String toString(boolean includeState) { return this.itemId + "-" + (this.state.isEmpty() || !includeState ? " " : this.state) + "-" + this.rotation + "-" + this.x + "-" + this.y; } 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 6e07424f..e1286fa1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.wired; -public enum WiredTriggerType -{ +public enum WiredTriggerType { SAY_SOMETHING(0), WALKS_ON_FURNI(1), WALKS_OFF_FURNI(2), @@ -25,8 +24,7 @@ public enum WiredTriggerType public final int code; - WiredTriggerType(int code) - { + WiredTriggerType(int code) { this.code = code; } } diff --git a/src/main/java/com/eu/habbo/messages/ClientMessage.java b/src/main/java/com/eu/habbo/messages/ClientMessage.java index 90b45c1c..9859938e 100644 --- a/src/main/java/com/eu/habbo/messages/ClientMessage.java +++ b/src/main/java/com/eu/habbo/messages/ClientMessage.java @@ -5,99 +5,76 @@ import io.netty.buffer.Unpooled; import java.nio.charset.Charset; -public class ClientMessage -{ +public class ClientMessage { private final int header; private final ByteBuf buffer; - public ByteBuf getBuffer() - { - return this.buffer; - } - - public int getMessageId() - { - return this.header; - } - - public ClientMessage(int messageId, ByteBuf buffer) - { + public ClientMessage(int messageId, ByteBuf buffer) { this.header = messageId; this.buffer = ((buffer == null) || (buffer.readableBytes() == 0) ? Unpooled.EMPTY_BUFFER : buffer); } - public ClientMessage clone() throws CloneNotSupportedException - { + public ByteBuf getBuffer() { + return this.buffer; + } + + public int getMessageId() { + return this.header; + } + + public ClientMessage clone() throws CloneNotSupportedException { return new ClientMessage(this.header, this.buffer.duplicate()); } - public int readShort() - { - try - { + public int readShort() { + try { return this.buffer.readShort(); - } - catch (Exception e) - { + } catch (Exception e) { } return 0; } - public Integer readInt() - { - try - { + public Integer readInt() { + try { return this.buffer.readInt(); - } - catch (Exception e) - { + } catch (Exception e) { } return 0; } - public boolean readBoolean() - { - try - { + public boolean readBoolean() { + try { return this.buffer.readByte() == 1; - } - catch (Exception e) - { + } catch (Exception e) { } return false; } - public String readString() - { - try - { + public String readString() { + try { int length = this.readShort(); byte[] data = new byte[length]; this.buffer.readBytes(data); return new String(data); - } - catch (Exception e) - { + } catch (Exception e) { return ""; } } - public String getMessageBody() - { + public String getMessageBody() { String consoleText = this.buffer.toString(Charset.defaultCharset()); for (int i = -1; i < 31; i++) { - consoleText = consoleText.replace(Character.toString((char)i), "[" + i + "]"); + consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); } return consoleText; } - public int bytesAvailable() - { + public int bytesAvailable() { return this.buffer.readableBytes(); } diff --git a/src/main/java/com/eu/habbo/messages/ICallable.java b/src/main/java/com/eu/habbo/messages/ICallable.java index 47bc44b8..5587fbda 100644 --- a/src/main/java/com/eu/habbo/messages/ICallable.java +++ b/src/main/java/com/eu/habbo/messages/ICallable.java @@ -2,7 +2,6 @@ package com.eu.habbo.messages; import com.eu.habbo.messages.incoming.MessageHandler; -public interface ICallable -{ +public interface ICallable { void call(MessageHandler handler); } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/ISerialize.java b/src/main/java/com/eu/habbo/messages/ISerialize.java index 0b548be2..0099693e 100644 --- a/src/main/java/com/eu/habbo/messages/ISerialize.java +++ b/src/main/java/com/eu/habbo/messages/ISerialize.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages; -public interface ISerialize -{ +public interface ISerialize { void serialize(ServerMessage message); } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 163826c1..42901521 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -74,14 +74,15 @@ import gnu.trove.map.hash.THashMap; import java.util.ArrayList; import java.util.List; -public class PacketManager -{ +public class PacketManager { + private static final List logList = new ArrayList<>(); + public static boolean DEBUG_SHOW_PACKETS = false; + public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; - private static final List logList = new ArrayList<>(); - public PacketManager() throws Exception - { + + public PacketManager() throws Exception { this.incoming = new THashMap<>(); this.callables = new THashMap<>(); @@ -110,63 +111,60 @@ public class PacketManager this.registerGameCenter(); } + @EventHandler + public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) { + logList.clear(); - public void registerHandler(Integer header, Class handler) throws Exception - { + for (String s : Emulator.getConfig().getValue("debug.show.headers").split(";")) { + try { + logList.add(Integer.valueOf(s)); + } catch (Exception e) { + + } + } + } + + public void registerHandler(Integer header, Class handler) throws Exception { if (header < 0) return; - if (this.incoming.containsKey(header)) - { + if (this.incoming.containsKey(header)) { throw new Exception("Header already registered. Failed to register " + handler.getName() + " with header " + header); } this.incoming.putIfAbsent(header, handler); } - - public void registerCallable(Integer header, ICallable callable) - { + public void registerCallable(Integer header, ICallable callable) { this.callables.putIfAbsent(header, new ArrayList<>()); this.callables.get(header).add(callable); } - - public void unregisterCallables(Integer header, ICallable callable) - { - if (this.callables.containsKey(header)) - { + public void unregisterCallables(Integer header, ICallable callable) { + if (this.callables.containsKey(header)) { this.callables.get(header).remove(callable); } } - - public void unregisterCallables(Integer header) - { - if (this.callables.containsKey(header)) - { + public void unregisterCallables(Integer header) { + if (this.callables.containsKey(header)) { this.callables.clear(); } } - - public void handlePacket(GameClient client, ClientMessage packet) - { - if(client == null || Emulator.isShuttingDown) + public void handlePacket(GameClient client, ClientMessage packet) { + if (client == null || Emulator.isShuttingDown) return; if (client.getHabbo() == null && !(packet.getMessageId() == Incoming.SecureLoginEvent || packet.getMessageId() == Incoming.MachineIDEvent)) return; - try - { - if(this.isRegistered(packet.getMessageId())) - { - if(PacketManager.DEBUG_SHOW_PACKETS) + try { + if (this.isRegistered(packet.getMessageId())) { + if (PacketManager.DEBUG_SHOW_PACKETS) Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); - if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) - { + if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) { System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody())); } @@ -175,365 +173,343 @@ public class PacketManager handler.client = client; handler.packet = packet; - if (this.callables.containsKey(packet.getMessageId())) - { - for (ICallable callable : this.callables.get(packet.getMessageId())) - { + if (this.callables.containsKey(packet.getMessageId())) { + for (ICallable callable : this.callables.get(packet.getMessageId())) { callable.call(handler); } } - if (!handler.isCancelled) - { + if (!handler.isCancelled) { handler.handle(); } - } - else - { - if(PacketManager.DEBUG_SHOW_PACKETS) + } else { + if (PacketManager.DEBUG_SHOW_PACKETS) Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - boolean isRegistered(int header) - { + boolean isRegistered(int header) { return this.incoming.containsKey(header); } - private void registerAmbassadors() throws Exception - { - this.registerHandler(Incoming.AmbassadorAlertCommandEvent, AmbassadorAlertCommandEvent.class); - this.registerHandler(Incoming.AmbassadorVisitCommandEvent, AmbassadorVisitCommandEvent.class); + private void registerAmbassadors() throws Exception { + this.registerHandler(Incoming.AmbassadorAlertCommandEvent, AmbassadorAlertCommandEvent.class); + this.registerHandler(Incoming.AmbassadorVisitCommandEvent, AmbassadorVisitCommandEvent.class); } - private void registerCatalog() throws Exception - { - this.registerHandler(Incoming.RequestRecylerLogicEvent, RequestRecyclerLogicEvent.class); - this.registerHandler(Incoming.RequestDiscountEvent, RequestDiscountEvent.class); - this.registerHandler(Incoming.RequestGiftConfigurationEvent, RequestGiftConfigurationEvent.class); - this.registerHandler(Incoming.GetMarketplaceConfigEvent, RequestMarketplaceConfigEvent.class); - this.registerHandler(Incoming.RequestCatalogModeEvent, RequestCatalogModeEvent.class); - this.registerHandler(Incoming.RequestCatalogIndexEvent, RequestCatalogIndexEvent.class); - this.registerHandler(Incoming.RequestCatalogPageEvent, RequestCatalogPageEvent.class); - this.registerHandler(Incoming.CatalogBuyItemAsGiftEvent, CatalogBuyItemAsGiftEvent.class); - this.registerHandler(Incoming.CatalogBuyItemEvent, CatalogBuyItemEvent.class); - this.registerHandler(Incoming.RedeemVoucherEvent, RedeemVoucherEvent.class); - this.registerHandler(Incoming.ReloadRecyclerEvent, ReloadRecyclerEvent.class); - this.registerHandler(Incoming.RecycleEvent, RecycleEvent.class); - this.registerHandler(Incoming.OpenRecycleBoxEvent, OpenRecycleBoxEvent.class); - this.registerHandler(Incoming.RequestOwnItemsEvent, RequestOwnItemsEvent.class); - this.registerHandler(Incoming.TakeBackItemEvent, TakeBackItemEvent.class); - this.registerHandler(Incoming.RequestOffersEvent, RequestOffersEvent.class); - this.registerHandler(Incoming.RequestItemInfoEvent, RequestItemInfoEvent.class); - this.registerHandler(Incoming.BuyItemEvent, BuyItemEvent.class); - this.registerHandler(Incoming.RequestSellItemEvent, RequestSellItemEvent.class); - this.registerHandler(Incoming.SellItemEvent, SellItemEvent.class); - this.registerHandler(Incoming.RequestCreditsEvent, RequestCreditsEvent.class); - this.registerHandler(Incoming.RequestPetBreedsEvent, RequestPetBreedsEvent.class); - this.registerHandler(Incoming.CheckPetNameEvent, CheckPetNameEvent.class); - this.registerHandler(Incoming.GetClubDataEvent, RequestClubDataEvent.class); - this.registerHandler(Incoming.RequestClubGiftsEvent, RequestClubGiftsEvent.class); - this.registerHandler(Incoming.CatalogSearchedItemEvent, CatalogSearchedItemEvent.class); - this.registerHandler(Incoming.PurchaseTargetOfferEvent, PurchaseTargetOfferEvent.class); - this.registerHandler(Incoming.TargetOfferStateEvent, TargetOfferStateEvent.class); + private void registerCatalog() throws Exception { + this.registerHandler(Incoming.RequestRecylerLogicEvent, RequestRecyclerLogicEvent.class); + this.registerHandler(Incoming.RequestDiscountEvent, RequestDiscountEvent.class); + this.registerHandler(Incoming.RequestGiftConfigurationEvent, RequestGiftConfigurationEvent.class); + this.registerHandler(Incoming.GetMarketplaceConfigEvent, RequestMarketplaceConfigEvent.class); + this.registerHandler(Incoming.RequestCatalogModeEvent, RequestCatalogModeEvent.class); + this.registerHandler(Incoming.RequestCatalogIndexEvent, RequestCatalogIndexEvent.class); + this.registerHandler(Incoming.RequestCatalogPageEvent, RequestCatalogPageEvent.class); + this.registerHandler(Incoming.CatalogBuyItemAsGiftEvent, CatalogBuyItemAsGiftEvent.class); + this.registerHandler(Incoming.CatalogBuyItemEvent, CatalogBuyItemEvent.class); + this.registerHandler(Incoming.RedeemVoucherEvent, RedeemVoucherEvent.class); + this.registerHandler(Incoming.ReloadRecyclerEvent, ReloadRecyclerEvent.class); + this.registerHandler(Incoming.RecycleEvent, RecycleEvent.class); + this.registerHandler(Incoming.OpenRecycleBoxEvent, OpenRecycleBoxEvent.class); + this.registerHandler(Incoming.RequestOwnItemsEvent, RequestOwnItemsEvent.class); + this.registerHandler(Incoming.TakeBackItemEvent, TakeBackItemEvent.class); + this.registerHandler(Incoming.RequestOffersEvent, RequestOffersEvent.class); + this.registerHandler(Incoming.RequestItemInfoEvent, RequestItemInfoEvent.class); + this.registerHandler(Incoming.BuyItemEvent, BuyItemEvent.class); + this.registerHandler(Incoming.RequestSellItemEvent, RequestSellItemEvent.class); + this.registerHandler(Incoming.SellItemEvent, SellItemEvent.class); + this.registerHandler(Incoming.RequestCreditsEvent, RequestCreditsEvent.class); + this.registerHandler(Incoming.RequestPetBreedsEvent, RequestPetBreedsEvent.class); + this.registerHandler(Incoming.CheckPetNameEvent, CheckPetNameEvent.class); + this.registerHandler(Incoming.GetClubDataEvent, RequestClubDataEvent.class); + this.registerHandler(Incoming.RequestClubGiftsEvent, RequestClubGiftsEvent.class); + this.registerHandler(Incoming.CatalogSearchedItemEvent, CatalogSearchedItemEvent.class); + this.registerHandler(Incoming.PurchaseTargetOfferEvent, PurchaseTargetOfferEvent.class); + this.registerHandler(Incoming.TargetOfferStateEvent, TargetOfferStateEvent.class); } - private void registerEvent() throws Exception - { - this.registerHandler(Incoming.AdventCalendarOpenDayEvent, AdventCalendarOpenDayEvent.class); - this.registerHandler(Incoming.AdventCalendarForceOpenEvent, AdventCalendarForceOpenEvent.class); + private void registerEvent() throws Exception { + this.registerHandler(Incoming.AdventCalendarOpenDayEvent, AdventCalendarOpenDayEvent.class); + this.registerHandler(Incoming.AdventCalendarForceOpenEvent, AdventCalendarForceOpenEvent.class); } - private void registerHandshake() throws Exception - { - this.registerHandler(Incoming.ReleaseVersionEvent, ReleaseVersionEvent.class); - this.registerHandler(Incoming.GenerateSecretKeyEvent, GenerateSecretKeyEvent.class); - this.registerHandler(Incoming.RequestBannerToken, RequestBannerToken.class); - this.registerHandler(Incoming.SecureLoginEvent, SecureLoginEvent.class); - this.registerHandler(Incoming.MachineIDEvent, MachineIDEvent.class); - this.registerHandler(Incoming.UsernameEvent, UsernameEvent.class); - this.registerHandler(Incoming.PingEvent, PingEvent.class); + private void registerHandshake() throws Exception { + this.registerHandler(Incoming.ReleaseVersionEvent, ReleaseVersionEvent.class); + this.registerHandler(Incoming.GenerateSecretKeyEvent, GenerateSecretKeyEvent.class); + this.registerHandler(Incoming.RequestBannerToken, RequestBannerToken.class); + this.registerHandler(Incoming.SecureLoginEvent, SecureLoginEvent.class); + this.registerHandler(Incoming.MachineIDEvent, MachineIDEvent.class); + this.registerHandler(Incoming.UsernameEvent, UsernameEvent.class); + this.registerHandler(Incoming.PingEvent, PingEvent.class); } - private void registerFriends() throws Exception - { - this.registerHandler(Incoming.RequestFriendsEvent, RequestFriendsEvent.class); - this.registerHandler(Incoming.ChangeRelationEvent, ChangeRelationEvent.class); - this.registerHandler(Incoming.RemoveFriendEvent, RemoveFriendEvent.class); - this.registerHandler(Incoming.SearchUserEvent, SearchUserEvent.class); - this.registerHandler(Incoming.FriendRequestEvent, FriendRequestEvent.class); - this.registerHandler(Incoming.AcceptFriendRequest, AcceptFriendRequestEvent.class); - this.registerHandler(Incoming.DeclineFriendRequest, DeclineFriendRequestEvent.class); - this.registerHandler(Incoming.FriendPrivateMessageEvent, FriendPrivateMessageEvent.class); - this.registerHandler(Incoming.RequestFriendRequestEvent, RequestFriendRequestsEvent.class); - this.registerHandler(Incoming.StalkFriendEvent, StalkFriendEvent.class); - this.registerHandler(Incoming.RequestInitFriendsEvent, RequestInitFriendsEvent.class); - this.registerHandler(Incoming.FindNewFriendsEvent, FindNewFriendsEvent.class); - this.registerHandler(Incoming.InviteFriendsEvent, InviteFriendsEvent.class); + private void registerFriends() throws Exception { + this.registerHandler(Incoming.RequestFriendsEvent, RequestFriendsEvent.class); + this.registerHandler(Incoming.ChangeRelationEvent, ChangeRelationEvent.class); + this.registerHandler(Incoming.RemoveFriendEvent, RemoveFriendEvent.class); + this.registerHandler(Incoming.SearchUserEvent, SearchUserEvent.class); + this.registerHandler(Incoming.FriendRequestEvent, FriendRequestEvent.class); + this.registerHandler(Incoming.AcceptFriendRequest, AcceptFriendRequestEvent.class); + this.registerHandler(Incoming.DeclineFriendRequest, DeclineFriendRequestEvent.class); + this.registerHandler(Incoming.FriendPrivateMessageEvent, FriendPrivateMessageEvent.class); + this.registerHandler(Incoming.RequestFriendRequestEvent, RequestFriendRequestsEvent.class); + this.registerHandler(Incoming.StalkFriendEvent, StalkFriendEvent.class); + this.registerHandler(Incoming.RequestInitFriendsEvent, RequestInitFriendsEvent.class); + this.registerHandler(Incoming.FindNewFriendsEvent, FindNewFriendsEvent.class); + this.registerHandler(Incoming.InviteFriendsEvent, InviteFriendsEvent.class); } - private void registerUsers() throws Exception - { - this.registerHandler(Incoming.RequestUserDataEvent, RequestUserDataEvent.class); - this.registerHandler(Incoming.RequestUserCreditsEvent, RequestUserCreditsEvent.class); - this.registerHandler(Incoming.RequestUserClubEvent, RequestUserClubEvent.class); - this.registerHandler(Incoming.RequestMeMenuSettingsEvent, RequestMeMenuSettingsEvent.class); - this.registerHandler(Incoming.RequestUserCitizinShipEvent, RequestUserCitizinShipEvent.class); - this.registerHandler(Incoming.RequestUserProfileEvent, RequestUserProfileEvent.class); - this.registerHandler(Incoming.RequestProfileFriendsEvent, RequestProfileFriendsEvent.class); - this.registerHandler(Incoming.RequestUserWardrobeEvent, RequestUserWardrobeEvent.class); - this.registerHandler(Incoming.SaveWardrobeEvent, SaveWardrobeEvent.class); - this.registerHandler(Incoming.SaveMottoEvent, SaveMottoEvent.class); - this.registerHandler(Incoming.UserSaveLookEvent, UserSaveLookEvent.class); - this.registerHandler(Incoming.UserWearBadgeEvent, UserWearBadgeEvent.class); - this.registerHandler(Incoming.RequestWearingBadgesEvent, RequestWearingBadgesEvent.class); - this.registerHandler(Incoming.SaveUserVolumesEvent, SaveUserVolumesEvent.class); - this.registerHandler(Incoming.SaveBlockCameraFollowEvent, SaveBlockCameraFollowEvent.class); - this.registerHandler(Incoming.SaveIgnoreRoomInvitesEvent, SaveIgnoreRoomInvitesEvent.class); - this.registerHandler(Incoming.SavePreferOldChatEvent, SavePreferOldChatEvent.class); - this.registerHandler(Incoming.ActivateEffectEvent, ActivateEffectEvent.class); - this.registerHandler(Incoming.EnableEffectEvent, EnableEffectEvent.class); - this.registerHandler(Incoming.UserActivityEvent, UserActivityEvent.class); - this.registerHandler(Incoming.UserNuxEvent, UserNuxEvent.class); - this.registerHandler(Incoming.PickNewUserGiftEvent, PickNewUserGiftEvent.class); - this.registerHandler(Incoming.ChangeNameCheckUsernameEvent, ChangeNameCheckUsernameEvent.class); - this.registerHandler(Incoming.ConfirmChangeNameEvent, ConfirmChangeNameEvent.class); - this.registerHandler(Incoming.ChangeChatBubbleEvent, ChangeChatBubbleEvent.class); + private void registerUsers() throws Exception { + this.registerHandler(Incoming.RequestUserDataEvent, RequestUserDataEvent.class); + this.registerHandler(Incoming.RequestUserCreditsEvent, RequestUserCreditsEvent.class); + this.registerHandler(Incoming.RequestUserClubEvent, RequestUserClubEvent.class); + this.registerHandler(Incoming.RequestMeMenuSettingsEvent, RequestMeMenuSettingsEvent.class); + this.registerHandler(Incoming.RequestUserCitizinShipEvent, RequestUserCitizinShipEvent.class); + this.registerHandler(Incoming.RequestUserProfileEvent, RequestUserProfileEvent.class); + this.registerHandler(Incoming.RequestProfileFriendsEvent, RequestProfileFriendsEvent.class); + this.registerHandler(Incoming.RequestUserWardrobeEvent, RequestUserWardrobeEvent.class); + this.registerHandler(Incoming.SaveWardrobeEvent, SaveWardrobeEvent.class); + this.registerHandler(Incoming.SaveMottoEvent, SaveMottoEvent.class); + this.registerHandler(Incoming.UserSaveLookEvent, UserSaveLookEvent.class); + this.registerHandler(Incoming.UserWearBadgeEvent, UserWearBadgeEvent.class); + this.registerHandler(Incoming.RequestWearingBadgesEvent, RequestWearingBadgesEvent.class); + this.registerHandler(Incoming.SaveUserVolumesEvent, SaveUserVolumesEvent.class); + this.registerHandler(Incoming.SaveBlockCameraFollowEvent, SaveBlockCameraFollowEvent.class); + this.registerHandler(Incoming.SaveIgnoreRoomInvitesEvent, SaveIgnoreRoomInvitesEvent.class); + this.registerHandler(Incoming.SavePreferOldChatEvent, SavePreferOldChatEvent.class); + this.registerHandler(Incoming.ActivateEffectEvent, ActivateEffectEvent.class); + this.registerHandler(Incoming.EnableEffectEvent, EnableEffectEvent.class); + this.registerHandler(Incoming.UserActivityEvent, UserActivityEvent.class); + this.registerHandler(Incoming.UserNuxEvent, UserNuxEvent.class); + this.registerHandler(Incoming.PickNewUserGiftEvent, PickNewUserGiftEvent.class); + this.registerHandler(Incoming.ChangeNameCheckUsernameEvent, ChangeNameCheckUsernameEvent.class); + this.registerHandler(Incoming.ConfirmChangeNameEvent, ConfirmChangeNameEvent.class); + this.registerHandler(Incoming.ChangeChatBubbleEvent, ChangeChatBubbleEvent.class); } - private void registerNavigator() throws Exception - { - this.registerHandler(Incoming.RequestRoomCategoriesEvent, RequestRoomCategoriesEvent.class); - this.registerHandler(Incoming.RequestPopularRoomsEvent, RequestPopularRoomsEvent.class); - this.registerHandler(Incoming.RequestHighestScoreRoomsEvent, RequestHighestScoreRoomsEvent.class); - this.registerHandler(Incoming.RequestMyRoomsEvent, RequestMyRoomsEvent.class); - this.registerHandler(Incoming.RequestCanCreateRoomEvent, RequestCanCreateRoomEvent.class); - this.registerHandler(Incoming.RequestPromotedRoomsEvent, RequestPromotedRoomsEvent.class); - this.registerHandler(Incoming.RequestCreateRoomEvent, RequestCreateRoomEvent.class); - this.registerHandler(Incoming.RequestTagsEvent, RequestTagsEvent.class); - this.registerHandler(Incoming.SearchRoomsByTagEvent, SearchRoomsByTagEvent.class); - this.registerHandler(Incoming.SearchRoomsEvent, SearchRoomsEvent.class); - this.registerHandler(Incoming.SearchRoomsFriendsNowEvent, SearchRoomsFriendsNowEvent.class); - this.registerHandler(Incoming.SearchRoomsFriendsOwnEvent, SearchRoomsFriendsOwnEvent.class); - this.registerHandler(Incoming.SearchRoomsWithRightsEvent, SearchRoomsWithRightsEvent.class); - this.registerHandler(Incoming.SearchRoomsInGroupEvent, SearchRoomsInGroupEvent.class); - this.registerHandler(Incoming.SearchRoomsMyFavoriteEvent, SearchRoomsMyFavouriteEvent.class); - this.registerHandler(Incoming.SearchRoomsVisitedEvent, SearchRoomsVisitedEvent.class); - this.registerHandler(Incoming.RequestNewNavigatorDataEvent, RequestNewNavigatorDataEvent.class); - this.registerHandler(Incoming.RequestNewNavigatorRoomsEvent, RequestNewNavigatorRoomsEvent.class); - this.registerHandler(Incoming.NewNavigatorActionEvent, NewNavigatorActionEvent.class); - this.registerHandler(Incoming.RequestNavigatorSettingsEvent, RequestNavigatorSettingsEvent.class); - this.registerHandler(Incoming.SaveWindowSettingsEvent, SaveWindowSettingsEvent.class); - this.registerHandler(Incoming.RequestDeleteRoomEvent, RequestDeleteRoomEvent.class); - this.registerHandler(Incoming.NavigatorCategoryListModeEvent, NavigatorCategoryListModeEvent.class); - this.registerHandler(Incoming.NavigatorCollapseCategoryEvent, NavigatorCollapseCategoryEvent.class); - this.registerHandler(Incoming.NavigatorUncollapseCategoryEvent, NavigatorUncollapseCategoryEvent.class); + private void registerNavigator() throws Exception { + this.registerHandler(Incoming.RequestRoomCategoriesEvent, RequestRoomCategoriesEvent.class); + this.registerHandler(Incoming.RequestPopularRoomsEvent, RequestPopularRoomsEvent.class); + this.registerHandler(Incoming.RequestHighestScoreRoomsEvent, RequestHighestScoreRoomsEvent.class); + this.registerHandler(Incoming.RequestMyRoomsEvent, RequestMyRoomsEvent.class); + this.registerHandler(Incoming.RequestCanCreateRoomEvent, RequestCanCreateRoomEvent.class); + this.registerHandler(Incoming.RequestPromotedRoomsEvent, RequestPromotedRoomsEvent.class); + this.registerHandler(Incoming.RequestCreateRoomEvent, RequestCreateRoomEvent.class); + this.registerHandler(Incoming.RequestTagsEvent, RequestTagsEvent.class); + this.registerHandler(Incoming.SearchRoomsByTagEvent, SearchRoomsByTagEvent.class); + this.registerHandler(Incoming.SearchRoomsEvent, SearchRoomsEvent.class); + this.registerHandler(Incoming.SearchRoomsFriendsNowEvent, SearchRoomsFriendsNowEvent.class); + this.registerHandler(Incoming.SearchRoomsFriendsOwnEvent, SearchRoomsFriendsOwnEvent.class); + this.registerHandler(Incoming.SearchRoomsWithRightsEvent, SearchRoomsWithRightsEvent.class); + this.registerHandler(Incoming.SearchRoomsInGroupEvent, SearchRoomsInGroupEvent.class); + this.registerHandler(Incoming.SearchRoomsMyFavoriteEvent, SearchRoomsMyFavouriteEvent.class); + this.registerHandler(Incoming.SearchRoomsVisitedEvent, SearchRoomsVisitedEvent.class); + this.registerHandler(Incoming.RequestNewNavigatorDataEvent, RequestNewNavigatorDataEvent.class); + this.registerHandler(Incoming.RequestNewNavigatorRoomsEvent, RequestNewNavigatorRoomsEvent.class); + this.registerHandler(Incoming.NewNavigatorActionEvent, NewNavigatorActionEvent.class); + this.registerHandler(Incoming.RequestNavigatorSettingsEvent, RequestNavigatorSettingsEvent.class); + this.registerHandler(Incoming.SaveWindowSettingsEvent, SaveWindowSettingsEvent.class); + this.registerHandler(Incoming.RequestDeleteRoomEvent, RequestDeleteRoomEvent.class); + this.registerHandler(Incoming.NavigatorCategoryListModeEvent, NavigatorCategoryListModeEvent.class); + this.registerHandler(Incoming.NavigatorCollapseCategoryEvent, NavigatorCollapseCategoryEvent.class); + this.registerHandler(Incoming.NavigatorUncollapseCategoryEvent, NavigatorUncollapseCategoryEvent.class); } - private void registerHotelview() throws Exception - { - this.registerHandler(Incoming.HotelViewEvent, HotelViewEvent.class); - this.registerHandler(Incoming.HotelViewRequestBonusRareEvent, HotelViewRequestBonusRareEvent.class); - this.registerHandler(Incoming.RequestNewsListEvent, RequestNewsListEvent.class); - this.registerHandler(Incoming.HotelViewDataEvent, HotelViewDataEvent.class); - this.registerHandler(Incoming.HotelViewRequestBadgeRewardEvent, HotelViewRequestBadgeRewardEvent.class); - this.registerHandler(Incoming.HotelViewClaimBadgeRewardEvent, HotelViewClaimBadgeRewardEvent.class); - this.registerHandler(Incoming.HotelViewRequestLTDAvailabilityEvent, HotelViewRequestLTDAvailabilityEvent.class); + private void registerHotelview() throws Exception { + this.registerHandler(Incoming.HotelViewEvent, HotelViewEvent.class); + this.registerHandler(Incoming.HotelViewRequestBonusRareEvent, HotelViewRequestBonusRareEvent.class); + this.registerHandler(Incoming.RequestNewsListEvent, RequestNewsListEvent.class); + this.registerHandler(Incoming.HotelViewDataEvent, HotelViewDataEvent.class); + this.registerHandler(Incoming.HotelViewRequestBadgeRewardEvent, HotelViewRequestBadgeRewardEvent.class); + this.registerHandler(Incoming.HotelViewClaimBadgeRewardEvent, HotelViewClaimBadgeRewardEvent.class); + this.registerHandler(Incoming.HotelViewRequestLTDAvailabilityEvent, HotelViewRequestLTDAvailabilityEvent.class); } - private void registerInventory() throws Exception - { + private void registerInventory() throws Exception { //this.registerHandler(Incoming.TestInventoryEvent, TestInventoryEvent.class); - this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); - this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); - this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); - this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); + this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); + this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); + this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); + this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); } - void registerRooms() throws Exception - { - this.registerHandler(Incoming.RequestRoomLoadEvent, RequestRoomLoadEvent.class); - this.registerHandler(Incoming.RequestHeightmapEvent, RequestRoomHeightmapEvent.class); - this.registerHandler(Incoming.RequestRoomHeightmapEvent, RequestRoomHeightmapEvent.class); - this.registerHandler(Incoming.RoomVoteEvent, RoomVoteEvent.class); - this.registerHandler(Incoming.RequestRoomDataEvent, RequestRoomDataEvent.class); - this.registerHandler(Incoming.RoomSettingsSaveEvent, RoomSettingsSaveEvent.class); - this.registerHandler(Incoming.RoomPlaceItemEvent, RoomPlaceItemEvent.class); - this.registerHandler(Incoming.RotateMoveItemEvent, RotateMoveItemEvent.class); - this.registerHandler(Incoming.MoveWallItemEvent, MoveWallItemEvent.class); - this.registerHandler(Incoming.RoomPickupItemEvent, RoomPickupItemEvent.class); - this.registerHandler(Incoming.RoomPlacePaintEvent, RoomPlacePaintEvent.class); - this.registerHandler(Incoming.RoomUserStartTypingEvent, RoomUserStartTypingEvent.class); - this.registerHandler(Incoming.RoomUserStopTypingEvent, RoomUserStopTypingEvent.class); - this.registerHandler(Incoming.ToggleFloorItemEvent, ToggleFloorItemEvent.class); - this.registerHandler(Incoming.ToggleWallItemEvent, ToggleWallItemEvent.class); - this.registerHandler(Incoming.RoomBackgroundEvent, RoomBackgroundEvent.class); - this.registerHandler(Incoming.MannequinSaveNameEvent, MannequinSaveNameEvent.class); - this.registerHandler(Incoming.MannequinSaveLookEvent, MannequinSaveLookEvent.class); - this.registerHandler(Incoming.FootballGateSaveLookEvent, FootballGateSaveLookEvent.class); - this.registerHandler(Incoming.AdvertisingSaveEvent, AdvertisingSaveEvent.class); - this.registerHandler(Incoming.RequestRoomSettingsEvent, RequestRoomSettingsEvent.class); - this.registerHandler(Incoming.MoodLightSettingsEvent, MoodLightSettingsEvent.class); - this.registerHandler(Incoming.MoodLightTurnOnEvent, MoodLightTurnOnEvent.class); - this.registerHandler(Incoming.RoomUserDropHandItemEvent, RoomUserDropHandItemEvent.class); - this.registerHandler(Incoming.RoomUserLookAtPoint, RoomUserLookAtPoint.class); - this.registerHandler(Incoming.RoomUserTalkEvent, RoomUserTalkEvent.class); - this.registerHandler(Incoming.RoomUserShoutEvent, RoomUserShoutEvent.class); - this.registerHandler(Incoming.RoomUserWhisperEvent, RoomUserWhisperEvent.class); - this.registerHandler(Incoming.RoomUserActionEvent, RoomUserActionEvent.class); - this.registerHandler(Incoming.RoomUserSitEvent, RoomUserSitEvent.class); - this.registerHandler(Incoming.RoomUserDanceEvent, RoomUserDanceEvent.class); - this.registerHandler(Incoming.RoomUserSignEvent, RoomUserSignEvent.class); - this.registerHandler(Incoming.RoomUserWalkEvent, RoomUserWalkEvent.class); - this.registerHandler(Incoming.RoomUserGiveRespectEvent, RoomUserGiveRespectEvent.class); - this.registerHandler(Incoming.RoomUserGiveRightsEvent, RoomUserGiveRightsEvent.class); - this.registerHandler(Incoming.RoomRemoveRightsEvent, RoomRemoveRightsEvent.class); - this.registerHandler(Incoming.RequestRoomRightsEvent, RequestRoomRightsEvent.class); - this.registerHandler(Incoming.RoomRemoveAllRightsEvent, RoomRemoveAllRightsEvent.class); - this.registerHandler(Incoming.RoomUserRemoveRightsEvent, RoomUserRemoveRightsEvent.class); - this.registerHandler(Incoming.BotPlaceEvent, BotPlaceEvent.class); - this.registerHandler(Incoming.BotPickupEvent, BotPickupEvent.class); - this.registerHandler(Incoming.BotSaveSettingsEvent, BotSaveSettingsEvent.class); - this.registerHandler(Incoming.BotSettingsEvent, BotSettingsEvent.class); - this.registerHandler(Incoming.TriggerDiceEvent, TriggerDiceEvent.class); - this.registerHandler(Incoming.CloseDiceEvent, CloseDiceEvent.class); - this.registerHandler(Incoming.TriggerColorWheelEvent, TriggerColorWheelEvent.class); - this.registerHandler(Incoming.RedeemItemEvent, RedeemItemEvent.class); - this.registerHandler(Incoming.PetPlaceEvent, PetPlaceEvent.class); - this.registerHandler(Incoming.RoomUserKickEvent, RoomUserKickEvent.class); - this.registerHandler(Incoming.SetStackHelperHeightEvent, SetStackHelperHeightEvent.class); - this.registerHandler(Incoming.TriggerOneWayGateEvent, TriggerOneWayGateEvent.class); - this.registerHandler(Incoming.HandleDoorbellEvent, HandleDoorbellEvent.class); - this.registerHandler(Incoming.RedeemClothingEvent, RedeemClothingEvent.class); - this.registerHandler(Incoming.PostItPlaceEvent, PostItPlaceEvent.class); - this.registerHandler(Incoming.PostItRequestDataEvent, PostItRequestDataEvent.class); - this.registerHandler(Incoming.PostItSaveDataEvent, PostItSaveDataEvent.class); - this.registerHandler(Incoming.PostItDeleteEvent, PostItDeleteEvent.class); - this.registerHandler(Incoming.MoodLightSaveSettingsEvent, MoodLightSaveSettingsEvent.class); - this.registerHandler(Incoming.RentSpaceEvent, RentSpaceEvent.class); - this.registerHandler(Incoming.RentSpaceCancelEvent, RentSpaceCancelEvent.class); - this.registerHandler(Incoming.SetHomeRoomEvent, SetHomeRoomEvent.class); - this.registerHandler(Incoming.RoomUserGiveHandItemEvent, RoomUserGiveHandItemEvent.class); - this.registerHandler(Incoming.RoomMuteEvent, RoomMuteEvent.class); - this.registerHandler(Incoming.RequestRoomWordFilterEvent, RequestRoomWordFilterEvent.class); - this.registerHandler(Incoming.RoomWordFilterModifyEvent, RoomWordFilterModifyEvent.class); - this.registerHandler(Incoming.RoomStaffPickEvent, RoomStaffPickEvent.class); - this.registerHandler(Incoming.RoomRequestBannedUsersEvent, RoomRequestBannedUsersEvent.class); - this.registerHandler(Incoming.JukeBoxRequestTrackCodeEvent, JukeBoxRequestTrackCodeEvent.class); - this.registerHandler(Incoming.JukeBoxRequestTrackDataEvent, JukeBoxRequestTrackDataEvent.class); - this.registerHandler(Incoming.JukeBoxAddSoundTrackEvent, JukeBoxAddSoundTrackEvent.class); - this.registerHandler(Incoming.JukeBoxRemoveSoundTrackEvent, JukeBoxRemoveSoundTrackEvent.class); - this.registerHandler(Incoming.JukeBoxRequestPlayListEvent, JukeBoxRequestPlayListEvent.class); - this.registerHandler(Incoming.JukeBoxEventOne, JukeBoxEventOne.class); - this.registerHandler(Incoming.JukeBoxEventTwo, JukeBoxEventTwo.class); - this.registerHandler(Incoming.SavePostItStickyPoleEvent, SavePostItStickyPoleEvent.class); - this.registerHandler(Incoming.RequestPromotionRoomsEvent, RequestPromotionRoomsEvent.class); - this.registerHandler(Incoming.BuyRoomPromotionEvent, BuyRoomPromotionEvent.class); - this.registerHandler(Incoming.EditRoomPromotionMessageEvent, UpdateRoomPromotionEvent.class); - this.registerHandler(Incoming.IgnoreRoomUserEvent, IgnoreRoomUserEvent.class); - this.registerHandler(Incoming.UnIgnoreRoomUserEvent, UnIgnoreRoomUserEvent.class); - this.registerHandler(Incoming.RoomUserMuteEvent, RoomUserMuteEvent.class); - this.registerHandler(Incoming.RoomUserBanEvent, RoomUserBanEvent.class); - this.registerHandler(Incoming.UnbanRoomUserEvent, UnbanRoomUserEvent.class); - this.registerHandler(Incoming.RequestRoomUserTagsEvent, RequestRoomUserTagsEvent.class); - this.registerHandler(Incoming.YoutubeRequestPlayListEvent, YoutubeRequestPlayListEvent.class); - this.registerHandler(Incoming.YoutubeRequestNextVideoEvent, YoutubeRequestNextVideoEvent.class); - this.registerHandler(Incoming.YoutubeRequestVideoDataEvent, YoutubeRequestVideoDataEvent.class); - this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class); - this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class); - this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class); + void registerRooms() throws Exception { + this.registerHandler(Incoming.RequestRoomLoadEvent, RequestRoomLoadEvent.class); + this.registerHandler(Incoming.RequestHeightmapEvent, RequestRoomHeightmapEvent.class); + this.registerHandler(Incoming.RequestRoomHeightmapEvent, RequestRoomHeightmapEvent.class); + this.registerHandler(Incoming.RoomVoteEvent, RoomVoteEvent.class); + this.registerHandler(Incoming.RequestRoomDataEvent, RequestRoomDataEvent.class); + this.registerHandler(Incoming.RoomSettingsSaveEvent, RoomSettingsSaveEvent.class); + this.registerHandler(Incoming.RoomPlaceItemEvent, RoomPlaceItemEvent.class); + this.registerHandler(Incoming.RotateMoveItemEvent, RotateMoveItemEvent.class); + this.registerHandler(Incoming.MoveWallItemEvent, MoveWallItemEvent.class); + this.registerHandler(Incoming.RoomPickupItemEvent, RoomPickupItemEvent.class); + this.registerHandler(Incoming.RoomPlacePaintEvent, RoomPlacePaintEvent.class); + this.registerHandler(Incoming.RoomUserStartTypingEvent, RoomUserStartTypingEvent.class); + this.registerHandler(Incoming.RoomUserStopTypingEvent, RoomUserStopTypingEvent.class); + this.registerHandler(Incoming.ToggleFloorItemEvent, ToggleFloorItemEvent.class); + this.registerHandler(Incoming.ToggleWallItemEvent, ToggleWallItemEvent.class); + this.registerHandler(Incoming.RoomBackgroundEvent, RoomBackgroundEvent.class); + this.registerHandler(Incoming.MannequinSaveNameEvent, MannequinSaveNameEvent.class); + this.registerHandler(Incoming.MannequinSaveLookEvent, MannequinSaveLookEvent.class); + this.registerHandler(Incoming.FootballGateSaveLookEvent, FootballGateSaveLookEvent.class); + this.registerHandler(Incoming.AdvertisingSaveEvent, AdvertisingSaveEvent.class); + this.registerHandler(Incoming.RequestRoomSettingsEvent, RequestRoomSettingsEvent.class); + this.registerHandler(Incoming.MoodLightSettingsEvent, MoodLightSettingsEvent.class); + this.registerHandler(Incoming.MoodLightTurnOnEvent, MoodLightTurnOnEvent.class); + this.registerHandler(Incoming.RoomUserDropHandItemEvent, RoomUserDropHandItemEvent.class); + this.registerHandler(Incoming.RoomUserLookAtPoint, RoomUserLookAtPoint.class); + this.registerHandler(Incoming.RoomUserTalkEvent, RoomUserTalkEvent.class); + this.registerHandler(Incoming.RoomUserShoutEvent, RoomUserShoutEvent.class); + this.registerHandler(Incoming.RoomUserWhisperEvent, RoomUserWhisperEvent.class); + this.registerHandler(Incoming.RoomUserActionEvent, RoomUserActionEvent.class); + this.registerHandler(Incoming.RoomUserSitEvent, RoomUserSitEvent.class); + this.registerHandler(Incoming.RoomUserDanceEvent, RoomUserDanceEvent.class); + this.registerHandler(Incoming.RoomUserSignEvent, RoomUserSignEvent.class); + this.registerHandler(Incoming.RoomUserWalkEvent, RoomUserWalkEvent.class); + this.registerHandler(Incoming.RoomUserGiveRespectEvent, RoomUserGiveRespectEvent.class); + this.registerHandler(Incoming.RoomUserGiveRightsEvent, RoomUserGiveRightsEvent.class); + this.registerHandler(Incoming.RoomRemoveRightsEvent, RoomRemoveRightsEvent.class); + this.registerHandler(Incoming.RequestRoomRightsEvent, RequestRoomRightsEvent.class); + this.registerHandler(Incoming.RoomRemoveAllRightsEvent, RoomRemoveAllRightsEvent.class); + this.registerHandler(Incoming.RoomUserRemoveRightsEvent, RoomUserRemoveRightsEvent.class); + this.registerHandler(Incoming.BotPlaceEvent, BotPlaceEvent.class); + this.registerHandler(Incoming.BotPickupEvent, BotPickupEvent.class); + this.registerHandler(Incoming.BotSaveSettingsEvent, BotSaveSettingsEvent.class); + this.registerHandler(Incoming.BotSettingsEvent, BotSettingsEvent.class); + this.registerHandler(Incoming.TriggerDiceEvent, TriggerDiceEvent.class); + this.registerHandler(Incoming.CloseDiceEvent, CloseDiceEvent.class); + this.registerHandler(Incoming.TriggerColorWheelEvent, TriggerColorWheelEvent.class); + this.registerHandler(Incoming.RedeemItemEvent, RedeemItemEvent.class); + this.registerHandler(Incoming.PetPlaceEvent, PetPlaceEvent.class); + this.registerHandler(Incoming.RoomUserKickEvent, RoomUserKickEvent.class); + this.registerHandler(Incoming.SetStackHelperHeightEvent, SetStackHelperHeightEvent.class); + this.registerHandler(Incoming.TriggerOneWayGateEvent, TriggerOneWayGateEvent.class); + this.registerHandler(Incoming.HandleDoorbellEvent, HandleDoorbellEvent.class); + this.registerHandler(Incoming.RedeemClothingEvent, RedeemClothingEvent.class); + this.registerHandler(Incoming.PostItPlaceEvent, PostItPlaceEvent.class); + this.registerHandler(Incoming.PostItRequestDataEvent, PostItRequestDataEvent.class); + this.registerHandler(Incoming.PostItSaveDataEvent, PostItSaveDataEvent.class); + this.registerHandler(Incoming.PostItDeleteEvent, PostItDeleteEvent.class); + this.registerHandler(Incoming.MoodLightSaveSettingsEvent, MoodLightSaveSettingsEvent.class); + this.registerHandler(Incoming.RentSpaceEvent, RentSpaceEvent.class); + this.registerHandler(Incoming.RentSpaceCancelEvent, RentSpaceCancelEvent.class); + this.registerHandler(Incoming.SetHomeRoomEvent, SetHomeRoomEvent.class); + this.registerHandler(Incoming.RoomUserGiveHandItemEvent, RoomUserGiveHandItemEvent.class); + this.registerHandler(Incoming.RoomMuteEvent, RoomMuteEvent.class); + this.registerHandler(Incoming.RequestRoomWordFilterEvent, RequestRoomWordFilterEvent.class); + this.registerHandler(Incoming.RoomWordFilterModifyEvent, RoomWordFilterModifyEvent.class); + this.registerHandler(Incoming.RoomStaffPickEvent, RoomStaffPickEvent.class); + this.registerHandler(Incoming.RoomRequestBannedUsersEvent, RoomRequestBannedUsersEvent.class); + this.registerHandler(Incoming.JukeBoxRequestTrackCodeEvent, JukeBoxRequestTrackCodeEvent.class); + this.registerHandler(Incoming.JukeBoxRequestTrackDataEvent, JukeBoxRequestTrackDataEvent.class); + this.registerHandler(Incoming.JukeBoxAddSoundTrackEvent, JukeBoxAddSoundTrackEvent.class); + this.registerHandler(Incoming.JukeBoxRemoveSoundTrackEvent, JukeBoxRemoveSoundTrackEvent.class); + this.registerHandler(Incoming.JukeBoxRequestPlayListEvent, JukeBoxRequestPlayListEvent.class); + this.registerHandler(Incoming.JukeBoxEventOne, JukeBoxEventOne.class); + this.registerHandler(Incoming.JukeBoxEventTwo, JukeBoxEventTwo.class); + this.registerHandler(Incoming.SavePostItStickyPoleEvent, SavePostItStickyPoleEvent.class); + this.registerHandler(Incoming.RequestPromotionRoomsEvent, RequestPromotionRoomsEvent.class); + this.registerHandler(Incoming.BuyRoomPromotionEvent, BuyRoomPromotionEvent.class); + this.registerHandler(Incoming.EditRoomPromotionMessageEvent, UpdateRoomPromotionEvent.class); + this.registerHandler(Incoming.IgnoreRoomUserEvent, IgnoreRoomUserEvent.class); + this.registerHandler(Incoming.UnIgnoreRoomUserEvent, UnIgnoreRoomUserEvent.class); + this.registerHandler(Incoming.RoomUserMuteEvent, RoomUserMuteEvent.class); + this.registerHandler(Incoming.RoomUserBanEvent, RoomUserBanEvent.class); + this.registerHandler(Incoming.UnbanRoomUserEvent, UnbanRoomUserEvent.class); + this.registerHandler(Incoming.RequestRoomUserTagsEvent, RequestRoomUserTagsEvent.class); + this.registerHandler(Incoming.YoutubeRequestPlayListEvent, YoutubeRequestPlayListEvent.class); + this.registerHandler(Incoming.YoutubeRequestNextVideoEvent, YoutubeRequestNextVideoEvent.class); + this.registerHandler(Incoming.YoutubeRequestVideoDataEvent, YoutubeRequestVideoDataEvent.class); + this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class); + this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class); + this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class); } - void registerPolls() throws Exception - { - this.registerHandler(Incoming.CancelPollEvent, CancelPollEvent.class); - this.registerHandler(Incoming.GetPollDataEvent, GetPollDataEvent.class); - this.registerHandler(Incoming.AnswerPollEvent, AnswerPollEvent.class); + void registerPolls() throws Exception { + this.registerHandler(Incoming.CancelPollEvent, CancelPollEvent.class); + this.registerHandler(Incoming.GetPollDataEvent, GetPollDataEvent.class); + this.registerHandler(Incoming.AnswerPollEvent, AnswerPollEvent.class); } - void registerModTool() throws Exception - { - this.registerHandler(Incoming.ModToolRequestRoomInfoEvent, ModToolRequestRoomInfoEvent.class); - this.registerHandler(Incoming.ModToolRequestRoomChatlogEvent, ModToolRequestRoomChatlogEvent.class); - this.registerHandler(Incoming.ModToolRequestUserInfoEvent, ModToolRequestUserInfoEvent.class); - this.registerHandler(Incoming.ModToolPickTicketEvent, ModToolPickTicketEvent.class); - this.registerHandler(Incoming.ModToolCloseTicketEvent, ModToolCloseTicketEvent.class); - this.registerHandler(Incoming.ModToolReleaseTicketEvent, ModToolReleaseTicketEvent.class); - this.registerHandler(Incoming.ModToolAlertEvent, ModToolAlertEvent.class); - this.registerHandler(Incoming.ModToolWarnEvent, ModToolWarnEvent.class); - this.registerHandler(Incoming.ModToolKickEvent, ModToolKickEvent.class); - this.registerHandler(Incoming.ModToolRoomAlertEvent, ModToolRoomAlertEvent.class); - this.registerHandler(Incoming.ModToolChangeRoomSettingsEvent, ModToolChangeRoomSettingsEvent.class); - this.registerHandler(Incoming.ModToolRequestRoomVisitsEvent, ModToolRequestRoomVisitsEvent.class); - this.registerHandler(Incoming.ModToolRequestIssueChatlogEvent, ModToolRequestIssueChatlogEvent.class); - this.registerHandler(Incoming.ModToolRequestRoomUserChatlogEvent, ModToolRequestRoomUserChatlogEvent.class); - this.registerHandler(Incoming.ModToolRequestUserChatlogEvent, ModToolRequestUserChatlogEvent.class); - this.registerHandler(Incoming.ModToolSanctionAlertEvent, ModToolSanctionAlertEvent.class); - this.registerHandler(Incoming.ModToolSanctionMuteEvent, ModToolSanctionMuteEvent.class); - this.registerHandler(Incoming.ModToolSanctionBanEvent, ModToolSanctionBanEvent.class); - this.registerHandler(Incoming.ModToolSanctionTradeLockEvent, ModToolSanctionTradeLockEvent.class); - this.registerHandler(Incoming.ModToolIssueChangeTopicEvent, ModToolIssueChangeTopicEvent.class); - this.registerHandler(Incoming.ModToolIssueDefaultSanctionEvent, ModToolIssueDefaultSanctionEvent.class); + void registerModTool() throws Exception { + this.registerHandler(Incoming.ModToolRequestRoomInfoEvent, ModToolRequestRoomInfoEvent.class); + this.registerHandler(Incoming.ModToolRequestRoomChatlogEvent, ModToolRequestRoomChatlogEvent.class); + this.registerHandler(Incoming.ModToolRequestUserInfoEvent, ModToolRequestUserInfoEvent.class); + this.registerHandler(Incoming.ModToolPickTicketEvent, ModToolPickTicketEvent.class); + this.registerHandler(Incoming.ModToolCloseTicketEvent, ModToolCloseTicketEvent.class); + this.registerHandler(Incoming.ModToolReleaseTicketEvent, ModToolReleaseTicketEvent.class); + this.registerHandler(Incoming.ModToolAlertEvent, ModToolAlertEvent.class); + this.registerHandler(Incoming.ModToolWarnEvent, ModToolWarnEvent.class); + this.registerHandler(Incoming.ModToolKickEvent, ModToolKickEvent.class); + this.registerHandler(Incoming.ModToolRoomAlertEvent, ModToolRoomAlertEvent.class); + this.registerHandler(Incoming.ModToolChangeRoomSettingsEvent, ModToolChangeRoomSettingsEvent.class); + this.registerHandler(Incoming.ModToolRequestRoomVisitsEvent, ModToolRequestRoomVisitsEvent.class); + this.registerHandler(Incoming.ModToolRequestIssueChatlogEvent, ModToolRequestIssueChatlogEvent.class); + this.registerHandler(Incoming.ModToolRequestRoomUserChatlogEvent, ModToolRequestRoomUserChatlogEvent.class); + this.registerHandler(Incoming.ModToolRequestUserChatlogEvent, ModToolRequestUserChatlogEvent.class); + this.registerHandler(Incoming.ModToolSanctionAlertEvent, ModToolSanctionAlertEvent.class); + this.registerHandler(Incoming.ModToolSanctionMuteEvent, ModToolSanctionMuteEvent.class); + this.registerHandler(Incoming.ModToolSanctionBanEvent, ModToolSanctionBanEvent.class); + this.registerHandler(Incoming.ModToolSanctionTradeLockEvent, ModToolSanctionTradeLockEvent.class); + this.registerHandler(Incoming.ModToolIssueChangeTopicEvent, ModToolIssueChangeTopicEvent.class); + this.registerHandler(Incoming.ModToolIssueDefaultSanctionEvent, ModToolIssueDefaultSanctionEvent.class); - this.registerHandler(Incoming.RequestReportRoomEvent, RequestReportRoomEvent.class); - this.registerHandler(Incoming.RequestReportUserBullyingEvent, RequestReportUserBullyingEvent.class); - this.registerHandler(Incoming.ReportBullyEvent, ReportBullyEvent.class); - this.registerHandler(Incoming.ReportEvent, ReportEvent.class); - this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); + this.registerHandler(Incoming.RequestReportRoomEvent, RequestReportRoomEvent.class); + this.registerHandler(Incoming.RequestReportUserBullyingEvent, RequestReportUserBullyingEvent.class); + this.registerHandler(Incoming.ReportBullyEvent, ReportBullyEvent.class); + this.registerHandler(Incoming.ReportEvent, ReportEvent.class); + this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); } - void registerTrading() throws Exception - { - this.registerHandler(Incoming.TradeStartEvent, TradeStartEvent.class); - this.registerHandler(Incoming.TradeOfferItemEvent, TradeOfferItemEvent.class); - this.registerHandler(Incoming.TradeOfferMultipleItemsEvent, TradeOfferMultipleItemsEvent.class); - this.registerHandler(Incoming.TradeCancelOfferItemEvent, TradeCancelOfferItemEvent.class); - this.registerHandler(Incoming.TradeAcceptEvent, TradeAcceptEvent.class); - this.registerHandler(Incoming.TradeUnAcceptEvent, TradeUnAcceptEvent.class); - this.registerHandler(Incoming.TradeConfirmEvent, TradeConfirmEvent.class); - this.registerHandler(Incoming.TradeCloseEvent, TradeCloseEvent.class); - this.registerHandler(Incoming.TradeCancelEvent, TradeCancelEvent.class); + void registerTrading() throws Exception { + this.registerHandler(Incoming.TradeStartEvent, TradeStartEvent.class); + this.registerHandler(Incoming.TradeOfferItemEvent, TradeOfferItemEvent.class); + this.registerHandler(Incoming.TradeOfferMultipleItemsEvent, TradeOfferMultipleItemsEvent.class); + this.registerHandler(Incoming.TradeCancelOfferItemEvent, TradeCancelOfferItemEvent.class); + this.registerHandler(Incoming.TradeAcceptEvent, TradeAcceptEvent.class); + this.registerHandler(Incoming.TradeUnAcceptEvent, TradeUnAcceptEvent.class); + this.registerHandler(Incoming.TradeConfirmEvent, TradeConfirmEvent.class); + this.registerHandler(Incoming.TradeCloseEvent, TradeCloseEvent.class); + this.registerHandler(Incoming.TradeCancelEvent, TradeCancelEvent.class); } - void registerGuilds() throws Exception - { - this.registerHandler(Incoming.RequestGuildBuyRoomsEvent, RequestGuildBuyRoomsEvent.class); - this.registerHandler(Incoming.RequestGuildPartsEvent, RequestGuildPartsEvent.class); - this.registerHandler(Incoming.RequestGuildBuyEvent, RequestGuildBuyEvent.class); - this.registerHandler(Incoming.RequestGuildInfoEvent, RequestGuildInfoEvent.class); - this.registerHandler(Incoming.RequestGuildManageEvent, RequestGuildManageEvent.class); - this.registerHandler(Incoming.RequestGuildMembersEvent, RequestGuildMembersEvent.class); - this.registerHandler(Incoming.RequestGuildJoinEvent, RequestGuildJoinEvent.class); - this.registerHandler(Incoming.GuildChangeNameDescEvent, GuildChangeNameDescEvent.class); - this.registerHandler(Incoming.GuildChangeBadgeEvent, GuildChangeBadgeEvent.class); - this.registerHandler(Incoming.GuildChangeColorsEvent, GuildChangeColorsEvent.class); - this.registerHandler(Incoming.GuildRemoveAdminEvent, GuildRemoveAdminEvent.class); - this.registerHandler(Incoming.GuildRemoveMemberEvent, GuildRemoveMemberEvent.class); - this.registerHandler(Incoming.GuildChangeSettingsEvent, GuildChangeSettingsEvent.class); - this.registerHandler(Incoming.GuildAcceptMembershipEvent, GuildAcceptMembershipEvent.class); - this.registerHandler(Incoming.GuildDeclineMembershipEvent, GuildDeclineMembershipEvent.class); - this.registerHandler(Incoming.GuildSetAdminEvent, GuildSetAdminEvent.class); - this.registerHandler(Incoming.GuildSetFavoriteEvent, GuildSetFavoriteEvent.class); - this.registerHandler(Incoming.RequestOwnGuildsEvent, RequestOwnGuildsEvent.class); - this.registerHandler(Incoming.RequestGuildFurniWidgetEvent, RequestGuildFurniWidgetEvent.class); - this.registerHandler(Incoming.GuildConfirmRemoveMemberEvent, GuildConfirmRemoveMemberEvent.class); - this.registerHandler(Incoming.GuildRemoveFavoriteEvent, GuildRemoveFavoriteEvent.class); - this.registerHandler(Incoming.GuildDeleteEvent, GuildDeleteEvent.class); - this.registerHandler(Incoming.GuildForumListEvent, GuildForumListEvent.class); - this.registerHandler(Incoming.GuildForumThreadsEvent, GuildForumThreadsEvent.class); - this.registerHandler(Incoming.GuildForumDataEvent, GuildForumDataEvent.class); - this.registerHandler(Incoming.GuildForumPostThreadEvent, GuildForumPostThreadEvent.class); - this.registerHandler(Incoming.GuildForumUpdateSettingsEvent, GuildForumUpdateSettingsEvent.class); - this.registerHandler(Incoming.GuildForumThreadsMessagesEvent, GuildForumThreadsMessagesEvent.class); - this.registerHandler(Incoming.GuildForumModerateMessageEvent, GuildForumModerateMessageEvent.class); - this.registerHandler(Incoming.GuildForumModerateThreadEvent, GuildForumModerateThreadEvent.class); - this.registerHandler(Incoming.GuildForumThreadUpdateEvent, GuildForumThreadUpdateEvent.class); - this.registerHandler(Incoming.GetHabboGuildBadgesMessageEvent, GetHabboGuildBadgesMessageEvent.class); + void registerGuilds() throws Exception { + this.registerHandler(Incoming.RequestGuildBuyRoomsEvent, RequestGuildBuyRoomsEvent.class); + this.registerHandler(Incoming.RequestGuildPartsEvent, RequestGuildPartsEvent.class); + this.registerHandler(Incoming.RequestGuildBuyEvent, RequestGuildBuyEvent.class); + this.registerHandler(Incoming.RequestGuildInfoEvent, RequestGuildInfoEvent.class); + this.registerHandler(Incoming.RequestGuildManageEvent, RequestGuildManageEvent.class); + this.registerHandler(Incoming.RequestGuildMembersEvent, RequestGuildMembersEvent.class); + this.registerHandler(Incoming.RequestGuildJoinEvent, RequestGuildJoinEvent.class); + this.registerHandler(Incoming.GuildChangeNameDescEvent, GuildChangeNameDescEvent.class); + this.registerHandler(Incoming.GuildChangeBadgeEvent, GuildChangeBadgeEvent.class); + this.registerHandler(Incoming.GuildChangeColorsEvent, GuildChangeColorsEvent.class); + this.registerHandler(Incoming.GuildRemoveAdminEvent, GuildRemoveAdminEvent.class); + this.registerHandler(Incoming.GuildRemoveMemberEvent, GuildRemoveMemberEvent.class); + this.registerHandler(Incoming.GuildChangeSettingsEvent, GuildChangeSettingsEvent.class); + this.registerHandler(Incoming.GuildAcceptMembershipEvent, GuildAcceptMembershipEvent.class); + this.registerHandler(Incoming.GuildDeclineMembershipEvent, GuildDeclineMembershipEvent.class); + this.registerHandler(Incoming.GuildSetAdminEvent, GuildSetAdminEvent.class); + this.registerHandler(Incoming.GuildSetFavoriteEvent, GuildSetFavoriteEvent.class); + this.registerHandler(Incoming.RequestOwnGuildsEvent, RequestOwnGuildsEvent.class); + this.registerHandler(Incoming.RequestGuildFurniWidgetEvent, RequestGuildFurniWidgetEvent.class); + this.registerHandler(Incoming.GuildConfirmRemoveMemberEvent, GuildConfirmRemoveMemberEvent.class); + this.registerHandler(Incoming.GuildRemoveFavoriteEvent, GuildRemoveFavoriteEvent.class); + this.registerHandler(Incoming.GuildDeleteEvent, GuildDeleteEvent.class); + this.registerHandler(Incoming.GuildForumListEvent, GuildForumListEvent.class); + this.registerHandler(Incoming.GuildForumThreadsEvent, GuildForumThreadsEvent.class); + this.registerHandler(Incoming.GuildForumDataEvent, GuildForumDataEvent.class); + this.registerHandler(Incoming.GuildForumPostThreadEvent, GuildForumPostThreadEvent.class); + this.registerHandler(Incoming.GuildForumUpdateSettingsEvent, GuildForumUpdateSettingsEvent.class); + this.registerHandler(Incoming.GuildForumThreadsMessagesEvent, GuildForumThreadsMessagesEvent.class); + this.registerHandler(Incoming.GuildForumModerateMessageEvent, GuildForumModerateMessageEvent.class); + this.registerHandler(Incoming.GuildForumModerateThreadEvent, GuildForumModerateThreadEvent.class); + this.registerHandler(Incoming.GuildForumThreadUpdateEvent, GuildForumThreadUpdateEvent.class); + this.registerHandler(Incoming.GetHabboGuildBadgesMessageEvent, GetHabboGuildBadgesMessageEvent.class); // this.registerHandler(Incoming.GuildForumDataEvent, GuildForumModerateMessageEvent.class); // this.registerHandler(Incoming.GuildForumDataEvent, GuildForumModerateThreadEvent.class); @@ -543,117 +519,87 @@ public class PacketManager // this.registerHandler(Incoming.GuildForumDataEvent, GuildForumUpdateSettingsEvent.class); } - void registerPets() throws Exception - { - this.registerHandler(Incoming.RequestPetInformationEvent, RequestPetInformationEvent.class); - this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class); - this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class); - this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class); - this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class); - this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class); - this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class); - this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class); - this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class); - this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class); - this.registerHandler(Incoming.MovePetEvent, MovePetEvent.class); - this.registerHandler(Incoming.PetPackageNameEvent, PetPackageNameEvent.class); - this.registerHandler(Incoming.StopBreedingEvent, StopBreedingEvent.class); - this.registerHandler(Incoming.ConfirmPetBreedingEvent, ConfirmPetBreedingEvent.class); + void registerPets() throws Exception { + this.registerHandler(Incoming.RequestPetInformationEvent, RequestPetInformationEvent.class); + this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class); + this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class); + this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class); + this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class); + this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class); + this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class); + this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class); + this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class); + this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class); + this.registerHandler(Incoming.MovePetEvent, MovePetEvent.class); + this.registerHandler(Incoming.PetPackageNameEvent, PetPackageNameEvent.class); + this.registerHandler(Incoming.StopBreedingEvent, StopBreedingEvent.class); + this.registerHandler(Incoming.ConfirmPetBreedingEvent, ConfirmPetBreedingEvent.class); } - void registerWired() throws Exception - { - this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); - this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); - this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); + void registerWired() throws Exception { + this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); + this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); + this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); } - void registerUnknown() throws Exception - { - this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class); - this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class); - this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class); + void registerUnknown() throws Exception { + this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class); + this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class); + this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class); } - void registerFloorPlanEditor() throws Exception - { - this.registerHandler(Incoming.FloorPlanEditorSaveEvent, FloorPlanEditorSaveEvent.class); - this.registerHandler(Incoming.FloorPlanEditorRequestBlockedTilesEvent, FloorPlanEditorRequestBlockedTilesEvent.class); - this.registerHandler(Incoming.FloorPlanEditorRequestDoorSettingsEvent, FloorPlanEditorRequestDoorSettingsEvent.class); + void registerFloorPlanEditor() throws Exception { + this.registerHandler(Incoming.FloorPlanEditorSaveEvent, FloorPlanEditorSaveEvent.class); + this.registerHandler(Incoming.FloorPlanEditorRequestBlockedTilesEvent, FloorPlanEditorRequestBlockedTilesEvent.class); + this.registerHandler(Incoming.FloorPlanEditorRequestDoorSettingsEvent, FloorPlanEditorRequestDoorSettingsEvent.class); } - void registerAchievements() throws Exception - { - this.registerHandler(Incoming.RequestAchievementsEvent, RequestAchievementsEvent.class); - this.registerHandler(Incoming.RequestAchievementConfigurationEvent, RequestAchievementConfigurationEvent.class); + void registerAchievements() throws Exception { + this.registerHandler(Incoming.RequestAchievementsEvent, RequestAchievementsEvent.class); + this.registerHandler(Incoming.RequestAchievementConfigurationEvent, RequestAchievementConfigurationEvent.class); } - void registerGuides() throws Exception - { - this.registerHandler(Incoming.RequestGuideToolEvent, RequestGuideToolEvent.class); - this.registerHandler(Incoming.RequestGuideAssistanceEvent, RequestGuideAssistanceEvent.class); - this.registerHandler(Incoming.GuideUserTypingEvent, GuideUserTypingEvent.class); - this.registerHandler(Incoming.GuideReportHelperEvent, GuideReportHelperEvent.class); - this.registerHandler(Incoming.GuideRecommendHelperEvent, GuideRecommendHelperEvent.class); - this.registerHandler(Incoming.GuideUserMessageEvent, GuideUserMessageEvent.class); - this.registerHandler(Incoming.GuideCancelHelpRequestEvent, GuideCancelHelpRequestEvent.class); - this.registerHandler(Incoming.GuideHandleHelpRequestEvent, GuideHandleHelpRequestEvent.class); - this.registerHandler(Incoming.GuideInviteUserEvent, GuideInviteUserEvent.class); - this.registerHandler(Incoming.GuideVisitUserEvent, GuideVisitUserEvent.class); - this.registerHandler(Incoming.GuideCloseHelpRequestEvent, GuideCloseHelpRequestEvent.class); + void registerGuides() throws Exception { + this.registerHandler(Incoming.RequestGuideToolEvent, RequestGuideToolEvent.class); + this.registerHandler(Incoming.RequestGuideAssistanceEvent, RequestGuideAssistanceEvent.class); + this.registerHandler(Incoming.GuideUserTypingEvent, GuideUserTypingEvent.class); + this.registerHandler(Incoming.GuideReportHelperEvent, GuideReportHelperEvent.class); + this.registerHandler(Incoming.GuideRecommendHelperEvent, GuideRecommendHelperEvent.class); + this.registerHandler(Incoming.GuideUserMessageEvent, GuideUserMessageEvent.class); + this.registerHandler(Incoming.GuideCancelHelpRequestEvent, GuideCancelHelpRequestEvent.class); + this.registerHandler(Incoming.GuideHandleHelpRequestEvent, GuideHandleHelpRequestEvent.class); + this.registerHandler(Incoming.GuideInviteUserEvent, GuideInviteUserEvent.class); + this.registerHandler(Incoming.GuideVisitUserEvent, GuideVisitUserEvent.class); + this.registerHandler(Incoming.GuideCloseHelpRequestEvent, GuideCloseHelpRequestEvent.class); - this.registerHandler(Incoming.GuardianNoUpdatesWantedEvent, GuardianNoUpdatesWantedEvent.class); - this.registerHandler(Incoming.GuardianAcceptRequestEvent, GuardianAcceptRequestEvent.class); - this.registerHandler(Incoming.GuardianVoteEvent, GuardianVoteEvent.class); + this.registerHandler(Incoming.GuardianNoUpdatesWantedEvent, GuardianNoUpdatesWantedEvent.class); + this.registerHandler(Incoming.GuardianAcceptRequestEvent, GuardianAcceptRequestEvent.class); + this.registerHandler(Incoming.GuardianVoteEvent, GuardianVoteEvent.class); } - void registerCrafting() throws Exception - { - this.registerHandler(Incoming.RequestCraftingRecipesEvent, RequestCraftingRecipesEvent.class); - this.registerHandler(Incoming.CraftingAddRecipeEvent, CraftingAddRecipeEvent.class); - this.registerHandler(Incoming.CraftingCraftItemEvent, CraftingCraftItemEvent.class); - this.registerHandler(Incoming.CraftingCraftSecretEvent, CraftingCraftSecretEvent.class); - this.registerHandler(Incoming.RequestCraftingRecipesAvailableEvent, RequestCraftingRecipesAvailableEvent.class); + void registerCrafting() throws Exception { + this.registerHandler(Incoming.RequestCraftingRecipesEvent, RequestCraftingRecipesEvent.class); + this.registerHandler(Incoming.CraftingAddRecipeEvent, CraftingAddRecipeEvent.class); + this.registerHandler(Incoming.CraftingCraftItemEvent, CraftingCraftItemEvent.class); + this.registerHandler(Incoming.CraftingCraftSecretEvent, CraftingCraftSecretEvent.class); + this.registerHandler(Incoming.RequestCraftingRecipesAvailableEvent, RequestCraftingRecipesAvailableEvent.class); } - void registerCamera() throws Exception - { - this.registerHandler(Incoming.CameraRoomPictureEvent, CameraRoomPictureEvent.class); - this.registerHandler(Incoming.RequestCameraConfigurationEvent, RequestCameraConfigurationEvent.class); - this.registerHandler(Incoming.CameraPurchaseEvent, CameraPurchaseEvent.class); - this.registerHandler(Incoming.CameraRoomThumbnailEvent, CameraRoomThumbnailEvent.class); - this.registerHandler(Incoming.CameraPublishToWebEvent, CameraPublishToWebEvent.class); + void registerCamera() throws Exception { + this.registerHandler(Incoming.CameraRoomPictureEvent, CameraRoomPictureEvent.class); + this.registerHandler(Incoming.RequestCameraConfigurationEvent, RequestCameraConfigurationEvent.class); + this.registerHandler(Incoming.CameraPurchaseEvent, CameraPurchaseEvent.class); + this.registerHandler(Incoming.CameraRoomThumbnailEvent, CameraRoomThumbnailEvent.class); + this.registerHandler(Incoming.CameraPublishToWebEvent, CameraPublishToWebEvent.class); } - void registerGameCenter() throws Exception - { - this.registerHandler(Incoming.GameCenterRequestGamesEvent, GameCenterRequestGamesEvent.class); - this.registerHandler(Incoming.GameCenterRequestAccountStatusEvent, GameCenterRequestAccountStatusEvent.class); - this.registerHandler(Incoming.GameCenterJoinGameEvent, GameCenterJoinGameEvent.class); - this.registerHandler(Incoming.GameCenterLoadGameEvent, GameCenterLoadGameEvent.class); - this.registerHandler(Incoming.GameCenterLeaveGameEvent, GameCenterLeaveGameEvent.class); - this.registerHandler(Incoming.GameCenterEvent, GameCenterEvent.class); - this.registerHandler(Incoming.GameCenterRequestGameStatusEvent, GameCenterRequestGameStatusEvent.class); + void registerGameCenter() throws Exception { + this.registerHandler(Incoming.GameCenterRequestGamesEvent, GameCenterRequestGamesEvent.class); + this.registerHandler(Incoming.GameCenterRequestAccountStatusEvent, GameCenterRequestAccountStatusEvent.class); + this.registerHandler(Incoming.GameCenterJoinGameEvent, GameCenterJoinGameEvent.class); + this.registerHandler(Incoming.GameCenterLoadGameEvent, GameCenterLoadGameEvent.class); + this.registerHandler(Incoming.GameCenterLeaveGameEvent, GameCenterLeaveGameEvent.class); + this.registerHandler(Incoming.GameCenterEvent, GameCenterEvent.class); + this.registerHandler(Incoming.GameCenterRequestGameStatusEvent, GameCenterRequestGameStatusEvent.class); } - - @EventHandler - public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) - { - logList.clear(); - - for (String s : Emulator.getConfig().getValue("debug.show.headers").split(";")) - { - try - { - logList.add(Integer.valueOf(s)); - } - catch (Exception e) - { - - } - } - } - - public static boolean DEBUG_SHOW_PACKETS = false; - public static boolean MULTI_THREADED_PACKET_HANDLING = false; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java index 1df004dd..a7241c2d 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java @@ -55,13 +55,11 @@ import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import gnu.trove.map.hash.THashMap; -public class PacketManager_1006 -{ +public class PacketManager_1006 { private final THashMap> incoming; - public PacketManager_1006() - { + public PacketManager_1006() { this.incoming = new THashMap<>(); this.registerCatalog(); @@ -84,21 +82,17 @@ public class PacketManager_1006 this.registerAmbassadors(); } - void registerHandler(Integer header, Class handler) - { + void registerHandler(Integer header, Class handler) { this.incoming.putIfAbsent(header, handler); } - public void handlePacket(GameClient client, ClientMessage packet) - { - if(client == null) + public void handlePacket(GameClient client, ClientMessage packet) { + if (client == null) return; - try - { - if(this.isRegistered(packet.getMessageId())) - { - if(Emulator.getConfig().getBoolean("debug.show.packets")) + try { + if (this.isRegistered(packet.getMessageId())) { + if (Emulator.getConfig().getBoolean("debug.show.packets")) Emulator.getLogging().logPacketLine("[CLIENT][" + packet.getMessageId() + "] => " + packet.getMessageBody()); MessageHandler handler = this.incoming.get(packet.getMessageId()).newInstance(); @@ -108,32 +102,25 @@ public class PacketManager_1006 handler.handle(); - } - else - { - if(Emulator.getConfig().getBoolean("debug.show.packets")) + } else { + if (Emulator.getConfig().getBoolean("debug.show.packets")) Emulator.getLogging().logPacketLine("[CLIENT][UNDEFINED][" + packet.getMessageId() + "] => " + packet.getMessageBody()); } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - boolean isRegistered(int header) - { + boolean isRegistered(int header) { return this.incoming.containsKey(header); } - private void registerAmbassadors() - { + private void registerAmbassadors() { this.registerHandler(Incoming.AmbassadorAlertCommandEvent, AmbassadorAlertCommandEvent.class); this.registerHandler(Incoming.AmbassadorVisitCommandEvent, AmbassadorVisitCommandEvent.class); } - private void registerCatalog() - { + private void registerCatalog() { this.registerHandler(Incoming.RequestRecylerLogicEvent, RequestRecyclerLogicEvent.class); this.registerHandler(Incoming.RequestDiscountEvent, RequestDiscountEvent.class); this.registerHandler(Incoming.RequestGiftConfigurationEvent, RequestGiftConfigurationEvent.class); @@ -162,8 +149,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.CatalogSearchedItemEvent, CatalogSearchedItemEvent.class); } - private void registerHandshake() - { + private void registerHandshake() { this.registerHandler(Incoming.ReleaseVersionEvent, ReleaseVersionEvent.class); this.registerHandler(Incoming.GenerateSecretKeyEvent, GenerateSecretKeyEvent.class); this.registerHandler(Incoming.RequestBannerToken, RequestBannerToken.class); @@ -173,8 +159,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.PingEvent, PingEvent.class); } - private void registerFriends() - { + private void registerFriends() { this.registerHandler(Incoming.RequestFriendsEvent, RequestFriendsEvent.class); this.registerHandler(Incoming.ChangeRelationEvent, ChangeRelationEvent.class); this.registerHandler(Incoming.RemoveFriendEvent, RemoveFriendEvent.class); @@ -184,13 +169,12 @@ public class PacketManager_1006 this.registerHandler(Incoming.FriendPrivateMessageEvent, FriendPrivateMessageEvent.class); this.registerHandler(Incoming.RequestFriendRequestEvent, RequestFriendRequestsEvent.class); this.registerHandler(Incoming.StalkFriendEvent, StalkFriendEvent.class); - this.registerHandler(Incoming.RequestInitFriendsEvent , RequestInitFriendsEvent.class); + this.registerHandler(Incoming.RequestInitFriendsEvent, RequestInitFriendsEvent.class); this.registerHandler(Incoming.FindNewFriendsEvent, FindNewFriendsEvent.class); this.registerHandler(Incoming.InviteFriendsEvent, InviteFriendsEvent.class); } - private void registerUsers() - { + private void registerUsers() { this.registerHandler(Incoming.RequestUserDataEvent, RequestUserDataEvent.class); this.registerHandler(Incoming.RequestUserCreditsEvent, RequestUserCreditsEvent.class); this.registerHandler(Incoming.RequestUserClubEvent, RequestUserClubEvent.class); @@ -210,8 +194,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.SavePreferOldChatEvent, SavePreferOldChatEvent.class); } - private void registerNavigator() - { + private void registerNavigator() { this.registerHandler(Incoming.RequestRoomCategoriesEvent, RequestRoomCategoriesEvent.class); this.registerHandler(Incoming.RequestPublicRoomsEvent, RequestPublicRoomsEvent.class); this.registerHandler(Incoming.RequestPopularRoomsEvent, RequestPopularRoomsEvent.class); @@ -234,24 +217,21 @@ public class PacketManager_1006 this.registerHandler(Incoming.NewNavigatorActionEvent, NewNavigatorActionEvent.class); } - private void registerHotelview() - { + private void registerHotelview() { this.registerHandler(Incoming.HotelViewEvent, HotelViewEvent.class); this.registerHandler(Incoming.HotelViewRequestBonusRareEvent, HotelViewRequestBonusRareEvent.class); this.registerHandler(Incoming.RequestNewsListEvent, RequestNewsListEvent.class); this.registerHandler(Incoming.HotelViewDataEvent, HotelViewDataEvent.class); } - private void registerInventory() - { + private void registerInventory() { this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); } - void registerRooms() - { + void registerRooms() { this.registerHandler(Incoming.RequestRoomLoadEvent, RequestRoomLoadEvent.class); this.registerHandler(Incoming.RequestHeightmapEvent, RequestRoomHeightmapEvent.class); this.registerHandler(Incoming.RequestRoomHeightmapEvent, RequestRoomHeightmapEvent.class); @@ -324,15 +304,13 @@ public class PacketManager_1006 this.registerHandler(Incoming.JukeBoxEventTwo, JukeBoxEventTwo.class); } - void registerPolls() - { + void registerPolls() { this.registerHandler(Incoming.CancelPollEvent, CancelPollEvent.class); this.registerHandler(Incoming.GetPollDataEvent, GetPollDataEvent.class); this.registerHandler(Incoming.AnswerPollEvent, AnswerPollEvent.class); } - void registerModTool() - { + void registerModTool() { this.registerHandler(Incoming.ModToolRequestRoomInfoEvent, ModToolRequestRoomInfoEvent.class); this.registerHandler(Incoming.ModToolRequestRoomChatlogEvent, ModToolRequestRoomChatlogEvent.class); this.registerHandler(Incoming.ModToolRequestUserInfoEvent, ModToolRequestUserInfoEvent.class); @@ -353,8 +331,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.ReportEvent, ReportEvent.class); } - void registerTrading() - { + void registerTrading() { this.registerHandler(Incoming.TradeStartEvent, TradeStartEvent.class); this.registerHandler(Incoming.TradeOfferItemEvent, TradeOfferItemEvent.class); this.registerHandler(Incoming.TradeCancelOfferItemEvent, TradeCancelOfferItemEvent.class); @@ -364,8 +341,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.TradeCloseEvent, TradeCloseEvent.class); } - void registerGuilds() - { + void registerGuilds() { this.registerHandler(Incoming.RequestGuildBuyRoomsEvent, RequestGuildBuyRoomsEvent.class); this.registerHandler(Incoming.RequestGuildPartsEvent, RequestGuildPartsEvent.class); this.registerHandler(Incoming.RequestGuildBuyEvent, RequestGuildBuyEvent.class); @@ -390,8 +366,7 @@ public class PacketManager_1006 this.registerHandler(Incoming.GuildDeleteEvent, GuildDeleteEvent.class); } - void registerPets() - { + void registerPets() { this.registerHandler(Incoming.RequestPetInformationEvent, RequestPetInformationEvent.class); this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class); this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class); @@ -401,29 +376,25 @@ public class PacketManager_1006 this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class); } - void registerWired() - { + void registerWired() { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); } - void registerUnknown() - { + void registerUnknown() { this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class); this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class); //TODO this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class); } - void registerFloorPlanEditor() - { + void registerFloorPlanEditor() { this.registerHandler(Incoming.FloorPlanEditorSaveEvent, FloorPlanEditorSaveEvent.class); this.registerHandler(Incoming.FloorPlanEditorRequestBlockedTilesEvent, FloorPlanEditorRequestBlockedTilesEvent.class); this.registerHandler(Incoming.FloorPlanEditorRequestDoorSettingsEvent, FloorPlanEditorRequestDoorSettingsEvent.class); } - void registerAchievements() - { + void registerAchievements() { this.registerHandler(Incoming.RequestAchievementsEvent, RequestAchievementsEvent.class); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/ServerMessage.java b/src/main/java/com/eu/habbo/messages/ServerMessage.java index 7fb49a49..2fb4d4df 100644 --- a/src/main/java/com/eu/habbo/messages/ServerMessage.java +++ b/src/main/java/com/eu/habbo/messages/ServerMessage.java @@ -8,231 +8,165 @@ import io.netty.buffer.Unpooled; import java.io.IOException; import java.nio.charset.Charset; -public class ServerMessage -{ +public class ServerMessage { private int header; private ByteBufOutputStream stream; private ByteBuf channelBuffer; - public ServerMessage() - { + public ServerMessage() { this.channelBuffer = Unpooled.buffer(); this.stream = new ByteBufOutputStream(this.channelBuffer); } - public ServerMessage(int header) - { + public ServerMessage(int header) { this.header = header; this.channelBuffer = Unpooled.buffer(); this.stream = new ByteBufOutputStream(this.channelBuffer); - try - { + try { this.stream.writeInt(0); this.stream.writeShort(header); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().handleException(e); } } - public ServerMessage init(int id) - { + public ServerMessage init(int id) { this.header = id; this.channelBuffer = Unpooled.buffer(); this.stream = new ByteBufOutputStream(this.channelBuffer); - try - { + try { this.stream.writeInt(0); this.stream.writeShort(id); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().handleException(e); } return this; } - public void appendRawBytes(byte[] bytes) - { - try - { + public void appendRawBytes(byte[] bytes) { + try { this.stream.write(bytes); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendString(String obj) - { - if (obj == null) - { + public void appendString(String obj) { + if (obj == null) { this.appendString(""); return; } - try - { + try { byte[] data = obj.getBytes(); this.stream.writeShort(data.length); this.stream.write(data); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendChar(int obj) - { - try - { + public void appendChar(int obj) { + try { this.stream.writeChar(obj); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendChars(Object obj) - { - try - { + public void appendChars(Object obj) { + try { this.stream.writeChars(obj.toString()); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendInt(Integer obj) - { - try - { + public void appendInt(Integer obj) { + try { this.stream.writeInt(obj); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendInt(Short obj) - { + public void appendInt(Short obj) { this.appendShort(0); this.appendShort(obj); } - public void appendInt(Byte obj) - { - try - { + public void appendInt(Byte obj) { + try { this.stream.writeInt((int) obj); - } - catch (IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendInt(Boolean obj) - { - try - { + public void appendInt(Boolean obj) { + try { this.stream.writeInt(obj ? 1 : 0); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendShort(int obj) - { - try - { + public void appendShort(int obj) { + try { this.stream.writeShort((short) obj); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendByte(Integer b) - { - try - { + public void appendByte(Integer b) { + try { this.stream.writeByte(b); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendBoolean(Boolean obj) - { - try - { + public void appendBoolean(Boolean obj) { + try { this.stream.writeBoolean(obj); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendDouble(double d) - { - try - { + public void appendDouble(double d) { + try { this.stream.writeDouble(d); - } - catch (IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public void appendDouble(Double obj) - { - try - { + public void appendDouble(Double obj) { + try { this.stream.writeDouble(obj); - } - catch (IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } } - public ServerMessage appendResponse(ServerMessage obj) - { - try - { + public ServerMessage appendResponse(ServerMessage obj) { + try { this.stream.write(obj.get().array()); - } - catch(IOException e) - { + } catch (IOException e) { Emulator.getLogging().logPacketError(e); } return this; } - public void append(ISerialize obj) - { + public void append(ISerialize obj) { obj.serialize(this); } - public String getBodyString() - { + public String getBodyString() { ByteBuf buffer = this.stream.buffer().duplicate(); buffer.setInt(0, buffer.writerIndex() - 4); @@ -240,7 +174,7 @@ public class ServerMessage String consoleText = buffer.toString(Charset.forName("UTF-8")); for (int i = 0; i < 14; i++) { - consoleText = consoleText.replace(Character.toString((char)i), "[" + i + "]"); + consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); } buffer.discardSomeReadBytes(); @@ -248,13 +182,11 @@ public class ServerMessage return consoleText; } - public int getHeader() - { + public int getHeader() { return this.header; } - public ByteBuf get() - { + public ByteBuf get() { this.channelBuffer.setInt(0, this.channelBuffer.writerIndex() - 4); return this.channelBuffer.copy(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 45237758..bf3e7b01 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -1,7 +1,6 @@ package com.eu.habbo.messages.incoming; -public class Incoming -{ +public class Incoming { public static final int ChangeNameCheckUsernameEvent = 3950; public static final int ConfirmChangeNameEvent = 2977; public static final int ActivateEffectEvent = 2959; diff --git a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java index 4e479253..98baf3b6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java +++ b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java @@ -3,8 +3,7 @@ package com.eu.habbo.messages.incoming; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.ClientMessage; -public abstract class MessageHandler -{ +public abstract class MessageHandler { public GameClient client; public ClientMessage packet; public boolean isCancelled = false; diff --git a/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementConfigurationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementConfigurationEvent.java index 9d456bc9..ff1d31c4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementConfigurationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementConfigurationEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.achievements; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryAchievementsComposer; -public class RequestAchievementConfigurationEvent extends MessageHandler -{ +public class RequestAchievementConfigurationEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new InventoryAchievementsComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementsEvent.java index 0d2b5b2a..c4ec8b35 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/achievements/RequestAchievementsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.achievements; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer; -public class RequestAchievementsEvent extends MessageHandler -{ +public class RequestAchievementsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new AchievementListComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java index d7456e25..fe42366b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java @@ -8,12 +8,10 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.plugin.events.support.SupportUserAlertedEvent; import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; -public class AmbassadorAlertCommandEvent extends MessageHandler -{ +public class AmbassadorAlertCommandEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(!this.client.getHabbo().hasPermission("acc_ambassador")) { + public void handle() throws Exception { + if (!this.client.getHabbo().hasPermission("acc_ambassador")) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}")); return; } @@ -22,7 +20,7 @@ public class AmbassadorAlertCommandEvent extends MessageHandler Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); - if(habbo == null) + if (habbo == null) return; SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(client.getHabbo(), habbo, "${notification.ambassador.alert.warning.message}", SupportUserAlertedReason.AMBASSADOR); diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorVisitCommandEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorVisitCommandEvent.java index f05fff7d..0a92bcab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorVisitCommandEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorVisitCommandEvent.java @@ -5,21 +5,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; -public class AmbassadorVisitCommandEvent extends MessageHandler -{ +public class AmbassadorVisitCommandEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission("acc_ambassador")) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission("acc_ambassador")) { String username = this.packet.readString(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if(habbo != null) - { - if(habbo.getHabboInfo().getCurrentRoom() != null) - { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentRoom() != null) { this.client.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java index 640ad031..537765e4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java @@ -9,33 +9,23 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class CameraPublishToWebEvent extends MessageHandler -{ +public class CameraPublishToWebEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) - { - if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) - { - if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) { + if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) { + if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) { int timestamp = Emulator.getIntUnixTimestamp(); boolean published = false; int timeDiff = timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp(); int wait = 0; - if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) - { + if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) { wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay"); - } - else - { + } else { UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId()); - if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) - { + if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) { statement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); statement.setInt(2, publishPictureEvent.roomId); statement.setInt(3, publishPictureEvent.timestamp); @@ -43,14 +33,10 @@ public class CameraPublishToWebEvent extends MessageHandler statement.execute(); this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp); published = true; - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } - else - { + } else { return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java index 7c9650f6..351f4be5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java @@ -10,31 +10,23 @@ import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent; -public class CameraPurchaseEvent extends MessageHandler -{ +public class CameraPurchaseEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits") || this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points")) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits") || this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points")) { this.client.sendResponse(new NotEnoughPointsTypeComposer(this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits"), this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points"), 0)); return; } - if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) - { - if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) - { - if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) - { - if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) - { + if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) { + if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) { + if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) { + if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) { return; } HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); - if (photoItem != null) - { + if (photoItem != null) { photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + "")); photoItem.needsUpdate(true); this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem); diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomPictureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomPictureEvent.java index 12309aaf..15506037 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomPictureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomPictureEvent.java @@ -6,19 +6,15 @@ import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.camera.messages.outgoing.CameraRenderImageComposer; import com.eu.habbo.util.crypto.ZIP; -public class CameraRoomPictureEvent extends MessageHandler -{ +public class CameraRoomPictureEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (!this.client.getHabbo().hasPermission("acc_camera")) - { + public void handle() throws Exception { + if (!this.client.getHabbo().hasPermission("acc_camera")) { this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission")); return; } - if (CameraClient.isLoggedIn) - { + if (CameraClient.isLoggedIn) { this.packet.getBuffer().readFloat(); byte[] data = this.packet.getBuffer().readBytes(this.packet.getBuffer().readableBytes()).array(); @@ -28,15 +24,12 @@ public class CameraRoomPictureEvent extends MessageHandler this.client.getHabbo().getHabboInfo().setPhotoJSON(Emulator.getConfig().getValue("camera.extradata").replace("%timestamp%", composer.timestamp + "")); this.client.getHabbo().getHabboInfo().setPhotoTimestamp(composer.timestamp); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().setPhotoRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()); } Emulator.getCameraClient().sendMessage(composer); - } - else - { + } else { this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.disabled")); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomThumbnailEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomThumbnailEvent.java index 6d2c088a..c9c1bc12 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomThumbnailEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraRoomThumbnailEvent.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.incoming.camera; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraRoomThumbnailSavedComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.camera.messages.outgoing.CameraRenderImageComposer; import com.eu.habbo.util.crypto.ZIP; -public class CameraRoomThumbnailEvent extends MessageHandler -{ +public class CameraRoomThumbnailEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (!this.client.getHabbo().hasPermission("acc_camera")) - { + public void handle() throws Exception { + if (!this.client.getHabbo().hasPermission("acc_camera")) { this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission")); return; } @@ -22,8 +18,7 @@ public class CameraRoomThumbnailEvent extends MessageHandler if (!this.client.getHabbo().getHabboInfo().getCurrentRoom().isOwner(this.client.getHabbo())) return; - if (CameraClient.isLoggedIn) - { + if (CameraClient.isLoggedIn) { this.packet.getBuffer().readFloat(); byte[] data = this.packet.getBuffer().readBytes(this.packet.getBuffer().readableBytes()).array(); String content = new String(ZIP.inflate(data)); @@ -34,9 +29,7 @@ public class CameraRoomThumbnailEvent extends MessageHandler this.client.getHabbo().getHabboInfo().setPhotoTimestamp(composer.timestamp); Emulator.getCameraClient().sendMessage(composer); - } - else - { + } else { this.client.sendResponse(new CameraRoomThumbnailSavedComposer()); this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.disabled")); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/RequestCameraConfigurationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/RequestCameraConfigurationEvent.java index 14be39cd..cc90af9e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/RequestCameraConfigurationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/RequestCameraConfigurationEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPriceComposer; -public class RequestCameraConfigurationEvent extends MessageHandler -{ +public class RequestCameraConfigurationEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new CameraPriceComposer(Emulator.getConfig().getInt("camera.price.credits"), Emulator.getConfig().getInt("camera.price.points"), Emulator.getConfig().getInt("camera.price.points.publish"))); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index beeb6616..c3e375e5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -31,32 +31,25 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; -public class CatalogBuyItemAsGiftEvent extends MessageHandler -{ +public class CatalogBuyItemAsGiftEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastGiftTimestamp >= CatalogManager.PURCHASE_COOLDOWN) - { + public void handle() throws Exception { + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastGiftTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { this.client.getHabbo().getHabboStats().lastGiftTimestamp = Emulator.getIntUnixTimestamp(); - if (ShutdownEmulator.timestamp > 0) - { + if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - if (this.client.getHabbo().getHabboStats().isPurchasingFurniture) - { + if (this.client.getHabbo().getHabboStats().isPurchasingFurniture) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; - } else - { + } else { this.client.getHabbo().getHabboStats().isPurchasingFurniture = true; } - try - { + try { int pageId = this.packet.readInt(); int itemId = this.packet.readInt(); @@ -71,8 +64,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler int count = 1; int userId = 0; - if (!Emulator.getGameEnvironment().getCatalogManager().giftWrappers.containsKey(spriteId) && !Emulator.getGameEnvironment().getCatalogManager().giftFurnis.containsKey(spriteId)) - { + if (!Emulator.getGameEnvironment().getCatalogManager().giftWrappers.containsKey(spriteId) && !Emulator.getGameEnvironment().getCatalogManager().giftFurnis.containsKey(spriteId)) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } @@ -82,98 +74,79 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler if (iItemId == null) iItemId = Emulator.getGameEnvironment().getCatalogManager().giftFurnis.get(spriteId); - if (iItemId == null) - { + if (iItemId == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem(iItemId); - if (giftItem == null) - { + if (giftItem == null) { giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); - if (giftItem == null) - { + if (giftItem == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); - if (habbo == null) - { - try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE username = ?")) - { + if (habbo == null) { + try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE username = ?")) { statement.setString(1, username); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { userId = set.getInt(1); } } - } catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } else - { + } else { userId = habbo.getHabboInfo().getId(); } - if (userId == 0) - { + if (userId == 0) { this.client.sendResponse(new GiftReceiverNotFoundComposer()); return; } CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(pageId); - if (page == null) - { + if (page == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId() || !page.isEnabled() || !page.isVisible()) - { + if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId() || !page.isEnabled() || !page.isVisible()) { this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } CatalogItem item = page.getCatalogItem(itemId); - if (item == null) - { + if (item == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - if (item.isClubOnly() && !this.client.getHabbo().getHabboStats().hasActiveClub()) - { + if (item.isClubOnly() && !this.client.getHabbo().getHabboStats().hasActiveClub()) { this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.REQUIRES_CLUB)); return; } - for (Item baseItem : item.getBaseItems()) - { - if (!baseItem.allowGift()) - { + for (Item baseItem : item.getBaseItems()) { + if (!baseItem.allowGift()) { this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } } - if (item.isLimited()) - { - if (item.getLimitedStack() == item.getLimitedSells()) - { + if (item.isLimited()) { + if (item.getLimitedStack() == item.getLimitedSells()) { this.client.sendResponse(new AlertLimitedSoldOutComposer()); return; } @@ -186,19 +159,16 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler CatalogLimitedConfiguration limitedConfiguration; int limitedStack = 0; int limitedNumber = 0; - if (item.isLimited()) - { + if (item.isLimited()) { count = 1; - if (Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item).available() == 0) - { + if (Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item).available() == 0) { habbo.getClient().sendResponse(new AlertLimitedSoldOutComposer()); return; } limitedConfiguration = Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item); - if (limitedConfiguration == null) - { + if (limitedConfiguration == null) { limitedConfiguration = Emulator.getGameEnvironment().getCatalogManager().createOrUpdateLimitedConfig(item); } @@ -209,93 +179,69 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler THashSet itemsList = new THashSet<>(); boolean badgeFound = false; - for (Item baseItem : item.getBaseItems()) - { - if (baseItem.getType() == FurnitureType.BADGE) - { - if (habbo != null) - { - if (habbo.getInventory().getBadgesComponent().hasBadge(baseItem.getName())) - { + for (Item baseItem : item.getBaseItems()) { + if (baseItem.getType() == FurnitureType.BADGE) { + if (habbo != null) { + if (habbo.getInventory().getBadgesComponent().hasBadge(baseItem.getName())) { badgeFound = true; } - } else - { + } else { int c = 0; - try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as c FROM users_badges WHERE user_id = ? AND badge_code LIKE ?")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as c FROM users_badges WHERE user_id = ? AND badge_code LIKE ?")) { statement.setInt(1, userId); statement.setString(2, baseItem.getName()); - try (ResultSet rSet = statement.executeQuery()) - { - if (rSet.next()) - { + try (ResultSet rSet = statement.executeQuery()) { + if (rSet.next()) { c = rSet.getInt("c"); } } } - if (c != 0) - { + if (c != 0) { badgeFound = true; } } } } - if (badgeFound) - { + if (badgeFound) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE)); return; } - for (int i = 0; i < count; i++) - { - if (item.getCredits() <= this.client.getHabbo().getHabboInfo().getCredits() - totalCredits) - { + for (int i = 0; i < count; i++) { + if (item.getCredits() <= this.client.getHabbo().getHabboInfo().getCredits() - totalCredits) { if ( item.getPoints() <= this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints) //item.getPointsType() == 0 && item.getPoints() <= this.client.getHabbo().getHabboInfo().getPixels() - totalPoints || { - if (((i + 1) % 6 != 0 && CatalogItem.haveOffer(item)) || !CatalogItem.haveOffer(item)) - { + if (((i + 1) % 6 != 0 && CatalogItem.haveOffer(item)) || !CatalogItem.haveOffer(item)) { totalCredits += item.getCredits(); totalPoints += item.getPoints(); } - for (int j = 0; j < item.getAmount(); j++) - { - if (item.getAmount() > 1 || item.getBaseItems().size() > 1) - { + for (int j = 0; j < item.getAmount(); j++) { + if (item.getAmount() > 1 || item.getBaseItems().size() > 1) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - for (Item baseItem : item.getBaseItems()) - { - if (item.getItemAmount(baseItem.getId()) > 1) - { + for (Item baseItem : item.getBaseItems()) { + if (item.getItemAmount(baseItem.getId()) > 1) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) - { - if (!baseItem.getName().contains("avatar_effect")) - { - if (baseItem.getType() == FurnitureType.BADGE) - { - if (!badgeFound) - { - if (habbo != null) - { + for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) { + if (!baseItem.getName().contains("avatar_effect")) { + if (baseItem.getType() == FurnitureType.BADGE) { + if (!badgeFound) { + if (habbo != null) { HabboBadge badge = new HabboBadge(0, baseItem.getName(), 0, habbo); Emulator.getThreading().run(badge); habbo.getInventory().getBadgesComponent().addBadge(badge); - } else - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) - { + } else { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) { statement.setInt(1, userId); statement.setString(2, baseItem.getName()); statement.execute(); @@ -304,46 +250,37 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler badgeFound = true; } - } else if (item.getName().startsWith("rentable_bot_")) - { + } else if (item.getName().startsWith("rentable_bot_")) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; - } else if (Item.isPet(baseItem)) - { + } else if (Item.isPet(baseItem)) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; - } else - { - if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) - { + } else { + if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) { extraData = this.client.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 + extraData; } - if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) - { + if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) { HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId()); itemsList.add(teleportOne); itemsList.add(teleportTwo); - } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) - { + } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) { HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData); Emulator.getGameEnvironment().getItemManager().insertHopper(hopper); itemsList.add(hopper); - } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) - { + } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) { InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); habboItem.setExtradata(""); habboItem.needsUpdate(true); int guildId; - try - { + try { guildId = Integer.parseInt(extraData); - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; @@ -351,14 +288,12 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler Emulator.getThreading().run(habboItem); Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId); itemsList.add(habboItem); - } else - { + } else { HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); itemsList.add(habboItem); } } - } else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("error.catalog.buy.not_yet"))); return; @@ -372,8 +307,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler StringBuilder giftData = new StringBuilder(itemsList.size() + "\t"); - for (HabboItem i : itemsList) - { + for (HabboItem i : itemsList) { giftData.append(i.getId()).append("\t"); } @@ -381,15 +315,13 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler HabboItem gift = Emulator.getGameEnvironment().getItemManager().createGift(username, giftItem, giftData.toString(), 0, 0); - if (gift == null) - { + if (gift == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftGiver")); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new AddHabboItemComposer(gift)); habbo.getClient().getHabbo().getInventory().getItemsComponent().addItem(gift); habbo.getClient().sendResponse(new InventoryRefreshComposer()); @@ -397,8 +329,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler keys.put("display", "BUBBLE"); keys.put("image", "${image.library.url}notifications/gift.gif"); keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous")); - if (showName) - { + if (showName) { keys.put("message", Emulator.getTexts().getValue("generic.gift.received").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys)); @@ -406,40 +337,29 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler AchievementManager.progressAchievement(userId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftReceiver")); - if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) - { - if (totalCredits > 0) - { + if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) { + if (totalCredits > 0) { this.client.getHabbo().giveCredits(-totalCredits); } } - if (totalPoints > 0) - { - if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermission("acc_infinite_pixels")) - { + if (totalPoints > 0) { + if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermission("acc_infinite_pixels")) { this.client.getHabbo().getHabboInfo().addPixels(-totalPoints); - } else if (!this.client.getHabbo().hasPermission("acc_infinite_points")) - { + } else if (!this.client.getHabbo().hasPermission("acc_infinite_points")) { this.client.getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -totalPoints); } this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -totalPoints, item.getPointsType())); } this.client.sendResponse(new PurchaseOKComposer(item)); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logPacketError(e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } - } - finally - { + } finally { this.client.getHabbo().getHabboStats().isPurchasingFurniture = false; } - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java index d9014346..67a89975 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java @@ -18,7 +18,6 @@ import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseUnavailableComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.users.*; @@ -26,16 +25,12 @@ import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; -public class CatalogBuyItemEvent extends MessageHandler -{ +public class CatalogBuyItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) - { + public void handle() throws Exception { + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { this.client.getHabbo().getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); - if (ShutdownEmulator.timestamp > 0) - { + if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); return; } @@ -45,72 +40,57 @@ public class CatalogBuyItemEvent extends MessageHandler String extraData = this.packet.readString(); int count = this.packet.readInt(); - try - { - if (this.client.getHabbo().getInventory().getItemsComponent().itemCount() > HabboInventory.MAXIMUM_ITEMS) - { + try { + if (this.client.getHabbo().getInventory().getItemsComponent().itemCount() > HabboInventory.MAXIMUM_ITEMS) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); this.client.getHabbo().alert(Emulator.getTexts().getValue("inventory.full")); return; } - } catch (Exception e) - { + } catch (Exception e) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); } CatalogPage page = null; - if (pageId == -12345678 || pageId == -1) - { + if (pageId == -12345678 || pageId == -1) { CatalogItem searchedItem = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(itemId); - if (searchedItem.getOfferId() > 0) - { + if (searchedItem.getOfferId() > 0) { page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(searchedItem.getPageId()); - if (page.getCatalogItem(itemId).getOfferId() <= 0) - { + if (page.getCatalogItem(itemId).getOfferId() <= 0) { page = null; - } else - { - if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) - { + } else { + if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) { page = null; } } } - } else - { + } else { page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(pageId); - if (page instanceof RoomBundleLayout) - { + if (page instanceof RoomBundleLayout) { final CatalogItem[] item = new CatalogItem[1]; - page.getCatalogItems().forEachValue(new TObjectProcedure() - { + page.getCatalogItems().forEachValue(new TObjectProcedure() { @Override - public boolean execute(CatalogItem object) - { + public boolean execute(CatalogItem object) { item[0] = object; return false; } }); - if (item[0] == null || item[0].getCredits() > this.client.getHabbo().getHabboInfo().getCredits() || item[0].getPoints() > this.client.getHabbo().getHabboInfo().getCurrencyAmount(item[0].getPointsType())) - { + if (item[0] == null || item[0].getCredits() > this.client.getHabbo().getHabboInfo().getCredits() || item[0].getPoints() > this.client.getHabbo().getHabboInfo().getCurrencyAmount(item[0].getPointsType())) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } ((RoomBundleLayout) page).buyRoom(this.client.getHabbo()); - if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) - { + if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) { this.client.getHabbo().getHabboInfo().addCredits(-item[0].getCredits()); } - if (!this.client.getHabbo().hasPermission("acc_inifinte_points")) - { + if (!this.client.getHabbo().hasPermission("acc_inifinte_points")) { this.client.getHabbo().getHabboInfo().addCurrencyAmount(item[0].getPointsType(), -item[0].getPoints()); } @@ -118,8 +98,7 @@ public class CatalogBuyItemEvent extends MessageHandler final boolean[] badgeFound = {false}; item[0].getBaseItems().stream().filter(i -> i.getType() == FurnitureType.BADGE).forEach(i -> { - if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(i.getName())) - { + if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(i.getName())) { HabboBadge badge = new HabboBadge(0, i.getName(), 0, this.client.getHabbo()); Emulator.getThreading().run(badge); this.client.getHabbo().getInventory().getBadgesComponent().addBadge(badge); @@ -129,14 +108,12 @@ public class CatalogBuyItemEvent extends MessageHandler 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 BubbleAlertComposer(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); - } else - { + } else { badgeFound[0] = true; } }); - if (badgeFound[0]) - { + if (badgeFound[0]) { this.client.getHabbo().getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE)); } @@ -144,24 +121,20 @@ public class CatalogBuyItemEvent extends MessageHandler } } - if (page == null) - { + if (page == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } - if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) - { + if (page.getRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) { this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } - if (page instanceof ClubBuyLayout || page instanceof VipBuyLayout) - { + if (page instanceof ClubBuyLayout || page instanceof VipBuyLayout) { ClubOffer item = Emulator.getGameEnvironment().getCatalogManager().clubOffers.get(itemId); - if (item == null) - { + if (item == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); return; } @@ -170,15 +143,13 @@ public class CatalogBuyItemEvent extends MessageHandler int totalCredits = 0; int totalDuckets = 0; - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { totalDays += item.getDays(); totalCredits += item.getCredits(); totalDuckets += item.getPoints(); } - if (totalDays > 0) - { + if (totalDays > 0) { if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) < totalDuckets) return; @@ -220,9 +191,7 @@ public class CatalogBuyItemEvent extends MessageHandler Emulator.getGameEnvironment().getCatalogManager().purchaseItem(page, item, this.client.getHabbo(), count, extraData, false); - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSearchedItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSearchedItemEvent.java index ddf29925..0851e03e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSearchedItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSearchedItemEvent.java @@ -7,31 +7,25 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.CatalogSearchResultComposer; import gnu.trove.iterator.TIntObjectIterator; -public class CatalogSearchedItemEvent extends MessageHandler -{ +public class CatalogSearchedItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int offerId = this.packet.readInt(); int pageId = Emulator.getGameEnvironment().getCatalogManager().offerDefs.get(offerId); - if(pageId != 0) - { + if (pageId != 0) { CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(pageId).getPageId()); - if (page != null) - { + if (page != null) { TIntObjectIterator iterator = page.getCatalogItems().iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { iterator.advance(); CatalogItem item = iterator.value(); - if (item.getOfferId() == offerId) - { + if (item.getOfferId() == offerId) { this.client.sendResponse(new CatalogSearchResultComposer(item)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CheckPetNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CheckPetNameEvent.java index 339c1014..d71897c5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CheckPetNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CheckPetNameEvent.java @@ -5,30 +5,21 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PetNameErrorComposer; import org.apache.commons.lang3.StringUtils; -public class CheckPetNameEvent extends MessageHandler -{ +public class CheckPetNameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String petName = this.packet.readString(); int minLength = Emulator.getConfig().getInt("hotel.pets.name.length.min"); int maxLength = Emulator.getConfig().getInt("hotel.pets.name.length.max"); - if(petName.length() < minLength) - { + if (petName.length() < minLength) { this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_SHORT, minLength + "")); - } - else if(petName.length() > maxLength) - { + } else if (petName.length() > maxLength) { this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_LONG, maxLength + "")); - } - else if(!StringUtils.isAlphanumeric(petName)) - { + } else if (!StringUtils.isAlphanumeric(petName)) { this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.FORBIDDEN_CHAR, petName)); - } - else - { + } else { this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_OK, petName)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackCodeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackCodeEvent.java index 4e3d2f39..d53c534e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackCodeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackCodeEvent.java @@ -5,17 +5,14 @@ import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxTrackCodeComposer; -public class JukeBoxRequestTrackCodeEvent extends MessageHandler -{ +public class JukeBoxRequestTrackCodeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String songName = this.packet.readString(); final SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(songName); - if(track != null) - { + if (track != null) { this.client.sendResponse(new JukeBoxTrackCodeComposer(track)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackDataEvent.java index 7c84367f..de8c2c6f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/JukeBoxRequestTrackDataEvent.java @@ -8,20 +8,17 @@ import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxTrackDataCompos import java.util.ArrayList; import java.util.List; -public class JukeBoxRequestTrackDataEvent extends MessageHandler -{ +public class JukeBoxRequestTrackDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int count = this.packet.readInt(); List tracks = new ArrayList<>(count); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.packet.readInt()); - if(track != null) + if (track != null) tracks.add(track); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetOfferEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetOfferEvent.java index 08c1e0e4..3ef97b24 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetOfferEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseTargetOfferEvent.java @@ -7,36 +7,30 @@ import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.messages.incoming.MessageHandler; -public class PurchaseTargetOfferEvent extends MessageHandler -{ +public class PurchaseTargetOfferEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int offerId = this.packet.readInt(); int amount = this.packet.readInt(); if (amount <= 0) return; - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) - { + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { this.client.getHabbo().getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); TargetOffer offer = Emulator.getGameEnvironment().getCatalogManager().getTargetOffer(offerId); HabboOfferPurchase purchase = HabboOfferPurchase.getOrCreate(this.client.getHabbo(), offerId); - if (purchase != null) - { + if (purchase != null) { amount = Math.min(offer.getPurchaseLimit() - purchase.getAmount(), amount); int now = Emulator.getIntUnixTimestamp(); - if (offer.getExpirationTime() > now) - { + if (offer.getExpirationTime() > now) { purchase.update(amount, now); CatalogItem item = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(offer.getCatalogItem()); - if (item.isLimited()) - { + if (item.isLimited()) { amount = 1; } Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, this.client.getHabbo(), amount, "", false); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RedeemVoucherEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RedeemVoucherEvent.java index 690ebe08..5923398b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RedeemVoucherEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RedeemVoucherEvent.java @@ -6,21 +6,17 @@ import com.eu.habbo.messages.outgoing.catalog.RedeemVoucherErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; import com.eu.habbo.threading.runnables.ShutdownEmulator; -public class RedeemVoucherEvent extends MessageHandler -{ +public class RedeemVoucherEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (ShutdownEmulator.timestamp > 0) - { + public void handle() throws Exception { + if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); return; } String voucherCode = this.packet.readString(); - if(voucherCode.contains(" ")) - { + if (voucherCode.contains(" ")) { this.client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogIndexEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogIndexEvent.java index f2934ae5..5aa476ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogIndexEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogIndexEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; -public class RequestCatalogIndexEvent extends MessageHandler -{ +public class RequestCatalogIndexEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { //this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), "NORMAL")); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogModeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogModeEvent.java index 9e6fcb5e..9e54083a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogModeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogModeEvent.java @@ -4,19 +4,15 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.CatalogModeComposer; import com.eu.habbo.messages.outgoing.catalog.CatalogPagesListComposer; -public class RequestCatalogModeEvent extends MessageHandler -{ +public class RequestCatalogModeEvent extends MessageHandler { @Override public void handle() throws Exception { String MODE = this.packet.readString(); - if(MODE.equalsIgnoreCase("normal")) - { + if (MODE.equalsIgnoreCase("normal")) { this.client.sendResponse(new CatalogModeComposer(0)); this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), MODE)); - } - else - { + } else { this.client.sendResponse(new CatalogModeComposer(1)); this.client.sendResponse(new CatalogPagesListComposer(this.client.getHabbo(), MODE)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java index 05c4a9ee..2e0f73c5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java @@ -6,28 +6,21 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.CatalogPageComposer; -public class RequestCatalogPageEvent extends MessageHandler -{ +public class RequestCatalogPageEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int catalogPageId = this.packet.readInt(); int unknown = this.packet.readInt(); String mode = this.packet.readString(); CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(catalogPageId); - if (catalogPageId > 0 && page != null) - { - if (page.getRank() <= this.client.getHabbo().getHabboInfo().getRank().getId() && page.isEnabled()) - { + if (catalogPageId > 0 && page != null) { + if (page.getRank() <= this.client.getHabbo().getHabboInfo().getRank().getId() && page.isEnabled()) { this.client.sendResponse(new CatalogPageComposer(page, this.client.getHabbo(), mode)); - } - else - { - if(!page.isVisible()) - { + } else { + if (!page.isVisible()) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.catalog.page").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%pagename%", page.getCaption())); } } 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 index 3f9c4696..259b5799 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubDataEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.ClubDataComposer; -public class RequestClubDataEvent extends MessageHandler -{ +public class RequestClubDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new ClubDataComposer(this.client.getHabbo(), this.packet.readInt())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubGiftsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubGiftsEvent.java index 2114e7bb..98bc8014 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubGiftsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubGiftsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.ClubGiftsComposer; -public class RequestClubGiftsEvent extends MessageHandler -{ +public class RequestClubGiftsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new ClubGiftsComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestDiscountEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestDiscountEvent.java index cfd156a5..fa240d80 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestDiscountEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestDiscountEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; -public class RequestDiscountEvent extends MessageHandler -{ +public class RequestDiscountEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new DiscountComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestGiftConfigurationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestGiftConfigurationEvent.java index a2dd78df..7976ee39 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestGiftConfigurationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestGiftConfigurationEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.GiftConfigurationComposer; -public class RequestGiftConfigurationEvent extends MessageHandler -{ +public class RequestGiftConfigurationEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new GiftConfigurationComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestMarketplaceConfigEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestMarketplaceConfigEvent.java index 4962d6cf..8442fd6a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestMarketplaceConfigEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestMarketplaceConfigEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; -public class RequestMarketplaceConfigEvent extends MessageHandler -{ +public class RequestMarketplaceConfigEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new MarketplaceConfigComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestPetBreedsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestPetBreedsEvent.java index 6d210713..5d005da0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestPetBreedsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestPetBreedsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PetBreedsComposer; -public class RequestPetBreedsEvent extends MessageHandler -{ +public class RequestPetBreedsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String petName = this.packet.readString(); this.client.sendResponse(new PetBreedsComposer(petName, Emulator.getGameEnvironment().getPetManager().getBreeds(petName))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/TargetOfferStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/TargetOfferStateEvent.java index 809ea476..9d62582c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/TargetOfferStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/TargetOfferStateEvent.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.messages.incoming.MessageHandler; -public class TargetOfferStateEvent extends MessageHandler -{ +public class TargetOfferStateEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int id = this.packet.readInt(); int state = this.packet.readInt(); HabboOfferPurchase purchase = this.client.getHabbo().getHabboStats().getHabboOfferPurchase(id); - if (purchase != null) - { + if (purchase != null) { purchase.setState(state); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/BuyItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/BuyItemEvent.java index 4b4c0274..b9af0be8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/BuyItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/BuyItemEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.messages.incoming.MessageHandler; -public class BuyItemEvent extends MessageHandler -{ +public class BuyItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int offerId = this.packet.readInt(); MarketPlace.buyItem(offerId, this.client); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestCreditsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestCreditsEvent.java index f4b78542..b03fda10 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestCreditsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestCreditsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.messages.incoming.MessageHandler; -public class RequestCreditsEvent extends MessageHandler -{ +public class RequestCreditsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { MarketPlace.getCredits(this.client); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestItemInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestItemInfoEvent.java index f12912d4..45c043f6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestItemInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestItemInfoEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceItemInfoComposer; -public class RequestItemInfoEvent extends MessageHandler -{ +public class RequestItemInfoEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.packet.readInt(); int id = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOffersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOffersEvent.java index 0753142c..c091c1be 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOffersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOffersEvent.java @@ -10,28 +10,24 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class RequestOffersEvent extends MessageHandler -{ +public class RequestOffersEvent extends MessageHandler { public final static Map cachedResults = new ConcurrentHashMap<>(0); + @Override - public void handle() throws Exception - { + public void handle() throws Exception { int min = this.packet.readInt(); int max = this.packet.readInt(); String query = this.packet.readString(); int type = this.packet.readInt(); boolean tryCache = false; - if (min == -1 && max == -1 && query.isEmpty()) - { + if (min == -1 && max == -1 && query.isEmpty()) { tryCache = true; } - if (tryCache) - { + if (tryCache) { ServerMessage message = cachedResults.get(type); - if (message != null) - { + if (message != null) { this.client.sendResponse(message); return; } @@ -40,8 +36,7 @@ public class RequestOffersEvent extends MessageHandler List offers = MarketPlace.getOffers(min, max, query, type); ServerMessage message = new MarketplaceOffersComposer(offers).compose(); - if (tryCache) - { + if (tryCache) { cachedResults.put(type, message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOwnItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOwnItemsEvent.java index 02503e48..ddfb95af 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOwnItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestOwnItemsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceOwnItemsComposer; -public class RequestOwnItemsEvent extends MessageHandler -{ +public class RequestOwnItemsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new MarketplaceOwnItemsComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestSellItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestSellItemEvent.java index 72dd369f..452c74c7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestSellItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/RequestSellItemEvent.java @@ -4,12 +4,10 @@ import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceSellItemComposer; -public class RequestSellItemEvent extends MessageHandler -{ +public class RequestSellItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(MarketPlace.MARKETPLACE_ENABLED) + public void handle() throws Exception { + if (MarketPlace.MARKETPLACE_ENABLED) this.client.sendResponse(new MarketplaceSellItemComposer(1, 0, 0)); else this.client.sendResponse(new MarketplaceSellItemComposer(3, 0, 0)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java index 0ef2fd45..5e8a793b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java @@ -7,15 +7,11 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceItemPostedComposer; -import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceSellItemComposer; -public class SellItemEvent extends MessageHandler -{ +public class SellItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(!MarketPlace.MARKETPLACE_ENABLED) - { + public void handle() throws Exception { + if (!MarketPlace.MARKETPLACE_ENABLED) { this.client.sendResponse(new MarketplaceItemPostedComposer(MarketplaceItemPostedComposer.MARKETPLACE_DISABLED)); return; } @@ -26,10 +22,8 @@ public class SellItemEvent extends MessageHandler int itemId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); - if(item != null) - { - if (!item.getBaseItem().allowMarketplace()) - { + if (item != null) { + if (!item.getBaseItem().allowMarketplace()) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); Emulator.getLogging().logUserLine(message); @@ -37,8 +31,7 @@ public class SellItemEvent extends MessageHandler return; } - if(credits < 0) - { + if (credits < 0) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.negative").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); Emulator.getLogging().logUserLine(message); @@ -46,12 +39,9 @@ public class SellItemEvent extends MessageHandler return; } - if(MarketPlace.sellItem(this.client, item, credits)) - { + if (MarketPlace.sellItem(this.client, item, credits)) { this.client.sendResponse(new MarketplaceItemPostedComposer(MarketplaceItemPostedComposer.POST_SUCCESS)); - } - else - { + } else { this.client.sendResponse(new MarketplaceItemPostedComposer(MarketplaceItemPostedComposer.FAILED_TECHNICAL_ERROR)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/TakeBackItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/TakeBackItemEvent.java index 98927a7f..7586afc4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/TakeBackItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/TakeBackItemEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.messages.incoming.MessageHandler; -public class TakeBackItemEvent extends MessageHandler -{ +public class TakeBackItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int offerId = this.packet.readInt(); MarketPlace.takeBackItem(this.client.getHabbo(), offerId); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java index de54f405..3662378b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java @@ -16,44 +16,34 @@ import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import com.eu.habbo.threading.runnables.OpenGift; -public class OpenRecycleBoxEvent extends MessageHandler -{ +public class OpenRecycleBoxEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { HabboItem item = room.getHabboItem(this.packet.readInt()); - if(item == null) + if (item == null) return; - if(item instanceof InteractionGift) - { - if(item.getBaseItem().getName().contains("present_wrap")) - { + if (item instanceof InteractionGift) { + if (item.getBaseItem().getName().contains("present_wrap")) { ((InteractionGift) item).explode = true; room.updateItem(item); } Emulator.getThreading().run(new OpenGift(item, this.client.getHabbo(), room), item.getBaseItem().getName().contains("present_wrap") ? 1000 : 0); - } - else - { - if (item.getExtradata().length() == 0) - { + } else { + if (item.getExtradata().length() == 0) { this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(Emulator.getTexts().getValue("error.recycler.box.empty"), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.BOT))); - } else - { + } else { HabboItem reward = Emulator.getGameEnvironment().getItemManager().handleOpenRecycleBox(this.client.getHabbo(), item); - if (reward != null) - { + if (reward != null) { this.client.getHabbo().getInventory().getItemsComponent().addItem(reward); this.client.sendResponse(new AddHabboItemComposer(reward)); this.client.sendResponse(new InventoryRefreshComposer()); @@ -66,8 +56,7 @@ public class OpenRecycleBoxEvent extends MessageHandler } - if(item.getRoomId() == 0) - { + if (item.getRoomId() == 0) { room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), room.getStackHeight(item.getX(), item.getY(), true)).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleEvent.java index 59cf6391..a3c69775 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleEvent.java @@ -15,54 +15,43 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.set.hash.THashSet; -public class RecycleEvent extends MessageHandler -{ +public class RecycleEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (ShutdownEmulator.timestamp > 0) - { + public void handle() throws Exception { + if (ShutdownEmulator.timestamp > 0) { this.client.sendResponse(new HotelWillCloseInMinutesComposer((ShutdownEmulator.timestamp - Emulator.getIntUnixTimestamp()) / 60)); return; } - if(Emulator.getGameEnvironment().getCatalogManager().ecotronItem != null && ItemManager.RECYCLER_ENABLED) - { + if (Emulator.getGameEnvironment().getCatalogManager().ecotronItem != null && ItemManager.RECYCLER_ENABLED) { THashSet items = new THashSet<>(); int count = this.packet.readInt(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); if (item == null) return; - if (item.getBaseItem().allowRecyle()) - { + if (item.getBaseItem().allowRecyle()) { items.add(item); } } - if (items.size() == count) - { - for (HabboItem item : items) - { + if (items.size() == count) { + for (HabboItem item : items) { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId())); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } HabboItem reward = Emulator.getGameEnvironment().getItemManager().handleRecycle(this.client.getHabbo(), Emulator.getGameEnvironment().getCatalogManager().getRandomRecyclerPrize().getId() + ""); - if(reward == null) - { + if (reward == null) { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -73,9 +62,7 @@ public class RecycleEvent extends MessageHandler this.client.sendResponse(new InventoryRefreshComposer()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FurnimaticQuest")); - } - else - { + } else { this.client.sendResponse(new RecyclerCompleteComposer(RecyclerCompleteComposer.RECYCLING_CLOSED)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/ReloadRecyclerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/ReloadRecyclerEvent.java index 9a4a6310..34fddc6a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/ReloadRecyclerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/ReloadRecyclerEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.recycler; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.ReloadRecyclerComposer; -public class ReloadRecyclerEvent extends MessageHandler -{ +public class ReloadRecyclerEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new ReloadRecyclerComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RequestRecyclerLogicEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RequestRecyclerLogicEvent.java index 3cc72436..0da41c0c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RequestRecyclerLogicEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RequestRecyclerLogicEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.catalog.recycler; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.RecyclerLogicComposer; -public class RequestRecyclerLogicEvent extends MessageHandler -{ +public class RequestRecyclerLogicEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new RecyclerLogicComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingAddRecipeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingAddRecipeEvent.java index b9500156..277eb19d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingAddRecipeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingAddRecipeEvent.java @@ -6,18 +6,14 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.AlertLimitedSoldOutComposer; import com.eu.habbo.messages.outgoing.crafting.CraftingRecipeComposer; -public class CraftingAddRecipeEvent extends MessageHandler -{ +public class CraftingAddRecipeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String recipeName = this.packet.readString(); CraftingRecipe recipe = Emulator.getGameEnvironment().getCraftingManager().getRecipe(recipeName); - if (recipe != null) - { - if (!recipe.canBeCrafted()) - { + if (recipe != null) { + if (!recipe.canBeCrafted()) { this.client.sendResponse(new AlertLimitedSoldOutComposer()); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java index eb0bc703..02936f01 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java @@ -18,33 +18,26 @@ import gnu.trove.procedure.TObjectProcedure; import java.util.Map; -public class CraftingCraftItemEvent extends MessageHandler -{ +public class CraftingCraftItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int craftingTable = this.packet.readInt(); HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(craftingTable); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); CraftingRecipe recipe = altar.getRecipe(this.packet.readString()); - if (recipe != null) - { - if (!recipe.canBeCrafted()) - { + if (recipe != null) { + if (!recipe.canBeCrafted()) { this.client.sendResponse(new AlertLimitedSoldOutComposer()); return; } TIntObjectHashMap toRemove = new TIntObjectHashMap<>(); - for (Map.Entry set : recipe.getIngredients().entrySet()) - { - for (int i = 0; i < set.getValue(); i++) - { + for (Map.Entry set : recipe.getIngredients().entrySet()) { + for (int i = 0; i < set.getValue(); i++) { HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getAndRemoveHabboItem(set.getKey()); - if (habboItem == null) - { + if (habboItem == null) { return; } @@ -54,26 +47,21 @@ public class CraftingCraftItemEvent extends MessageHandler HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); - if (rewardItem != null) - { - if (recipe.isLimited()) - { + if (rewardItem != null) { + if (recipe.isLimited()) { recipe.decrease(); } - if (!recipe.getAchievement().isEmpty()) - { + if (!recipe.getAchievement().isEmpty()) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(recipe.getAchievement())); } this.client.sendResponse(new CraftingResultComposer(recipe)); this.client.getHabbo().getInventory().getItemsComponent().addItem(rewardItem); this.client.sendResponse(new AddHabboItemComposer(rewardItem)); - toRemove.forEachValue(new TObjectProcedure() - { + toRemove.forEachValue(new TObjectProcedure() { @Override - public boolean execute(HabboItem object) - { + public boolean execute(HabboItem object) { CraftingCraftItemEvent.this.client.sendResponse(new RemoveHabboItemComposer(object.getGiftAdjustedId())); return true; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftSecretEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftSecretEvent.java index d3fd19ff..f93f2084 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftSecretEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftSecretEvent.java @@ -19,39 +19,32 @@ import gnu.trove.set.hash.THashSet; import java.util.Map; import java.util.Set; -public class CraftingCraftSecretEvent extends MessageHandler -{ +public class CraftingCraftSecretEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int altarId = this.packet.readInt(); int count = this.packet.readInt(); HabboItem craftingAltar = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(altarId); - if (craftingAltar != null) - { + if (craftingAltar != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(craftingAltar.getBaseItem()); - if (altar != null) - { + if (altar != null) { Set habboItems = new THashSet<>(); Map items = new THashMap<>(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if (habboItem == null) - { + if (habboItem == null) { this.client.sendResponse(new CraftingResultComposer(null)); return; } habboItems.add(habboItem); - if (!items.containsKey(habboItem.getBaseItem())) - { + if (!items.containsKey(habboItem.getBaseItem())) { items.put(habboItem.getBaseItem(), 0); } @@ -60,38 +53,31 @@ public class CraftingCraftSecretEvent extends MessageHandler CraftingRecipe recipe = altar.getRecipe(items); - if (recipe != null) - { - if (!recipe.canBeCrafted()) - { + if (recipe != null) { + if (!recipe.canBeCrafted()) { this.client.sendResponse(new AlertLimitedSoldOutComposer()); return; } HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); - if (rewardItem != null) - { - if (recipe.isLimited()) - { + if (rewardItem != null) { + if (recipe.isLimited()) { recipe.decrease(); } - if (!recipe.getAchievement().isEmpty()) - { + if (!recipe.getAchievement().isEmpty()) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(recipe.getAchievement())); } this.client.sendResponse(new CraftingResultComposer(recipe)); - if (!this.client.getHabbo().getHabboStats().hasRecipe(recipe.getId())) - { + if (!this.client.getHabbo().getHabboStats().hasRecipe(recipe.getId())) { this.client.getHabbo().getHabboStats().addRecipe(recipe.getId()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("AtcgSecret")); } this.client.getHabbo().getInventory().getItemsComponent().addItem(rewardItem); this.client.sendResponse(new AddHabboItemComposer(rewardItem)); - for (HabboItem item : habboItems) - { + for (HabboItem item : habboItems) { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId())); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesAvailableEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesAvailableEvent.java index 98cc83c9..cb709d1d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesAvailableEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesAvailableEvent.java @@ -11,30 +11,24 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class RequestCraftingRecipesAvailableEvent extends MessageHandler -{ +public class RequestCraftingRecipesAvailableEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int altarId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(altarId); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); - if (altar != null) - { + if (altar != null) { Map items = new THashMap<>(); int count = this.packet.readInt(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if (habboItem != null) - { - if (!items.containsKey(habboItem.getBaseItem())) - { + if (habboItem != null) { + if (!items.containsKey(habboItem.getBaseItem())) { items.put(habboItem.getBaseItem(), 0); } @@ -43,8 +37,7 @@ public class RequestCraftingRecipesAvailableEvent extends MessageHandler } CraftingRecipe equalsRecipe = altar.getRecipe(items); - if (equalsRecipe != null && this.client.getHabbo().getHabboStats().hasRecipe(equalsRecipe.getId())) - { + if (equalsRecipe != null && this.client.getHabbo().getHabboStats().hasRecipe(equalsRecipe.getId())) { //this.client.sendResponse(new CraftingRecipesAvailableComposer(-1, true)); //this.client.sendResponse(new CraftingRecipeComposer(equalsRecipe)); //this.client.sendResponse(new CraftingResultComposer(equalsRecipe, true)); @@ -54,16 +47,13 @@ public class RequestCraftingRecipesAvailableEvent extends MessageHandler boolean found = false; int c = recipes.size(); - for (Map.Entry set : recipes.entrySet()) - { - if (this.client.getHabbo().getHabboStats().hasRecipe(set.getKey().getId())) - { + for (Map.Entry set : recipes.entrySet()) { + if (this.client.getHabbo().getHabboStats().hasRecipe(set.getKey().getId())) { c--; continue; } - if (set.getValue()) - { + if (set.getValue()) { found = true; break; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesEvent.java index 6400c23b..2b4b30ab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/RequestCraftingRecipesEvent.java @@ -6,20 +6,16 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.crafting.CraftableProductsComposer; -public class RequestCraftingRecipesEvent extends MessageHandler -{ +public class RequestCraftingRecipesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item != null) - { + if (item != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); - if (altar != null) - { + if (altar != null) { this.client.sendResponse(new CraftableProductsComposer(altar.getRecipesForHabbo(this.client.getHabbo()), altar.getIngredients())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java index 87cdf6b4..99f87ad0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.events.calendar; import com.eu.habbo.messages.incoming.MessageHandler; -public class AdventCalendarForceOpenEvent extends MessageHandler -{ +public class AdventCalendarForceOpenEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String campaign = this.packet.readString(); int day = this.packet.readInt(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java index 6448a309..51cbd07a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.events.calendar; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; -public class AdventCalendarOpenDayEvent extends MessageHandler -{ +public class AdventCalendarOpenDayEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String campaign = this.packet.readString(); int day = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestBlockedTilesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestBlockedTilesEvent.java index aaafccf9..9599edf4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestBlockedTilesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestBlockedTilesEvent.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.incoming.floorplaneditor; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.floorplaneditor.FloorPlanEditorBlockedTilesComposer; -public class FloorPlanEditorRequestBlockedTilesEvent extends MessageHandler -{ +public class FloorPlanEditorRequestBlockedTilesEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; this.client.sendResponse(new FloorPlanEditorBlockedTilesComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestDoorSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestDoorSettingsEvent.java index 6ed783ee..a2de8842 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestDoorSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorRequestDoorSettingsEvent.java @@ -4,12 +4,10 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.floorplaneditor.FloorPlanEditorDoorSettingsComposer; import com.eu.habbo.messages.outgoing.rooms.RoomFloorThicknessUpdatedComposer; -public class FloorPlanEditorRequestDoorSettingsEvent extends MessageHandler -{ +public class FloorPlanEditorRequestDoorSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; this.client.sendResponse(new FloorPlanEditorDoorSettingsComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index 457b6c57..65f54683 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -17,33 +17,28 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -public class FloorPlanEditorSaveEvent extends MessageHandler -{ +public class FloorPlanEditorSaveEvent extends MessageHandler { public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64; public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64; @Override - public void handle() throws Exception - { - if (!this.client.getHabbo().hasPermission("acc_floorplan_editor")) - { + public void handle() throws Exception { + if (!this.client.getHabbo().hasPermission("acc_floorplan_editor")) { this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("floorplan.permission"))); return; } Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { List errors = new ArrayList<>(); String map = this.packet.readString(); map = map.replace("X", "x"); - if(map.isEmpty() || map.replace("x", "").replace(((char) 13) + "", "").length() == 0) - { + if (map.isEmpty() || map.replace("x", "").replace(((char) 13) + "", "").length() == 0) { errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); } @@ -52,34 +47,26 @@ public class FloorPlanEditorSaveEvent extends MessageHandler String[] data = map.split(((char) 13) + ""); - if (errors.isEmpty()) - { - if (map.length() > 64 * 64) - { + if (errors.isEmpty()) { + if (map.length() > 64 * 64) { errors.add("${notification.floorplan_editor.error.message.too_large_area}"); } lengthY = data.length; - if (data.length > 64) - { + if (data.length > 64) { errors.add("${notification.floorplan_editor.error.message.too_large_height}"); - } else - { - for (String s : data) - { - if (lengthX == -1) - { + } else { + for (String s : data) { + if (lengthX == -1) { lengthX = s.length(); } - if (s.length() != lengthX) - { + if (s.length() != lengthX) { break; } - if (s.length() > 64 || s.length() == 0) - { + if (s.length() > 64 || s.length() == 0) { errors.add("${notification.floorplan_editor.error.message.too_large_width}"); } } @@ -89,44 +76,37 @@ public class FloorPlanEditorSaveEvent extends MessageHandler int doorX = this.packet.readInt(); int doorY = this.packet.readInt(); - if (doorX < 0 || doorX > lengthX || doorY < 0 || doorY > lengthY || data[doorY].charAt(doorX) == 'x') - { + if (doorX < 0 || doorX > lengthX || doorY < 0 || doorY > lengthY || data[doorY].charAt(doorX) == 'x') { errors.add("${notification.floorplan_editor.error.message.entry_tile_outside_map}"); } int doorRotation = this.packet.readInt(); - if (doorRotation < 0 || doorRotation > 7) - { + if (doorRotation < 0 || doorRotation > 7) { errors.add("${notification.floorplan_editor.error.message.invalid_entry_tile_direction}"); } int wallSize = this.packet.readInt(); - if (wallSize < -2 || wallSize > 1) - { + if (wallSize < -2 || wallSize > 1) { errors.add("${notification.floorplan_editor.error.message.invalid_wall_thickness}"); } int floorSize = this.packet.readInt(); - if (floorSize < -2 || floorSize > 1) - { + if (floorSize < -2 || floorSize > 1) { errors.add("${notification.floorplan_editor.error.message.invalid_floor_thickness}"); } int wallHeight = -1; - if(this.packet.bytesAvailable() >= 4) + if (this.packet.bytesAvailable() >= 4) wallHeight = this.packet.readInt(); - if (wallHeight < -1 || wallHeight > 15) - { + if (wallHeight < -1 || wallHeight > 15) { errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}"); } - if (!errors.isEmpty()) - { + if (!errors.isEmpty()) { StringBuilder errorMessage = new StringBuilder(); - for (String s : errors) - { + for (String s : errors) { errorMessage.append(s).append("
"); } this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errorMessage.toString())); @@ -135,31 +115,26 @@ public class FloorPlanEditorSaveEvent extends MessageHandler RoomLayout layout = room.getLayout(); - if(layout instanceof CustomRoomLayout) - { + if (layout instanceof CustomRoomLayout) { layout.setDoorX((short) doorX); layout.setDoorY((short) doorY); layout.setDoorDirection(doorRotation); layout.setHeightmap(map); layout.parse(); - if (layout.getDoorTile() == null) - { + if (layout.getDoorTile() == null) { this.client.getHabbo().alert("Error"); - ((CustomRoomLayout)layout).needsUpdate(false); + ((CustomRoomLayout) layout).needsUpdate(false); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); return; } - ((CustomRoomLayout)layout).needsUpdate(true); - Emulator.getThreading().run((CustomRoomLayout)layout); - } - else - { + ((CustomRoomLayout) layout).needsUpdate(true); + Emulator.getThreading().run((CustomRoomLayout) layout); + } else { layout = Emulator.getGameEnvironment().getRoomManager().insertCustomLayout(room, map, doorX, doorY, doorRotation); } - if(layout != null) - { + if (layout != null) { room.setHasCustomLayout(true); room.setNeedsUpdate(true); room.setLayout(layout); @@ -172,8 +147,7 @@ public class FloorPlanEditorSaveEvent extends MessageHandler Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); - for (Habbo habbo : habbos) - { + for (Habbo habbo : habbos) { habbo.getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java index 4d79c997..aa5b1821 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java @@ -5,22 +5,19 @@ import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class AcceptFriendRequestEvent extends MessageHandler -{ +public class AcceptFriendRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int count = this.packet.readInt(); int userId; - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { userId = this.packet.readInt(); - if(userId == 0) + if (userId == 0) return; - if(this.client.getHabbo().getMessenger().getFriends().containsKey(userId)) + if (this.client.getHabbo().getMessenger().getFriends().containsKey(userId)) continue; this.client.getHabbo().getMessenger().acceptFriendRequest(userId, this.client.getHabbo().getHabboInfo().getId()); @@ -29,8 +26,7 @@ public class AcceptFriendRequestEvent extends MessageHandler Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (target != null) - { + if (target != null) { Messenger.checkFriendSizeProgress(target); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java index 328848bb..cb02842f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java @@ -5,20 +5,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.UpdateFriendComposer; import com.eu.habbo.plugin.events.users.friends.UserRelationShipEvent; -public class ChangeRelationEvent extends MessageHandler -{ +public class ChangeRelationEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); int relationId = this.packet.readInt(); MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriends().get(userId); - if(buddy != null && relationId >= 0 && relationId <= 3) - { + if (buddy != null && relationId >= 0 && relationId <= 3) { UserRelationShipEvent event = new UserRelationShipEvent(this.client.getHabbo(), buddy, relationId); - if (!event.isCancelled()) - { + if (!event.isCancelled()) { buddy.setRelation(event.relationShip); this.client.sendResponse(new UpdateFriendComposer(buddy)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/DeclineFriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/DeclineFriendRequestEvent.java index 928c4c0c..8010cf5f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/DeclineFriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/DeclineFriendRequestEvent.java @@ -2,23 +2,17 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.messages.incoming.MessageHandler; -public class DeclineFriendRequestEvent extends MessageHandler -{ +public class DeclineFriendRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { boolean all = this.packet.readBoolean(); - if (all) - { + if (all) { this.client.getHabbo().getMessenger().deleteAllFriendRequests(this.client.getHabbo().getHabboInfo().getId()); - } - else - { + } else { int count = this.packet.readInt(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { this.client.getHabbo().getMessenger().deleteFriendRequests(this.packet.readInt(), this.client.getHabbo().getHabboInfo().getId()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java index 97f51ec9..c582d2a9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java @@ -10,24 +10,19 @@ import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import java.util.Collections; import java.util.List; -public class FindNewFriendsEvent extends MessageHandler -{ +public class FindNewFriendsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { List roomCategories = Emulator.getGameEnvironment().getRoomManager().roomCategoriesForHabbo(this.client.getHabbo()); Collections.shuffle(roomCategories); - for (RoomCategory category : roomCategories) - { + for (RoomCategory category : roomCategories) { List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(category.getId()); - if(!rooms.isEmpty()) - { + if (!rooms.isEmpty()) { Room room = rooms.get(0); - if (room.getUserCount() > 0) - { + if (room.getUserCount() > 0) { this.client.sendResponse(new ForwardToRoomComposer(room.getId())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java index fdd95137..3a472fcb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java @@ -1,31 +1,22 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.commands.CommandHandler; -import com.eu.habbo.habbohotel.messenger.Message; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; -import com.eu.habbo.habbohotel.modtool.WordFilter; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer; import com.eu.habbo.plugin.events.users.friends.UserFriendChatEvent; -public class FriendPrivateMessageEvent extends MessageHandler -{ +public class FriendPrivateMessageEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); String message = this.packet.readString(); - if (!this.client.getHabbo().getHabboStats().allowTalk()) - { + if (!this.client.getHabbo().getHabboStats().allowTalk()) { return; } long millis = System.currentTimeMillis(); - if (millis - this.client.getHabbo().getHabboStats().lastChat < 750) - { + if (millis - this.client.getHabbo().getHabboStats().lastChat < 750) { return; } this.client.getHabbo().getHabboStats().lastChat = millis; @@ -35,7 +26,7 @@ public class FriendPrivateMessageEvent extends MessageHandler return; UserFriendChatEvent event = new UserFriendChatEvent(this.client.getHabbo(), buddy, message); - if(Emulator.getPluginManager().fireEvent(event).isCancelled()) + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; buddy.onMessageReceived(this.client.getHabbo(), message); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java index 6cd5fd31..a13616ee 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java @@ -15,16 +15,13 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class FriendRequestEvent extends MessageHandler -{ +public class FriendRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String username = this.packet.readString(); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); - if(Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, habbo)).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, habbo)).isCancelled()) { this.client.sendResponse(new FriendRequestErrorComposer(2)); return; } @@ -33,63 +30,48 @@ public class FriendRequestEvent extends MessageHandler boolean allowFriendRequests = true; FriendRequest friendRequest = this.client.getHabbo().getMessenger().findFriendRequest(username); - if (friendRequest != null) - { + if (friendRequest != null) { this.client.getHabbo().getMessenger().acceptFriendRequest(friendRequest.getId(), this.client.getHabbo().getHabboInfo().getId()); return; } - if(!Messenger.canFriendRequest(this.client.getHabbo(), username)) - { + if (!Messenger.canFriendRequest(this.client.getHabbo(), username)) { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); return; } - if(habbo == null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users_settings.block_friendrequests, users.id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE username = ? LIMIT 1")) - { + if (habbo == null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users_settings.block_friendrequests, users.id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE username = ? LIMIT 1")) { statement.setString(1, username); - try (ResultSet set = statement.executeQuery()) - { - while (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { id = set.getInt("id"); allowFriendRequests = set.getString("block_friendrequests").equalsIgnoreCase("0"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); return; } - } - else - { + } else { id = habbo.getHabboInfo().getId(); allowFriendRequests = !habbo.getHabboStats().blockFriendRequests; - if(allowFriendRequests) + if (allowFriendRequests) habbo.getClient().sendResponse(new FriendRequestComposer(this.client.getHabbo())); } - if(id != 0) - { - if(!allowFriendRequests) - { + if (id != 0) { + if (!allowFriendRequests) { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_ACCEPTING_REQUESTS)); return; } - if(this.client.getHabbo().getMessenger().getFriends().values().size() >= Messenger.friendLimit(this.client.getHabbo()) && !this.client.getHabbo().hasPermission("acc_infinite_friends")) - { + if (this.client.getHabbo().getMessenger().getFriends().values().size() >= Messenger.friendLimit(this.client.getHabbo()) && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_OWN_FULL)); return; } Messenger.makeFriendRequest(this.client.getHabbo().getHabboInfo().getId(), id); - } - else - { + } else { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java index f64b27f5..185e2d47 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java @@ -5,33 +5,26 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.RoomInviteComposer; -public class InviteFriendsEvent extends MessageHandler -{ +public class InviteFriendsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().getHabboStats().allowTalk()) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboStats().allowTalk()) { int[] userIds = new int[this.packet.readInt()]; - for (int i = 0; i < userIds.length; i++) - { + for (int i = 0; i < userIds.length; i++) { userIds[i] = this.packet.readInt(); } String message = this.packet.readString(); - for (int i : userIds) - { + for (int i : userIds) { if (i == 0) continue; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(i); - if (habbo != null) - { - if (!habbo.getHabboStats().blockRoomInvites) - { + if (habbo != null) { + if (!habbo.getHabboStats().blockRoomInvites) { habbo.getClient().sendResponse(new RoomInviteComposer(this.client.getHabbo().getHabboInfo().getId(), message)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RemoveFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RemoveFriendEvent.java index ca25587a..27bc05e2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RemoveFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RemoveFriendEvent.java @@ -7,22 +7,18 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.RemoveFriendComposer; import gnu.trove.list.array.TIntArrayList; -public class RemoveFriendEvent extends MessageHandler -{ +public class RemoveFriendEvent extends MessageHandler { private final TIntArrayList removedFriends; - public RemoveFriendEvent() - { + public RemoveFriendEvent() { this.removedFriends = new TIntArrayList(); } @Override - public void handle() throws Exception - { + public void handle() throws Exception { int count = this.packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { int habboId = this.packet.readInt(); this.removedFriends.add(habboId); @@ -31,8 +27,7 @@ public class RemoveFriendEvent extends MessageHandler Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(habboId); - if(habbo != null) - { + if (habbo != null) { habbo.getMessenger().removeBuddy(this.client.getHabbo()); habbo.getClient().sendResponse(new RemoveFriendComposer(this.client.getHabbo().getHabboInfo().getId())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendRequestsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendRequestsEvent.java index 4f6b94ab..27c70b8a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendRequestsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendRequestsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.LoadFriendRequestsComposer; -public class RequestFriendRequestsEvent extends MessageHandler -{ +public class RequestFriendRequestsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new LoadFriendRequestsComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendsEvent.java index f88e0e85..c0397261 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendsEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.messages.incoming.MessageHandler; -public class RequestFriendsEvent extends MessageHandler -{ +public class RequestFriendsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { //this.client.sendResponse(new FriendsComposer(this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestInitFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestInitFriendsEvent.java index c6d3b342..c77adfec 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestInitFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestInitFriendsEvent.java @@ -7,11 +7,9 @@ import com.eu.habbo.messages.outgoing.friends.MessengerInitComposer; import java.util.ArrayList; -public class RequestInitFriendsEvent extends MessageHandler -{ +public class RequestInitFriendsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { ArrayList messages = new ArrayList<>(); // messages.add(new MessengerInitComposer(this.client.getHabbo()).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/SearchUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/SearchUserEvent.java index eec9d37e..d4b01757 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/SearchUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/SearchUserEvent.java @@ -8,13 +8,11 @@ import gnu.trove.set.hash.THashSet; import java.util.concurrent.ConcurrentHashMap; -public class SearchUserEvent extends MessageHandler -{ +public class SearchUserEvent extends MessageHandler { public static ConcurrentHashMap> cachedResults = new ConcurrentHashMap<>(); @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (System.currentTimeMillis() - this.client.getHabbo().getHabboStats().lastUsersSearched < 3000) return; @@ -23,17 +21,14 @@ public class SearchUserEvent extends MessageHandler if (username.isEmpty()) return; - if (username.length() > 15) - { + if (username.length() > 15) { username = username.substring(0, 15); } - if (this.client.getHabbo().getMessenger() != null) - { + if (this.client.getHabbo().getMessenger() != null) { THashSet buddies = cachedResults.get(username); - if (buddies == null) - { + if (buddies == null) { buddies = Messenger.searchUsers(username); cachedResults.put(username, buddies); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java index 737f48a2..88cb761d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java @@ -10,47 +10,38 @@ import com.eu.habbo.messages.outgoing.friends.StalkErrorComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; -public class StalkFriendEvent extends MessageHandler -{ +public class StalkFriendEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int friendId = this.packet.readInt(); MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(friendId); - if(buddy == null) - { + if (buddy == null) { this.client.sendResponse(new StalkErrorComposer(StalkErrorComposer.NOT_IN_FRIEND_LIST)); return; } Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(friendId); - if(habbo == null || !habbo.isOnline()) - { + if (habbo == null || !habbo.isOnline()) { this.client.sendResponse(new StalkErrorComposer(StalkErrorComposer.FRIEND_OFFLINE)); return; } - if(habbo.getHabboStats().blockFollowing && !this.client.getHabbo().hasPermission("acc_can_stalk")) - { + if (habbo.getHabboStats().blockFollowing && !this.client.getHabbo().hasPermission("acc_can_stalk")) { this.client.sendResponse(new StalkErrorComposer(StalkErrorComposer.FRIEND_BLOCKED_STALKING)); return; } - if(habbo.getHabboInfo().getCurrentRoom() == null) - { + if (habbo.getHabboInfo().getCurrentRoom() == null) { this.client.sendResponse(new StalkErrorComposer(StalkErrorComposer.FRIEND_NOT_IN_ROOM)); return; } - if(habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) - { + if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { this.client.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId())); - } - else - { + } else { this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(Emulator.getTexts().getValue("stalk.failed.same.room").replace("%user%", habbo.getHabboInfo().getUsername()), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterEvent.java index 71af22b1..921ac121 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterEvent.java @@ -2,10 +2,8 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; -public class GameCenterEvent extends MessageHandler -{ +public class GameCenterEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterJoinGameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterJoinGameEvent.java index 00ff01a9..db00af33 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterJoinGameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterJoinGameEvent.java @@ -6,11 +6,9 @@ import com.eu.habbo.messages.outgoing.gamecenter.basejump.BaseJumpJoinQueueCompo import com.eu.habbo.messages.outgoing.gamecenter.basejump.BaseJumpLoadGameComposer; import com.eu.habbo.messages.outgoing.gamecenter.basejump.BaseJumpLoadGameURLComposer; -public class GameCenterJoinGameEvent extends MessageHandler -{ +public class GameCenterJoinGameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int gameId = this.packet.readInt(); if (gameId == 3) //BaseJump @@ -18,9 +16,7 @@ public class GameCenterJoinGameEvent extends MessageHandler this.client.sendResponse(new GameCenterAchievementsConfigurationComposer()); this.client.sendResponse(new BaseJumpLoadGameURLComposer()); this.client.sendResponse(new BaseJumpLoadGameComposer(this.client, 3)); - } - else if (gameId == 4) - { + } else if (gameId == 4) { this.client.sendResponse(new BaseJumpJoinQueueComposer(4)); this.client.sendResponse(new BaseJumpLoadGameURLComposer()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLeaveGameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLeaveGameEvent.java index 2d12ff08..6236f2fd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLeaveGameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLeaveGameEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.gamecenter.basejump.BaseJumpUnloadGameComposer; -public class GameCenterLeaveGameEvent extends MessageHandler -{ +public class GameCenterLeaveGameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new BaseJumpUnloadGameComposer()); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLoadGameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLoadGameEvent.java index 148a804b..acfc2e8d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLoadGameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterLoadGameEvent.java @@ -2,15 +2,12 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; -public class GameCenterLoadGameEvent extends MessageHandler -{ +public class GameCenterLoadGameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int gameId = this.packet.readInt(); - if (gameId == 3) - { + if (gameId == 3) { } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestAccountStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestAccountStatusEvent.java index 93e8b7ea..b476dc37 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestAccountStatusEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestAccountStatusEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAccountInfoComposer; -public class GameCenterRequestAccountStatusEvent extends MessageHandler -{ +public class GameCenterRequestAccountStatusEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new GameCenterAccountInfoComposer(this.packet.readInt(), 10)); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGameStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGameStatusEvent.java index da4a9d99..f2efab02 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGameStatusEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGameStatusEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameComposer; -public class GameCenterRequestGameStatusEvent extends MessageHandler -{ +public class GameCenterRequestGameStatusEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new GameCenterGameComposer(this.packet.readInt(), GameCenterGameComposer.OK)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGamesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGamesEvent.java index 5df6e1ff..cedfabae 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGamesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/gamecenter/GameCenterRequestGamesEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.gamecenter; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAchievementsConfigurationComposer; -public class GameCenterRequestGamesEvent extends MessageHandler -{ +public class GameCenterRequestGamesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new GameCenterAchievementsConfigurationComposer()); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianAcceptRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianAcceptRequestEvent.java index abd4ebbc..1f48b58d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianAcceptRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianAcceptRequestEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.guardians; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuardianAcceptRequestEvent extends MessageHandler -{ +public class GuardianAcceptRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Emulator.getGameEnvironment().getGuideManager().acceptTicket(this.client.getHabbo(), this.packet.readBoolean()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianNoUpdatesWantedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianNoUpdatesWantedEvent.java index 505a8ccc..8dfecacd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianNoUpdatesWantedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianNoUpdatesWantedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.guardians; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuardianNoUpdatesWantedEvent extends MessageHandler -{ +public class GuardianNoUpdatesWantedEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { //TODO: Add dont care about ticket updates. } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java index 93efd24f..0356b9ef 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java @@ -5,33 +5,23 @@ import com.eu.habbo.habbohotel.guides.GuardianTicket; import com.eu.habbo.habbohotel.guides.GuardianVoteType; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuardianVoteEvent extends MessageHandler -{ +public class GuardianVoteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int voteType = this.packet.readInt(); GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getTicketForGuardian(this.client.getHabbo()); - if(ticket != null) - { + if (ticket != null) { GuardianVoteType type = GuardianVoteType.NOT_VOTED; - if(voteType == 0) - { + if (voteType == 0) { type = GuardianVoteType.ACCEPTABLY; - } - else if(voteType == 1) - { + } else if (voteType == 1) { type = GuardianVoteType.BADLY; - } - else if(voteType == 2) - { + } else if (voteType == 2) { type = GuardianVoteType.AWFULLY; - } - else - { + } else { Emulator.getLogging().logErrorLine("Uknown vote type: " + voteType); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCancelHelpRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCancelHelpRequestEvent.java index facbd04a..172c743a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCancelHelpRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCancelHelpRequestEvent.java @@ -4,15 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuideCancelHelpRequestEvent extends MessageHandler -{ +public class GuideCancelHelpRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByNoob(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { tour.end(); Emulator.getGameEnvironment().getGuideManager().endSession(tour); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCloseHelpRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCloseHelpRequestEvent.java index f8284319..84be74d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCloseHelpRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideCloseHelpRequestEvent.java @@ -4,15 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuideCloseHelpRequestEvent extends MessageHandler -{ +public class GuideCloseHelpRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHabbo(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { Emulator.getGameEnvironment().getGuideManager().endSession(tour); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideHandleHelpRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideHandleHelpRequestEvent.java index 19857b95..9089cafe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideHandleHelpRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideHandleHelpRequestEvent.java @@ -4,26 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuideHandleHelpRequestEvent extends MessageHandler -{ +public class GuideHandleHelpRequestEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHelper(this.client.getHabbo()); - if(tour == null) - { + if (tour == null) { return; } boolean accepted = this.packet.readBoolean(); - if(!accepted) - { + if (!accepted) { Emulator.getGameEnvironment().getGuideManager().declineTour(tour); - } - else - { + } else { Emulator.getGameEnvironment().getGuideManager().startSession(tour, this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideInviteUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideInviteUserEvent.java index 2ce04829..9c60efbb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideInviteUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideInviteUserEvent.java @@ -6,15 +6,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideSessionInvitedToGuideRoomComposer; -public class GuideInviteUserEvent extends MessageHandler -{ +public class GuideInviteUserEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHelper(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { ServerMessage message = new GuideSessionInvitedToGuideRoomComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom()).compose(); tour.getNoob().getClient().sendResponse(message); tour.getHelper().getClient().sendResponse(message); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideRecommendHelperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideRecommendHelperEvent.java index 1e407320..9ecf4460 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideRecommendHelperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideRecommendHelperEvent.java @@ -4,17 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; -public class GuideRecommendHelperEvent extends MessageHandler -{ +public class GuideRecommendHelperEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { boolean recommend = this.packet.readBoolean(); GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByNoob(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { Emulator.getGameEnvironment().getGuideManager().recommend(tour, recommend); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideReportHelperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideReportHelperEvent.java index 4c4ab5c8..2b51c31c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideReportHelperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideReportHelperEvent.java @@ -10,21 +10,17 @@ import com.eu.habbo.messages.outgoing.guides.GuideSessionDetachedComposer; import com.eu.habbo.messages.outgoing.guides.GuideSessionEndedComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer; -public class GuideReportHelperEvent extends MessageHandler -{ +public class GuideReportHelperEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String message = this.packet.readString(); GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHabbo(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { Habbo reported = tour.getHelper(); - if(reported == this.client.getHabbo()) - { + if (reported == this.client.getHabbo()) { reported = tour.getNoob(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserMessageEvent.java index 38df6e88..fb84a36c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserMessageEvent.java @@ -7,15 +7,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideSessionMessageComposer; -public class GuideUserMessageEvent extends MessageHandler -{ +public class GuideUserMessageEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHabbo(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { GuideChatMessage chatMessage = new GuideChatMessage(this.client.getHabbo().getHabboInfo().getId(), this.packet.readString(), Emulator.getIntUnixTimestamp()); tour.addMessage(chatMessage); ServerMessage serverMessage = new GuideSessionMessageComposer(chatMessage).compose(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserTypingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserTypingEvent.java index 03fda8d2..2446ca44 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserTypingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideUserTypingEvent.java @@ -5,23 +5,17 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideSessionPartnerIsTypingComposer; -public class GuideUserTypingEvent extends MessageHandler -{ +public class GuideUserTypingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { boolean typing = this.packet.readBoolean(); GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHabbo(this.client.getHabbo()); - if(tour != null) - { - if(tour.getHelper() == this.client.getHabbo()) - { + if (tour != null) { + if (tour.getHelper() == this.client.getHabbo()) { tour.getNoob().getClient().sendResponse(new GuideSessionPartnerIsTypingComposer(typing)); - } - else - { + } else { tour.getHelper().getClient().sendResponse(new GuideSessionPartnerIsTypingComposer(typing)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideVisitUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideVisitUserEvent.java index bf8a9f11..70a10420 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideVisitUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideVisitUserEvent.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideSessionRequesterRoomComposer; -public class GuideVisitUserEvent extends MessageHandler -{ +public class GuideVisitUserEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHelper(this.client.getHabbo()); - if(tour != null) - { + if (tour != null) { this.client.sendResponse(new GuideSessionRequesterRoomComposer(tour.getNoob().getHabboInfo().getCurrentRoom())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideAssistanceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideAssistanceEvent.java index ad829d2c..e51dc166 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideAssistanceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideAssistanceEvent.java @@ -5,18 +5,15 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideSessionErrorComposer; -public class RequestGuideAssistanceEvent extends MessageHandler -{ +public class RequestGuideAssistanceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int type = this.packet.readInt(); String message = this.packet.readString(); GuideTour activeTour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHabbo(this.client.getHabbo()); - if(activeTour != null) - { + if (activeTour != null) { this.client.sendResponse(new GuideSessionErrorComposer(GuideSessionErrorComposer.SOMETHING_WRONG_REQUEST)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideToolEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideToolEvent.java index 40d60f97..a3240e31 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideToolEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/RequestGuideToolEvent.java @@ -4,42 +4,35 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guides.GuideToolsComposer; -public class RequestGuideToolEvent extends MessageHandler -{ +public class RequestGuideToolEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { boolean onDuty = this.packet.readBoolean(); - if(onDuty) - { + if (onDuty) { boolean tourRequests = this.packet.readBoolean(); boolean helperRequests = this.packet.readBoolean(); boolean bullyReports = this.packet.readBoolean(); - if(!this.client.getHabbo().hasPermission("acc_helper_use_guide_tool")) + if (!this.client.getHabbo().hasPermission("acc_helper_use_guide_tool")) return; - if(helperRequests && !this.client.getHabbo().hasPermission("acc_helper_give_guide_tours")) + if (helperRequests && !this.client.getHabbo().hasPermission("acc_helper_give_guide_tours")) helperRequests = false; - if(bullyReports && !this.client.getHabbo().hasPermission("acc_helper_judge_chat_reviews")) + if (bullyReports && !this.client.getHabbo().hasPermission("acc_helper_judge_chat_reviews")) bullyReports = false; - if (helperRequests) - { + if (helperRequests) { Emulator.getGameEnvironment().getGuideManager().setOnGuide(this.client.getHabbo(), onDuty); } - if(bullyReports) - { + if (bullyReports) { Emulator.getGameEnvironment().getGuideManager().setOnGuardian(this.client.getHabbo(), onDuty); } this.client.sendResponse(new GuideToolsComposer(onDuty)); - } - else - { + } else { Emulator.getGameEnvironment().getGuideManager().setOnGuide(this.client.getHabbo(), onDuty); Emulator.getGameEnvironment().getGuideManager().setOnGuardian(this.client.getHabbo(), onDuty); this.client.sendResponse(new GuideToolsComposer(onDuty)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetHabboGuildBadgesMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetHabboGuildBadgesMessageEvent.java index 97e33856..8ca7b6ea 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetHabboGuildBadgesMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetHabboGuildBadgesMessageEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.messages.incoming.MessageHandler; -public class GetHabboGuildBadgesMessageEvent extends MessageHandler -{ +public class GetHabboGuildBadgesMessageEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { } } 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 index 4a3bd93e..497d4c15 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java @@ -12,53 +12,41 @@ import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer; import com.eu.habbo.plugin.events.guilds.GuildAcceptedMembershipEvent; -public class GuildAcceptMembershipEvent extends MessageHandler -{ +public class GuildAcceptMembershipEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null || (guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).containsKey(this.client.getHabbo().getHabboInfo().getId()) && !this.client.getHabbo().hasPermission("acc_guild_admin"))) + if (guild == null || (guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).containsKey(this.client.getHabbo().getHabboInfo().getId()) && !this.client.getHabbo().hasPermission("acc_guild_admin"))) return; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - - if(habbo != null) - { - if (habbo.getHabboStats().hasGuild(guild.getId())) - { + + if (habbo != null) { + if (habbo.getHabboStats().hasGuild(guild.getId())) { this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED)); return; - } - else - { + } else { //Check the user has requested GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); - if(member == null || member.getRank().type != GuildRank.REQUESTED.type) - { + if (member == null || member.getRank().type != GuildRank.REQUESTED.type) { this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER)); return; - } - else - { + } else { GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(event); - if(!event.isCancelled()) - { + if (!event.isCancelled()) { habbo.getHabboStats().addGuild(guild.getId()); Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true); guild.decreaseRequestCount(); guild.increaseMemberCount(); this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); Room room = habbo.getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.getGuildId() == guildId) - { + if (room != null) { + if (room.getGuildId() == guildId) { habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); room.refreshRightsForHabbo(habbo); } @@ -66,9 +54,7 @@ public class GuildAcceptMembershipEvent extends MessageHandler } } } - } - else - { + } else { Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeBadgeEvent.java index 0e7e864f..1edbbd5f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeBadgeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeBadgeEvent.java @@ -6,18 +6,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.guilds.GuildChangedBadgeEvent; -public class GuildChangeBadgeEvent extends MessageHandler -{ +public class GuildChangeBadgeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); if (room == null || room.getId() != guild.getRoomId()) @@ -29,17 +25,14 @@ public class GuildChangeBadgeEvent extends MessageHandler byte base = 1; - while (base < count) - { + while (base < count) { int id = this.packet.readInt(); int color = this.packet.readInt(); int pos = this.packet.readInt(); - if (base == 1) - { + if (base == 1) { badge += "b"; - } else - { + } else { badge += "s"; } @@ -60,8 +53,7 @@ public class GuildChangeBadgeEvent extends MessageHandler guild.setBadge(badgeEvent.badge); guild.needsUpdate = true; - if (Emulator.getConfig().getBoolean("imager.internal.enabled")) - { + if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { Emulator.getBadgeImager().generate(guild); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeColorsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeColorsEvent.java index 56216d4f..ed496ded 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeColorsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeColorsEvent.java @@ -6,34 +6,28 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.guilds.GuildChangedColorsEvent; -public class GuildChangeColorsEvent extends MessageHandler -{ +public class GuildChangeColorsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { GuildChangedColorsEvent colorsEvent = new GuildChangedColorsEvent(guild, this.packet.readInt(), this.packet.readInt()); Emulator.getPluginManager().fireEvent(colorsEvent); if (colorsEvent.isCancelled()) return; - if (guild.getColorOne() != colorsEvent.colorOne || guild.getColorTwo() != colorsEvent.colorTwo) - { + if (guild.getColorOne() != colorsEvent.colorOne || guild.getColorTwo() != colorsEvent.colorTwo) { guild.setColorOne(colorsEvent.colorOne); guild.setColorTwo(colorsEvent.colorTwo); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); - if (room != null && room.getUserCount() > 0) - { + if (room != null && room.getUserCount() > 0) { room.refreshGuild(guild); room.refreshGuildColors(guild); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeNameDescEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeNameDescEvent.java index 5a361f0d..fc28261c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeNameDescEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeNameDescEvent.java @@ -6,19 +6,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.guilds.GuildChangedNameEvent; -public class GuildChangeNameDescEvent extends MessageHandler -{ +public class GuildChangeNameDescEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { GuildChangedNameEvent nameEvent = new GuildChangedNameEvent(guild, this.packet.readString(), this.packet.readString()); Emulator.getPluginManager().fireEvent(nameEvent); @@ -35,8 +31,7 @@ public class GuildChangeNameDescEvent extends MessageHandler Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); - if (room != null && !room.getCurrentHabbos().isEmpty()) - { + if (room != null && !room.getCurrentHabbos().isEmpty()) { room.refreshGuild(guild); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java index 920b72fd..75e20dc5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java @@ -7,19 +7,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.guilds.GuildChangedSettingsEvent; -public class GuildChangeSettingsEvent extends MessageHandler -{ +public class GuildChangeSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); if (room == null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java index a4f5af90..1424241b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java @@ -8,25 +8,20 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildConfirmRemoveMemberComposer; -public class GuildConfirmRemoveMemberEvent extends MessageHandler -{ +public class GuildConfirmRemoveMemberEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null) - { + if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); int count = 0; - if (room != null) - { + if (room != null) { count = room.getUserFurniCount(userId); } this.client.sendResponse(new GuildConfirmRemoveMemberComposer(userId, count)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java index 27a2263e..6c1f5d76 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java @@ -12,21 +12,17 @@ import com.eu.habbo.messages.outgoing.guilds.GuildMembersComposer; import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer; import com.eu.habbo.plugin.events.guilds.GuildDeclinedMembershipEvent; -public class GuildDeclineMembershipEvent extends MessageHandler -{ +public class GuildDeclineMembershipEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null) - { + if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("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)); @@ -35,13 +31,10 @@ public class GuildDeclineMembershipEvent extends MessageHandler Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); Emulator.getPluginManager().fireEvent(new GuildDeclinedMembershipEvent(guild, userId, habbo, this.client.getHabbo())); - if (habbo != null) - { + if (habbo != null) { Room room = habbo.getHabboInfo().getCurrentRoom(); - if (room != null) - { - if (room.getGuildId() == guildId) - { + if (room != null) { + if (room.getGuildId() == guildId) { habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java index 6e332ed3..b5f4300b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java @@ -7,27 +7,22 @@ import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent; -public class GuildDeleteEvent extends MessageHandler -{ +public class GuildDeleteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { + if (guild != null) { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) //TODO Add staff permission override. { Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo())); Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new RemoveGuildFromRoomComposer(guildId).compose()); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if (guild.getRoomId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (guild.getRoomId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) { this.client.sendResponse(new RoomDataComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom(), this.client.getHabbo(), false, false)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java index 04f23190..84bbb3fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java @@ -10,19 +10,15 @@ import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMemberUpdateComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedAdminEvent; -public class GuildRemoveAdminEvent extends MessageHandler -{ +public class GuildRemoveAdminEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { int userId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); @@ -35,8 +31,7 @@ public class GuildRemoveAdminEvent extends MessageHandler if (removedAdminEvent.isCancelled()) return; - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new GuildInfoComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId))); room.refreshRightsForHabbo(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java index 59fa227a..5aaf3e7f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java @@ -6,19 +6,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserProfileComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedFavoriteEvent; -public class GuildRemoveFavoriteEvent extends MessageHandler -{ +public class GuildRemoveFavoriteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); - if(this.client.getHabbo().getHabboStats().hasGuild(guildId)) - { + if (this.client.getHabbo().getHabboStats().hasGuild(guildId)) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); GuildRemovedFavoriteEvent favoriteEvent = new GuildRemovedFavoriteEvent(guild, this.client.getHabbo()); Emulator.getPluginManager().fireEvent(favoriteEvent); - if(favoriteEvent.isCancelled()) + if (favoriteEvent.isCancelled()) return; this.client.getHabbo().getHabboStats().guild = 0; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java index 30deb523..cfcada6c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java @@ -11,22 +11,18 @@ import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent; -public class GuildRemoveMemberEvent extends MessageHandler -{ +public class GuildRemoveMemberEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null) - { + if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(removedMemberEvent); @@ -36,31 +32,26 @@ public class GuildRemoveMemberEvent extends MessageHandler Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); guild.decreaseMemberCount(); - if (userId != this.client.getHabbo().getHabboInfo().getId()) - { + if (userId != this.client.getHabbo().getHabboInfo().getId()) { this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); } Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().removeGuild(guild.getId()); if (habbo.getHabboStats().guild == guildId) habbo.getHabboStats().guild = 0; - if (room != null && habbo.getHabboInfo().getCurrentRoom() == room) - { + if (room != null && habbo.getHabboInfo().getCurrentRoom() == room) { room.refreshRightsForHabbo(habbo); } habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null)); } - if (room != null) - { - if (room.getGuildId() == guildId) - { + if (room != null) { + if (room.getGuildId() == guildId) { room.ejectUserFurni(userId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetAdminEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetAdminEvent.java index 22bc1eec..6c91f4bc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetAdminEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetAdminEvent.java @@ -9,20 +9,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildMemberUpdateComposer; import com.eu.habbo.plugin.events.guilds.GuildGivenAdminEvent; -public class GuildSetAdminEvent extends MessageHandler -{ +public class GuildSetAdminEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null) - { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) - { + if (guild != null) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission("acc_guild_admin")) { Emulator.getGameEnvironment().getGuildManager().setAdmin(guild, userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); @@ -32,13 +28,10 @@ public class GuildSetAdminEvent extends MessageHandler if (adminEvent.isCancelled()) return; - if (habbo != null) - { + if (habbo != null) { Room room = habbo.getHabboInfo().getCurrentRoom(); - if (room != null) - { - if (room.getGuildId() == guildId) - { + if (room != null) { + if (room.getGuildId() == guildId) { room.refreshRightsForHabbo(habbo); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetFavoriteEvent.java index 5eae7935..0837320c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildSetFavoriteEvent.java @@ -8,29 +8,24 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersAddGuildBadgeComposer import com.eu.habbo.messages.outgoing.users.UserProfileComposer; import com.eu.habbo.plugin.events.guilds.GuildFavoriteSetEvent; -public class GuildSetFavoriteEvent extends MessageHandler -{ +public class GuildSetFavoriteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(this.client.getHabbo().getHabboStats().hasGuild(guildId)) - { + if (this.client.getHabbo().getHabboStats().hasGuild(guildId)) { GuildFavoriteSetEvent favoriteSetEvent = new GuildFavoriteSetEvent(guild, this.client.getHabbo()); Emulator.getPluginManager().fireEvent(favoriteSetEvent); - if(favoriteSetEvent.isCancelled()) + if (favoriteSetEvent.isCancelled()) return; this.client.getHabbo().getHabboStats().guild = guildId; - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(guild != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (guild != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUsersAddGuildBadgeComposer(guild).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java index fbdd6c94..b5b31be9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java @@ -13,26 +13,20 @@ import com.eu.habbo.messages.outgoing.guilds.GuildEditFailComposer; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.plugin.events.guilds.GuildPurchasedEvent; -public class RequestGuildBuyEvent extends MessageHandler -{ +public class RequestGuildBuyEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) - { + public void handle() throws Exception { + if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) { int guildPrice = Emulator.getConfig().getInt("catalog.guild.price"); - if (this.client.getHabbo().getHabboInfo().getCredits() >= guildPrice) - { + if (this.client.getHabbo().getHabboInfo().getCredits() >= guildPrice) { this.client.getHabbo().giveCredits(-guildPrice); - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } } - if(Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && this.client.getHabbo().getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) { + if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && this.client.getHabbo().getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) { this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.HC_REQUIRED)); return; } @@ -44,17 +38,14 @@ public class RequestGuildBuyEvent extends MessageHandler Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(r != null) - { - if(r.hasGuild()) { + if (r != null) { + if (r.hasGuild()) { this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.ROOM_ALREADY_IN_USE)); return; } - if(r.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) - { - if (r.getGuildId() == 0) - { + if (r.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { + if (r.getGuildId() == 0) { int colorOne = this.packet.readInt(); int colorTwo = this.packet.readInt(); @@ -64,18 +55,14 @@ public class RequestGuildBuyEvent extends MessageHandler byte base = 1; - while(base < count) - { - int id = this.packet.readInt(); - int color = this.packet.readInt(); - int pos = this.packet.readInt(); + while (base < count) { + int id = this.packet.readInt(); + int color = this.packet.readInt(); + int pos = this.packet.readInt(); - if(base == 1) - { + if (base == 1) { badge += "b"; - } - else - { + } else { badge += "s"; } @@ -88,16 +75,14 @@ public class RequestGuildBuyEvent extends MessageHandler r.setGuild(guild.getId()); r.setNeedsUpdate(true); - - if (Emulator.getConfig().getBoolean("imager.internal.enabled")) - { + + if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { Emulator.getBadgeImager().generate(guild); } - + this.client.sendResponse(new PurchaseOKComposer()); this.client.sendResponse(new GuildBoughtComposer(guild)); - for (Habbo habbo : r.getHabbos()) - { + for (Habbo habbo : r.getHabbos()) { habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null)); } r.refreshGuild(guild); @@ -106,9 +91,7 @@ public class RequestGuildBuyEvent extends MessageHandler Emulator.getGameEnvironment().getGuildManager().addGuild(guild); } - } - else - { + } else { String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName())); ScripterManager.scripterDetected(this.client, message); Emulator.getLogging().logUserLine(message); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyRoomsEvent.java index fe2d0e92..6ca7a4ed 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyRoomsEvent.java @@ -8,18 +8,15 @@ import gnu.trove.set.hash.THashSet; import java.util.List; -public class RequestGuildBuyRoomsEvent extends MessageHandler -{ +public class RequestGuildBuyRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()); THashSet roomList = new THashSet(); - for(Room room : rooms) - { - if(room.getGuildId() == 0) + for (Room room : rooms) { + if (room.getGuildId() == 0) roomList.add(room); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildFurniWidgetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildFurniWidgetEvent.java index f1a6e546..18dc0b94 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildFurniWidgetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildFurniWidgetEvent.java @@ -6,20 +6,17 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildFurniWidgetComposer; -public class RequestGuildFurniWidgetEvent extends MessageHandler -{ +public class RequestGuildFurniWidgetEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); int guildId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(item != null && guild != null) + if (item != null && guild != null) this.client.sendResponse(new GuildFurniWidgetComposer(this.client.getHabbo(), guild, item)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildInfoEvent.java index 61042013..d3a06928 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildInfoEvent.java @@ -5,18 +5,15 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; -public class RequestGuildInfoEvent extends MessageHandler -{ +public class RequestGuildInfoEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); boolean newWindow = this.packet.readBoolean(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild != null) - { + if (guild != null) { this.client.sendResponse(new GuildInfoComposer(guild, this.client, newWindow, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java index c34ef8f8..bb5a5de4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java @@ -8,23 +8,20 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildJoinErrorComposer; -public class RequestGuildJoinEvent extends MessageHandler -{ +public class RequestGuildJoinEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = this.packet.readInt(); - if(this.client.getHabbo().getHabboStats().hasGuild(guildId)) + if (this.client.getHabbo().getHabboStats().hasGuild(guildId)) return; Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null) + if (guild == null) return; - if(guild.getState() == GuildState.CLOSED) - { + if (guild.getState() == GuildState.CLOSED) { this.client.sendResponse(new GuildJoinErrorComposer(GuildJoinErrorComposer.GROUP_CLOSED)); return; } @@ -34,7 +31,7 @@ public class RequestGuildJoinEvent extends MessageHandler Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null || room.getGuildId() != guildId) + if (room == null || room.getGuildId() != guildId) return; room.refreshRightsForHabbo(this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildManageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildManageEvent.java index 2053a601..ccb6ce89 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildManageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildManageEvent.java @@ -5,11 +5,9 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildManageComposer; -public class RequestGuildManageEvent extends MessageHandler -{ +public class RequestGuildManageEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.packet.readInt()); this.client.sendResponse(new GuildManageComposer(guild)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java index b963fb3c..f875d94b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java @@ -7,11 +7,9 @@ import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildMembersComposer; -public class RequestGuildMembersEvent extends MessageHandler -{ +public class RequestGuildMembersEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int groupId = this.packet.readInt(); int pageId = this.packet.readInt(); String query = this.packet.readString(); @@ -19,11 +17,9 @@ public class RequestGuildMembersEvent extends MessageHandler Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(groupId); - if (g != null) - { + if (g != null) { boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin"); - if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) - { + if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); isAdmin = member != null && member.getRank().equals(GuildRank.ADMIN); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildPartsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildPartsEvent.java index 37f79cc2..39340765 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildPartsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildPartsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildPartsComposer; -public class RequestGuildPartsEvent extends MessageHandler -{ +public class RequestGuildPartsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new GuildPartsComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestOwnGuildsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestOwnGuildsEvent.java index 4745c364..1a89d705 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestOwnGuildsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestOwnGuildsEvent.java @@ -6,22 +6,18 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildListComposer; import gnu.trove.set.hash.THashSet; -public class RequestOwnGuildsEvent extends MessageHandler -{ +public class RequestOwnGuildsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { THashSet guilds = new THashSet(); - for(int i : this.client.getHabbo().getHabboStats().guilds) - { - if(i == 0) + for (int i : this.client.getHabbo().getHabboStats().guilds) { + if (i == 0) continue; Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(i); - if (g != null) - { + if (g != null) { guilds.add(g); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java index a8475d73..88fec7ab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java @@ -5,16 +5,14 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; -public class GuildForumDataEvent extends MessageHandler -{ +public class GuildForumDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null) + if (guild == null) return; this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java index e72e2e14..a47a52bc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java @@ -34,7 +34,7 @@ public class GuildForumListEvent extends MessageHandler { break; } - if(guilds != null) { + if (guilds != null) { this.client.sendResponse(new GuildForumListComposer(guilds, this.client.getHabbo(), mode, offset)); } } @@ -46,20 +46,17 @@ public class GuildForumListEvent extends MessageHandler { "FROM `guilds_forums_threads` " + "LEFT JOIN `guilds` ON `guilds`.`id` = `guilds_forums_threads`.`guild_id` " + "GROUP BY `guilds`.`id` " + - "ORDER BY `post_count` DESC LIMIT 100")) - { + "ORDER BY `post_count` DESC LIMIT 100")) { ResultSet set = statement.executeQuery(); - while(set.next()) { + while (set.next()) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(set.getInt("id")); - if(guild != null) { + if (guild != null) { guilds.add(guild); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); this.client.sendResponse(new ConnectionErrorComposer(500)); } @@ -72,21 +69,18 @@ public class GuildForumListEvent extends MessageHandler { 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` " + - "WHERE `guilds_members`.`user_id` = ? AND `guilds`.`forum` = '1'")) - { + "WHERE `guilds_members`.`user_id` = ? AND `guilds`.`forum` = '1'")) { statement.setInt(1, userId); ResultSet set = statement.executeQuery(); - while(set.next()) { + while (set.next()) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(set.getInt("id")); - if(guild != null) { + if (guild != null) { guilds.add(guild); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); this.client.sendResponse(new ConnectionErrorComposer(500)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java index 14e3106c..c156a9af 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java @@ -25,13 +25,13 @@ public class GuildForumModerateMessageEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - if(guild == null || thread == null) { + if (guild == null || thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } ForumThreadComment comment = thread.getCommentById(messageId); - if(comment == null) { + if (comment == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } @@ -39,7 +39,7 @@ public class GuildForumModerateMessageEvent extends MessageHandler { boolean isStaff = this.client.getHabbo().hasPermission("acc_modtool_ticket_q"); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); - if(member == null) { + if (member == null) { this.client.sendResponse(new ConnectionErrorComposer(401)); return; } @@ -51,7 +51,7 @@ public class GuildForumModerateMessageEvent extends MessageHandler { return; } - if(state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { + if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java index 39ed968a..1aaea3d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java @@ -23,7 +23,7 @@ public class GuildForumModerateThreadEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - if(guild == null || thread == null) { + if (guild == null || thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } @@ -31,7 +31,7 @@ public class GuildForumModerateThreadEvent extends MessageHandler { boolean isStaff = this.client.getHabbo().hasPermission("acc_modtool_ticket_q"); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); - if(member == null) { + if (member == null) { this.client.sendResponse(new ConnectionErrorComposer(401)); return; } @@ -43,7 +43,7 @@ public class GuildForumModerateThreadEvent extends MessageHandler { return; } - if(state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { + if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumPostThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumPostThreadEvent.java index 710efe9e..c15f6198 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumPostThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumPostThreadEvent.java @@ -22,7 +22,7 @@ public class GuildForumPostThreadEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null) { + if (guild == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } @@ -38,7 +38,7 @@ public class GuildForumPostThreadEvent extends MessageHandler { ForumThread thread = ForumThread.getById(threadId); - if(threadId == 0) { + 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)) @@ -62,7 +62,7 @@ public class GuildForumPostThreadEvent extends MessageHandler { return; } - if(thread == null) { + if (thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } @@ -79,14 +79,13 @@ public class GuildForumPostThreadEvent extends MessageHandler { ForumThreadComment comment = ForumThreadComment.create(thread, this.client.getHabbo(), message); - if(comment != null) { + if (comment != null) { thread.addComment(comment); thread.setUpdatedAt(Emulator.getIntUnixTimestamp()); this.client.getHabbo().getHabboStats().forumPostsCount += 1; thread.setPostsCount(thread.getPostsCount() + 1); this.client.sendResponse(new GuildForumAddCommentComposer(comment)); - } - else { + } else { this.client.sendResponse(new ConnectionErrorComposer(500)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java index 30e34275..e2004257 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.guilds.GuildMember; import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.habbohotel.guilds.SettingsState; import com.eu.habbo.habbohotel.guilds.forums.ForumThread; -import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.ThreadUpdatedMessageComposer; @@ -23,7 +22,7 @@ public class GuildForumThreadUpdateEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - if(guild == null || thread == null) { + if (guild == null || thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } @@ -31,7 +30,7 @@ public class GuildForumThreadUpdateEvent extends MessageHandler { boolean isStaff = this.client.getHabbo().hasPermission("acc_modtool_ticket_q"); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); - if(member == null) { + if (member == null) { this.client.sendResponse(new ConnectionErrorComposer(401)); return; } @@ -45,7 +44,7 @@ public class GuildForumThreadUpdateEvent extends MessageHandler { this.client.sendResponse(new ThreadUpdatedMessageComposer(guild, thread, this.client.getHabbo(), isPinned, isLocked)); - if(isPinned) { + if (isPinned) { this.client.sendResponse(new GuildForumThreadsComposer(guild, 0)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsEvent.java index b2ac9fd3..a184c7cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsEvent.java @@ -7,17 +7,15 @@ import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; -public class GuildForumThreadsEvent extends MessageHandler -{ +public class GuildForumThreadsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = packet.readInt(); int index = packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null) { + if (guild == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java index a56a33f5..c315fb1a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java @@ -10,11 +10,9 @@ import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumCommentsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; -public class GuildForumThreadsMessagesEvent extends MessageHandler -{ +public class GuildForumThreadsMessagesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = packet.readInt(); int threadId = packet.readInt(); int index = packet.readInt(); // 40 @@ -23,17 +21,14 @@ public class GuildForumThreadsMessagesEvent extends MessageHandler Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - if(guild == null || thread == null) { + if (guild == null || thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } - if ((thread.getState() == ForumThreadState.HIDDEN_BY_ADMIN || thread.getState() == ForumThreadState.HIDDEN_BY_STAFF) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) - { + if ((thread.getState() == ForumThreadState.HIDDEN_BY_ADMIN || thread.getState() == ForumThreadState.HIDDEN_BY_STAFF) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { this.client.sendResponse(new BubbleAlertComposer("oldforums.error.access_denied")); - } - else - { + } else { this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumUpdateSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumUpdateSettingsEvent.java index 8396abe9..e5e65042 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumUpdateSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumUpdateSettingsEvent.java @@ -9,11 +9,9 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; -public class GuildForumUpdateSettingsEvent extends MessageHandler -{ +public class GuildForumUpdateSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int guildId = packet.readInt(); int canRead = packet.readInt(); int postMessages = packet.readInt(); @@ -22,12 +20,12 @@ public class GuildForumUpdateSettingsEvent extends MessageHandler Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if(guild == null) { + if (guild == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } - if(guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { + if (guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/IsFirstLoginOfDayComposer.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/IsFirstLoginOfDayComposer.java index 9e2b4438..33410ab0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/IsFirstLoginOfDayComposer.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/IsFirstLoginOfDayComposer.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; -public class IsFirstLoginOfDayComposer extends MessageComposer -{ +public class IsFirstLoginOfDayComposer extends MessageComposer { private final boolean isFirstLoginOfDay; - public IsFirstLoginOfDayComposer(boolean isFirstLoginOfDay) - { + public IsFirstLoginOfDayComposer(boolean isFirstLoginOfDay) { this.isFirstLoginOfDay = isFirstLoginOfDay; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.IsFirstLoginOfDayComposer); this.response.appendBoolean(this.isFirstLoginOfDay); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/PingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/PingEvent.java index 18878961..b4ff08fd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/PingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/PingEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.PongComposer; -public class PingEvent extends MessageHandler -{ +public class PingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PongComposer(this.packet.readInt())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java index 828a5f20..4dfe71ae 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java @@ -5,8 +5,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class ReleaseVersionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.packet.readString(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/RequestBannerToken.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/RequestBannerToken.java index 7ec6e352..b5c751dc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/RequestBannerToken.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/RequestBannerToken.java @@ -6,8 +6,7 @@ import com.eu.habbo.messages.outgoing.handshake.BannerTokenComposer; public class RequestBannerToken extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new BannerTokenComposer("Stop loggin, Imma ban your ass", false)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 9128bc69..0ee81ead 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -13,7 +13,10 @@ import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameListComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer; -import com.eu.habbo.messages.outgoing.handshake.*; +import com.eu.habbo.messages.outgoing.handshake.DebugConsoleComposer; +import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer; +import com.eu.habbo.messages.outgoing.handshake.SessionRightsComposer; +import com.eu.habbo.messages.outgoing.handshake.SomeConnectionComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryAchievementsComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; @@ -27,74 +30,60 @@ import com.eu.habbo.plugin.events.users.UserLoginEvent; import java.util.ArrayList; -public class SecureLoginEvent extends MessageHandler -{ +public class SecureLoginEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (!this.client.getChannel().isOpen()) - { + public void handle() throws Exception { + if (!this.client.getChannel().isOpen()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - if(!Emulator.isReady) + if (!Emulator.isReady) return; String sso = this.packet.readString().replace(" ", ""); - if (Emulator.getPluginManager().fireEvent(new SSOAuthenticationEvent(sso)).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(new SSOAuthenticationEvent(sso)).isCancelled()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - if (sso.isEmpty()) - { + if (sso.isEmpty()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - if(this.client.getHabbo() == null) - { + if (this.client.getHabbo() == null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso); - if(habbo != null) - { - if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) - { + if (habbo != null) { + if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.client.getChannel())) - { + if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.client.getChannel())) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - try - { + try { habbo.setClient(this.client); this.client.setHabbo(habbo); this.client.getHabbo().connect(); - if (this.client.getHabbo().getHabboInfo() == null) - { + if (this.client.getHabbo().getHabboInfo() == null) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } - if (this.client.getHabbo().getHabboInfo().getRank() == null) - { + if (this.client.getHabbo().getHabboInfo().getRank() == null) { throw new NullPointerException(habbo.getHabboInfo().getUsername() + " has a NON EXISTING RANK!"); } Emulator.getThreading().run(habbo); Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; @@ -124,8 +113,7 @@ public class SecureLoginEvent extends MessageHandler //messages.add(new FriendsComposer(this.client.getHabbo()).compose()); messages.add(new UserClubComposer(this.client.getHabbo()).compose()); - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { messages.add(new ModToolComposer(this.client.getHabbo()).compose()); } @@ -145,19 +133,14 @@ public class SecureLoginEvent extends MessageHandler Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress())); - if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) - { + if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) { final Habbo finalHabbo = habbo; - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - if (Emulator.getConfig().getBoolean("hotel.welcome.alert.oldstyle")) - { + public void run() { + if (Emulator.getConfig().getBoolean("hotel.welcome.alert.oldstyle")) { SecureLoginEvent.this.client.sendResponse(new MessagesForYouComposer(HabboManager.WELCOME_MESSAGE.replace("%username%", finalHabbo.getHabboInfo().getUsername()).replace("%user%", finalHabbo.getHabboInfo().getUsername()).split("
"))); - } else - { + } else { SecureLoginEvent.this.client.sendResponse(new GenericAlertComposer(HabboManager.WELCOME_MESSAGE.replace("%username%", finalHabbo.getHabboInfo().getUsername()).replace("%user%", finalHabbo.getHabboInfo().getUsername()))); } } @@ -165,14 +148,10 @@ public class SecureLoginEvent extends MessageHandler } Messenger.checkFriendSizeProgress(habbo); - } - else - { + } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } - } - else - { + } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java index 3a475f69..a4d85b53 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java @@ -18,24 +18,20 @@ import com.eu.habbo.plugin.events.users.UserLoginEvent; import java.util.ArrayList; -public class SecureLoginEvent_BACKUP extends MessageHandler -{ +public class SecureLoginEvent_BACKUP extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { - if(!Emulator.isReady) + if (!Emulator.isReady) return; String sso = this.packet.readString(); - if(this.client.getHabbo() == null) - { + if (this.client.getHabbo() == null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso); - if(habbo != null) - { + if (habbo != null) { habbo.setClient(this.client); this.client.setHabbo(habbo); this.client.getHabbo().connect(); @@ -46,9 +42,6 @@ public class SecureLoginEvent_BACKUP extends MessageHandler ArrayList messages = new ArrayList<>(); - - - messages.add(new SecureLoginOKComposer().compose()); messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose()); messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose()); @@ -67,8 +60,7 @@ public class SecureLoginEvent_BACKUP extends MessageHandler //messages.add(new MessengerInitComposer(this.client.getHabbo()).compose()); //messages.add(new FriendsComposer(this.client.getHabbo()).compose()); - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { messages.add(new ModToolComposer(this.client.getHabbo()).compose()); } @@ -85,15 +77,9 @@ public class SecureLoginEvent_BACKUP extends MessageHandler //this.client.sendResponse(new UserEffectsListComposer()); - - - - Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress())); - } - else - { + } else { this.client.sendResponse(new GenericAlertComposer("Can't connect *sadpanda*")); this.client.getChannel().close(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java index 7a3692f5..d9940903 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownComposer5 extends MessageComposer -{ +public class UnknownComposer5 extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownComposer5); this.response.appendString(""); //Box color this.response.appendString(""); //Key color 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 index 798e1202..62b4d631 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java @@ -4,9 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; -import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,21 +15,16 @@ import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; -public class UsernameEvent extends MessageHandler -{ +public class UsernameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { boolean calendar = false; - if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login"))) - { + if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login"))) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")); calendar = true; - } - else - { + } else { - long daysBetween = ChronoUnit.DAYS.between(new Date((long)this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); + long daysBetween = ChronoUnit.DAYS.between(new Date((long) this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); Date lastLogin = new Date(this.client.getHabbo().getHabboInfo().getLastOnline()); @@ -39,83 +34,64 @@ public class UsernameEvent extends MessageHandler Calendar c2 = Calendar.getInstance(); c2.setTime(lastLogin); - if (daysBetween == 1) - { - if (this.client.getHabbo().getHabboStats().getAchievementProgress().get(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")) == this.client.getHabbo().getHabboStats().loginStreak) - { + if (daysBetween == 1) { + if (this.client.getHabbo().getHabboStats().getAchievementProgress().get(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")) == this.client.getHabbo().getHabboStats().loginStreak) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")); } this.client.getHabbo().getHabboStats().loginStreak++; calendar = true; - } - else if (daysBetween >= 1) - { + } else if (daysBetween >= 1) { calendar = true; - } - else - { - if (((lastLogin.getTime() / 1000) - Emulator.getIntUnixTimestamp()) > 86400) - { + } else { + if (((lastLogin.getTime() / 1000) - Emulator.getIntUnixTimestamp()) > 86400) { this.client.getHabbo().getHabboStats().loginStreak = 0; } } } - if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"))) - { + if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"))) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"), 0); - } - else - { + } else { int daysRegistered = ((Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboInfo().getAccountCreated()) / 86400); int days = this.client.getHabbo().getHabboStats().getAchievementProgress( Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration") ); - if (daysRegistered - days > 0) - { + if (daysRegistered - days > 0) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"), daysRegistered - days); } } - if(!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("TraderPass"))) - { + if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("TraderPass"))) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("TraderPass")); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement achievementQueueStatement = connection.prepareStatement("SELECT * FROM users_achievements_queue WHERE user_id = ?")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement achievementQueueStatement = connection.prepareStatement("SELECT * FROM users_achievements_queue WHERE user_id = ?")) { achievementQueueStatement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); - try (ResultSet achievementSet = achievementQueueStatement.executeQuery()) - { - while (achievementSet.next()) - { + try (ResultSet achievementSet = achievementQueueStatement.executeQuery()) { + while (achievementSet.next()) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievementSet.getInt("achievement_id")), achievementSet.getInt("amount")); } } - try (PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM users_achievements_queue WHERE user_id = ?")) - { + try (PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM users_achievements_queue WHERE user_id = ?")) { deleteStatement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); deleteStatement.execute(); } } - if (calendar && Emulator.getConfig().getBoolean("hotel.calendar.enabled")) - { - this.client.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int)Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400) , this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); + if (calendar && Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { + this.client.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); this.client.sendResponse(new NuxAlertComposer("openView/calendar")); } - if (TargetOffer.ACTIVE_TARGET_OFFER_ID > 0) - { + if (TargetOffer.ACTIVE_TARGET_OFFER_ID > 0) { TargetOffer offer = Emulator.getGameEnvironment().getCatalogManager().getTargetOffer(TargetOffer.ACTIVE_TARGET_OFFER_ID); - if (offer != null) - { + if (offer != null) { this.client.sendResponse(new TargetedOfferComposer(this.client.getHabbo(), offer)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/helper/RequestTalentTrackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/helper/RequestTalentTrackEvent.java index 05166e0e..6c851948 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/helper/RequestTalentTrackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/helper/RequestTalentTrackEvent.java @@ -5,13 +5,10 @@ import com.eu.habbo.habbohotel.achievements.TalentTrackType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.achievements.talenttrack.TalentTrackComposer; -public class RequestTalentTrackEvent extends MessageHandler -{ +public class RequestTalentTrackEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (Emulator.getConfig().getBoolean("hotel.talenttrack.enabled")) - { + public void handle() throws Exception { + if (Emulator.getConfig().getBoolean("hotel.talenttrack.enabled")) { this.client.sendResponse(new TalentTrackComposer(this.client.getHabbo(), TalentTrackType.valueOf(this.packet.readString().toUpperCase()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewClaimBadgeRewardEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewClaimBadgeRewardEvent.java index 2b60a131..64389be5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewClaimBadgeRewardEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewClaimBadgeRewardEvent.java @@ -6,21 +6,16 @@ import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; -public class HotelViewClaimBadgeRewardEvent extends MessageHandler -{ +public class HotelViewClaimBadgeRewardEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String request = this.packet.readString(); - if (Emulator.getConfig().getBoolean("hotelview.badgereward." + request +".enabled")) - { - String badgeCode = Emulator.getConfig().getValue("hotelview.badgereward." + request +"badge"); + if (Emulator.getConfig().getBoolean("hotelview.badgereward." + request + ".enabled")) { + String badgeCode = Emulator.getConfig().getValue("hotelview.badgereward." + request + "badge"); - if (!badgeCode.isEmpty()) - { - if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(badgeCode)) - { + if (!badgeCode.isEmpty()) { + if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(badgeCode)) { HabboBadge badge = BadgesComponent.createBadge(badgeCode, this.client.getHabbo()); this.client.sendResponse(new AddUserBadgeComposer(badge)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java index f9379899..f6db73b1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java @@ -7,26 +7,18 @@ import com.eu.habbo.messages.outgoing.hotelview.HotelViewDataComposer; public class HotelViewDataEvent extends MessageHandler { @Override - public void handle() - { + public void handle() { - - - try - { + try { String data = this.packet.readString(); - if (data.contains(";")) - { + if (data.contains(";")) { String[] d = data.split(";"); - for (String s : d) - { - if (s.contains(",")) - { + for (String s : d) { + if (s.contains(",")) { this.client.sendResponse(new HotelViewDataComposer(s, s.split(",")[s.split(",").length - 1])); - } else - { + } else { this.client.sendResponse(new HotelViewDataComposer(data, s)); } @@ -34,13 +26,10 @@ public class HotelViewDataEvent extends MessageHandler { } //this.client.sendResponse(new HotelViewDataComposer("2013-05-08 13:0", "gamesmaker")); - } else - { + } else { this.client.sendResponse(new HotelViewDataComposer(data, data.split(",")[data.split(",").length - 1])); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java index 02314c63..a1560542 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java @@ -4,34 +4,26 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class HotelViewEvent extends MessageHandler -{ +public class HotelViewEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.getHabbo().getHabboInfo().setLoadingRoom(0); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); } - if (this.client.getHabbo().getHabboInfo().getRoomQueueId() != 0) - { + if (this.client.getHabbo().getHabboInfo().getRoomQueueId() != 0) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.client.getHabbo().getHabboInfo().getRoomQueueId()); - if (room != null) - { + if (room != null) { room.removeFromQueue(this.client.getHabbo()); - } - else - { + } else { this.client.getHabbo().getHabboInfo().setRoomQueueId(0); } } - if(this.client.getHabbo().getRoomUnit() != null) - { + if (this.client.getHabbo().getRoomUnit() != null) { this.client.getHabbo().getRoomUnit().clearWalking(); this.client.getHabbo().getRoomUnit().setInRoom(false); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBadgeRewardEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBadgeRewardEvent.java index 826ff511..edbefbdf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBadgeRewardEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBadgeRewardEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.HotelViewBadgeButtonConfigComposer; -public class HotelViewRequestBadgeRewardEvent extends MessageHandler -{ +public class HotelViewRequestBadgeRewardEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String badge = this.packet.readString(); this.client.sendResponse(new HotelViewBadgeButtonConfigComposer(Emulator.getConfig().getValue("hotelview.badgereward." + badge + ".badge"), Emulator.getConfig().getBoolean("hotelview.badgereward." + badge + ".enabled"))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBonusRareEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBonusRareEvent.java index 640fcb2d..37c9db1e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBonusRareEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestBonusRareEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.hotelview; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer; -public class HotelViewRequestBonusRareEvent extends MessageHandler -{ +public class HotelViewRequestBonusRareEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new BonusRareComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestLTDAvailabilityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestLTDAvailabilityEvent.java index d0215998..99dc88cc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestLTDAvailabilityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestLTDAvailabilityEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.HotelViewNextLTDAvailableComposer; -public class HotelViewRequestLTDAvailabilityEvent extends MessageHandler -{ +public class HotelViewRequestLTDAvailabilityEvent extends MessageHandler { public static boolean ENABLED = false; public static int TIMESTAMP; public static int ITEM_ID; @@ -13,15 +12,13 @@ public class HotelViewRequestLTDAvailabilityEvent extends MessageHandler public static String ITEM_NAME; @Override - public void handle() throws Exception - { - if (ENABLED) - { + public void handle() throws Exception { + if (ENABLED) { int timeremaining = Math.max(TIMESTAMP - Emulator.getIntUnixTimestamp(), -1); this.client.sendResponse(new HotelViewNextLTDAvailableComposer( timeremaining, - timeremaining > 0 ? - 1 : ITEM_ID, - timeremaining > 0 ? - 1 : PAGE_ID, + timeremaining > 0 ? -1 : ITEM_ID, + timeremaining > 0 ? -1 : PAGE_ID, timeremaining > 0 ? "" : ITEM_NAME)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/RequestNewsListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/RequestNewsListEvent.java index 980bed05..d3928dc2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/RequestNewsListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/RequestNewsListEvent.java @@ -6,11 +6,9 @@ import com.eu.habbo.messages.outgoing.hotelview.HallOfFameComposer; import com.eu.habbo.messages.outgoing.hotelview.HotelViewDataComposer; import com.eu.habbo.messages.outgoing.hotelview.NewsListComposer; -public class RequestNewsListEvent extends MessageHandler -{ +public class RequestNewsListEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new HotelViewDataComposer("2013-05-08 13:0", "gamesmaker")); this.client.sendResponse(new HallOfFameComposer(Emulator.getGameEnvironment().getHotelViewManager().getHallOfFame())); this.client.sendResponse(new NewsListComposer()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBadgesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBadgesEvent.java index f287b0f7..a0d23508 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBadgesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBadgesEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.inventory; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer; -public class RequestInventoryBadgesEvent extends MessageHandler -{ +public class RequestInventoryBadgesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new InventoryBadgesComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBotsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBotsEvent.java index eadb080c..276dd008 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBotsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryBotsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.inventory; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryBotsComposer; -public class RequestInventoryBotsEvent extends MessageHandler -{ +public class RequestInventoryBotsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new InventoryBotsComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java index f3d92194..11b6f3f3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java @@ -10,46 +10,36 @@ import gnu.trove.map.hash.TIntObjectHashMap; import java.util.NoSuchElementException; -public class RequestInventoryItemsEvent extends MessageHandler -{ +public class RequestInventoryItemsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int totalItems = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); int pages = (int) Math.ceil((double) totalItems / 1000.0); - if (pages == 0) - { + if (pages == 0) { pages = 1; } - synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) - { + synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) { TIntObjectMap items = new TIntObjectHashMap<>(); TIntObjectIterator iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator(); int count = 0; int page = 0; - for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) - { - if (count == 0) - { + for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) { + if (count == 0) { page++; } - try - { + try { iterator.advance(); items.put(iterator.key(), iterator.value()); count++; - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { Emulator.getLogging().logErrorLine(e); break; } - if (count == 1000) - { + if (count == 1000) { this.client.sendResponse(new InventoryItemsComposer(page, pages, items)); count = 0; items.clear(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryPetsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryPetsEvent.java index d98a020e..e370acc2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryPetsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryPetsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.inventory; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryPetsComposer; -public class RequestInventoryPetsEvent extends MessageHandler -{ +public class RequestInventoryPetsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new InventoryPetsComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java index 7233c375..09b4ebb3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java @@ -7,20 +7,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; -public class ModToolAlertEvent extends MessageHandler -{ +public class ModToolAlertEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); - if(alertedUser != null) + if (alertedUser != null) Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.ALERT); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.kick").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolChangeRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolChangeRoomSettingsEvent.java index d26915a8..2a325246 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolChangeRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolChangeRoomSettingsEvent.java @@ -6,26 +6,20 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolChangeRoomSettingsEvent extends MessageHandler -{ +public class ModToolChangeRoomSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); - if (room != null) - { + if (room != null) { boolean lockDoor = this.packet.readInt() == 1; boolean changeTitle = this.packet.readInt() == 1; boolean kickUsers = this.packet.readInt() == 1; Emulator.getGameEnvironment().getModToolManager().roomAction(room, this.client.getHabbo(), kickUsers, lockDoor, changeTitle); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.roomsettings").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolCloseTicketEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolCloseTicketEvent.java index b821b712..9326623e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolCloseTicketEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolCloseTicketEvent.java @@ -7,13 +7,10 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolCloseTicketEvent extends MessageHandler -{ +public class ModToolCloseTicketEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int state = this.packet.readInt(); int something = this.packet.readInt(); int ticketId = this.packet.readInt(); @@ -25,8 +22,7 @@ public class ModToolCloseTicketEvent extends MessageHandler Habbo sender = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.senderId); - switch (state) - { + switch (state) { case 1: Emulator.getGameEnvironment().getModToolManager().closeTicketAsUseless(issue, sender); break; @@ -39,9 +35,7 @@ public class ModToolCloseTicketEvent extends MessageHandler Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, sender); break; } - } - else - { + } 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/ModToolIssueChangeTopicEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueChangeTopicEvent.java index 04934a7a..efa0e853 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueChangeTopicEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueChangeTopicEvent.java @@ -6,21 +6,17 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.threading.runnables.UpdateModToolIssue; -public class ModToolIssueChangeTopicEvent extends MessageHandler -{ +public class ModToolIssueChangeTopicEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int ticketId = this.packet.readInt(); int unknownInt = this.packet.readInt(); int categoryId = this.packet.readInt(); ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId); - if (issue != null) - { + if (issue != null) { issue.category = categoryId; new UpdateModToolIssue(issue).run(); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java index de0f1109..bea0a0ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java @@ -6,40 +6,30 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolIssueDefaultSanctionEvent extends MessageHandler -{ +public class ModToolIssueDefaultSanctionEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int issueId = this.packet.readInt(); int unknown = this.packet.readInt(); int category = this.packet.readInt(); ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(issueId); - if (issue.modId == this.client.getHabbo().getHabboInfo().getId()) - { + if (issue.modId == this.client.getHabbo().getHabboInfo().getId()) { CfhTopic modToolCategory = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(category); - if (modToolCategory != null) - { + if (modToolCategory != null) { ModToolPreset defaultSanction = modToolCategory.defaultSanction; - if (defaultSanction != null) - { + if (defaultSanction != null) { Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId); - if (defaultSanction.banLength > 0) - { + 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) - { + } else if (defaultSanction.muteLength > 0) { - if (target != null) - { + if (target != null) { target.mute(defaultSanction.muteLength * 86400); } } @@ -48,9 +38,7 @@ public class ModToolIssueDefaultSanctionEvent extends MessageHandler issue.state = ModToolTicketState.CLOSED; Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); - } - else - { + } else { this.client.getHabbo().alert(Emulator.getTexts().getValue("supporttools.not_ticket_owner")); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolKickEvent.java index 193250bc..3e1e234e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolKickEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolKickEvent extends MessageHandler -{ +public class ModToolKickEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Emulator.getGameEnvironment().getModToolManager().kick(this.client.getHabbo(), Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()), this.packet.readString()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolPickTicketEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolPickTicketEvent.java index 44f75d01..172ad656 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolPickTicketEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolPickTicketEvent.java @@ -6,24 +6,19 @@ import com.eu.habbo.habbohotel.modtool.ModToolTicketState; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueInfoComposer; -public class ModToolPickTicketEvent extends MessageHandler -{ +public class ModToolPickTicketEvent extends MessageHandler { public static boolean send = false; + @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { this.packet.readInt(); ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt()); - if(issue != null) - { - if(issue.state == ModToolTicketState.PICKED) - { + if (issue != null) { + if (issue.state == ModToolTicketState.PICKED) { this.client.sendResponse(new ModToolIssueInfoComposer(issue)); this.client.getHabbo().alert(Emulator.getTexts().getValue("support.ticket.picked.failed")); @@ -32,14 +27,10 @@ public class ModToolPickTicketEvent extends MessageHandler //this.client.sendResponse(new ModToolIssueInfoComposer(issue)); Emulator.getGameEnvironment().getModToolManager().pickTicket(issue, this.client.getHabbo()); - } - else - { + } else { this.client.getHabbo().alert(Emulator.getTexts().getValue("support.ticket.picked.failed")); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ticket.pick").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolReleaseTicketEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolReleaseTicketEvent.java index cd1ab13b..e0a155d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolReleaseTicketEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolReleaseTicketEvent.java @@ -7,17 +7,13 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolReleaseTicketEvent extends MessageHandler -{ +public class ModToolReleaseTicketEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int count = this.packet.readInt(); - while (count != 0) - { + while (count != 0) { count--; int ticketId = this.packet.readInt(); @@ -36,9 +32,7 @@ public class ModToolReleaseTicketEvent extends MessageHandler Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ticket.release").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java index 829778b5..2b4b31f0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java @@ -12,30 +12,21 @@ import com.eu.habbo.messages.outgoing.modtool.ModToolIssueChatlogComposer; import java.util.ArrayList; -public class ModToolRequestIssueChatlogEvent extends MessageHandler -{ +public class ModToolRequestIssueChatlogEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt()); - if(issue != null) - { + if (issue != null) { ArrayList chatlog; - if (issue.type == ModToolTicketType.IM) - { + if (issue.type == ModToolTicketType.IM) { chatlog = Emulator.getGameEnvironment().getModToolManager().getMessengerChatlog(issue.reportedId, issue.senderId); - } - else - { - if (issue.roomId > 0) - { + } else { + if (issue.roomId > 0) { chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId); - } else - { + } else { chatlog = new ArrayList<>(); chatlog.addAll(Emulator.getGameEnvironment().getModToolManager().getUserChatlog(issue.reportedId)); chatlog.addAll(Emulator.getGameEnvironment().getModToolManager().getUserChatlog(issue.senderId)); @@ -45,15 +36,12 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(issue.roomId); String roomName = ""; - if(room != null) - { + if (room != null) { roomName = room.getName(); } this.client.sendResponse(new ModToolIssueChatlogComposer(issue, chatlog, roomName)); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomChatlogEvent.java index 27fb04c4..5f58f50e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomChatlogEvent.java @@ -7,21 +7,16 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolRoomChatlogComposer; -public class ModToolRequestRoomChatlogEvent extends MessageHandler -{ +public class ModToolRequestRoomChatlogEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); - if(room != null) + if (room != null) this.client.sendResponse(new ModToolRoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getId()))); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java index bc2a04ad..3aff8583 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java @@ -7,25 +7,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolRoomInfoComposer; -public class ModToolRequestRoomInfoEvent extends MessageHandler -{ +public class ModToolRequestRoomInfoEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { //int roomId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); //Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if (room != null) - { + if (room != null) { this.client.sendResponse(new ModToolRoomInfoComposer(room)); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.roominfo").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java index 233425b2..6fec0a90 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java @@ -8,29 +8,22 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolRoomChatlogComposer; -public class ModToolRequestRoomUserChatlogEvent extends MessageHandler -{ +public class ModToolRequestRoomUserChatlogEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if(habbo != null) - { + if (habbo != null) { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { this.client.sendResponse(new ModToolRoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getId()))); } } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java index 354b4ce5..2725aa50 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java @@ -6,18 +6,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolUserRoomVisitsComposer; -public class ModToolRequestRoomVisitsEvent extends MessageHandler -{ +public class ModToolRequestRoomVisitsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if(habbo != null) + if (habbo != null) this.client.sendResponse(new ModToolUserRoomVisitsComposer(habbo, Emulator.getGameEnvironment().getModToolManager().requestUserRoomVisits(habbo))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserChatlogEvent.java index 3a9b18b3..ad55465e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserChatlogEvent.java @@ -7,20 +7,15 @@ import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolUserChatlogComposer; -public class ModToolRequestUserChatlogEvent extends MessageHandler -{ +public class ModToolRequestUserChatlogEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); String username = HabboManager.getOfflineHabboInfo(userId).getUsername(); this.client.sendResponse(new ModToolUserChatlogComposer(Emulator.getGameEnvironment().getModToolManager().getUserRoomVisitsAndChatlogs(userId), userId, username)); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserInfoEvent.java index 9249e1b3..25f68402 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestUserInfoEvent.java @@ -6,17 +6,12 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolRequestUserInfoEvent extends MessageHandler -{ +public class ModToolRequestUserInfoEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { ModToolManager.requestUserInfo(this.client, this.packet); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.userinfo").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRoomAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRoomAlertEvent.java index 8e81d681..8631a3e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRoomAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRoomAlertEvent.java @@ -6,23 +6,17 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolRoomAlertEvent extends MessageHandler -{ +public class ModToolRoomAlertEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int type = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { room.alert(this.packet.readString()); } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.roomalert").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } 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 index 7804fd1f..26cfbda9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java @@ -6,25 +6,19 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; -public class ModToolSanctionAlertEvent extends MessageHandler -{ +public class ModToolSanctionAlertEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.alert(message); - } - else - { + } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java index 04e03871..f317c8d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java @@ -6,8 +6,7 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; -public class ModToolSanctionBanEvent extends MessageHandler -{ +public class ModToolSanctionBanEvent extends MessageHandler { public static final int BAN_18_HOURS = 3; public static final int BAN_7_DAYS = 4; public static final int BAN_30_DAYS_STEP_1 = 5; @@ -18,8 +17,7 @@ public class ModToolSanctionBanEvent extends MessageHandler public final int DAY_IN_SECONDS = 24 * 60 * 60; @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); @@ -28,23 +26,24 @@ public class ModToolSanctionBanEvent extends MessageHandler int duration = 0; - switch (banType) - { - case BAN_18_HOURS: duration = 18 * 60 * 60; break; - case BAN_7_DAYS: duration = 7 * this.DAY_IN_SECONDS; break; + switch (banType) { + case BAN_18_HOURS: + duration = 18 * 60 * 60; + break; + case BAN_7_DAYS: + duration = 7 * this.DAY_IN_SECONDS; + break; case BAN_30_DAYS_STEP_1: case BAN_30_DAYS_STEP_2: - duration = 30 * this.DAY_IN_SECONDS; break; + duration = 30 * this.DAY_IN_SECONDS; + break; case BAN_100_YEARS: case BAN_AVATAR_ONLY_100_YEARS: duration = Emulator.getIntUnixTimestamp(); } - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } 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 index e7e706fb..f5664f93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -6,27 +6,21 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; -public class ModToolSanctionMuteEvent extends MessageHandler -{ +public class ModToolSanctionMuteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.mute(60 * 60); habbo.alert(message); this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername())); - } - else - { + } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java index a7b0caa5..ed8ad7af 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java @@ -6,27 +6,21 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; -public class ModToolSanctionTradeLockEvent extends MessageHandler -{ +public class ModToolSanctionTradeLockEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); String message = this.packet.readString(); int duration = this.packet.readInt(); int cfhTopic = this.packet.readInt(); - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().setAllowTrade(false); habbo.alert(message); - } - else - { + } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java index 06acd1db..e5f0b102 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java @@ -7,20 +7,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; -public class ModToolWarnEvent extends MessageHandler -{ +public class ModToolWarnEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); - if(alertedUser != null) + if (alertedUser != null) Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.CAUTION); - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.kick").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportBullyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportBullyEvent.java index dd9b0e90..f2207f2c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportBullyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportBullyEvent.java @@ -11,13 +11,10 @@ import com.eu.habbo.messages.outgoing.modtool.HelperRequestDisabledComposer; import java.util.ArrayList; -public class ReportBullyEvent extends MessageHandler -{ +public class ReportBullyEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboStats().allowTalk()) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboStats().allowTalk()) { this.client.sendResponse(new HelperRequestDisabledComposer()); return; } @@ -25,31 +22,26 @@ public class ReportBullyEvent extends MessageHandler int userId = this.packet.readInt(); int roomId = this.packet.readInt(); - if(userId == this.client.getHabbo().getHabboInfo().getId()) - { + if (userId == this.client.getHabbo().getHabboInfo().getId()) { return; } Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { + if (room != null) { Habbo habbo = room.getHabbo(userId); - if(habbo != null) - { + if (habbo != null) { GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getOpenReportedHabboTicket(habbo); - if(ticket != null) - { + if (ticket != null) { this.client.sendResponse(new BullyReportedMessageComposer(BullyReportedMessageComposer.ALREADY_REPORTED)); return; } ArrayList chatLog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(roomId); - if(chatLog.isEmpty()) - { + if (chatLog.isEmpty()) { this.client.sendResponse(new BullyReportedMessageComposer(BullyReportedMessageComposer.NO_CHAT)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportEvent.java index ea23ebc6..79fc8faa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportEvent.java @@ -13,13 +13,10 @@ import com.eu.habbo.threading.runnables.InsertModToolIssue; import java.util.ArrayList; import java.util.List; -public class ReportEvent extends MessageHandler -{ +public class ReportEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(!this.client.getHabbo().getHabboStats().allowTalk()) - { + public void handle() throws Exception { + if (!this.client.getHabbo().getHabboStats().allowTalk()) { this.client.sendResponse(new HelperRequestDisabledComposer()); return; } @@ -32,8 +29,7 @@ public class ReportEvent extends MessageHandler Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); List issues = Emulator.getGameEnvironment().getModToolManager().openTicketsForHabbo(this.client.getHabbo()); - if(!issues.isEmpty()) - { + if (!issues.isEmpty()) { //this.client.sendResponse(new GenericAlertComposer("You've got still a pending ticket. Wait till the moderators are done reviewing your ticket.")); this.client.sendResponse(new ReportRoomFormComposer(issues)); return; @@ -41,26 +37,21 @@ public class ReportEvent extends MessageHandler CfhTopic cfhTopic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topic); - if(userId != -1) - { + if (userId != -1) { Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if(reported != null) - { - if (cfhTopic != null && cfhTopic.action == CfhActionType.GUARDIANS && Emulator.getGameEnvironment().getGuideManager().activeGuardians()) - { + if (reported != null) { + if (cfhTopic != null && cfhTopic.action == CfhActionType.GUARDIANS && Emulator.getGameEnvironment().getGuideManager().activeGuardians()) { GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getOpenReportedHabboTicket(reported); - if(ticket != null) - { + if (ticket != null) { this.client.sendResponse(new BullyReportedMessageComposer(BullyReportedMessageComposer.ALREADY_REPORTED)); return; } ArrayList chatLog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(roomId); - if(chatLog.isEmpty()) - { + if (chatLog.isEmpty()) { this.client.sendResponse(new BullyReportedMessageComposer(BullyReportedMessageComposer.NO_CHAT)); return; } @@ -68,9 +59,7 @@ public class ReportEvent extends MessageHandler Emulator.getGameEnvironment().getGuideManager().addGuardianTicket(new GuardianTicket(this.client.getHabbo(), reported, chatLog)); this.client.sendResponse(new BullyReportedMessageComposer(BullyReportedMessageComposer.RECEIVED)); - } - else - { + } else { ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), reported.getHabboInfo().getId(), reported.getHabboInfo().getUsername(), roomId, message, ModToolTicketType.NORMAL); issue.category = topic; new InsertModToolIssue(issue).run(); @@ -79,19 +68,13 @@ public class ReportEvent extends MessageHandler Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, cfhTopic.reply)); - if (cfhTopic != null) - { - if (cfhTopic.action != CfhActionType.MODS) - { - Emulator.getThreading().run(new Runnable() - { + if (cfhTopic != null) { + if (cfhTopic.action != CfhActionType.MODS) { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - if (issue.state == ModToolTicketState.OPEN) - { - if (cfhTopic.action == CfhActionType.AUTO_IGNORE) - { + public void run() { + if (issue.state == ModToolTicketState.OPEN) { + if (cfhTopic.action == CfhActionType.AUTO_IGNORE) { ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(reported.getHabboInfo().getId()); ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED)); } @@ -105,9 +88,7 @@ public class ReportEvent extends MessageHandler } } } - } - else - { + } else { ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), room != null ? room.getOwnerId() : 0, room != null ? room.getOwnerName() : "", roomId, message, ModToolTicketType.ROOM); issue.category = topic; new InsertModToolIssue(issue).run(); @@ -116,23 +97,16 @@ public class ReportEvent extends MessageHandler Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); - if(cfhTopic != null) - { - if(cfhTopic.action != CfhActionType.MODS) - { - Emulator.getThreading().run(new Runnable() - { + if (cfhTopic != null) { + if (cfhTopic.action != CfhActionType.MODS) { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { - if(issue.state == ModToolTicketState.OPEN) - { - if(cfhTopic.action == CfhActionType.AUTO_IGNORE) - { + public void run() { + if (issue.state == ModToolTicketState.OPEN) { + if (cfhTopic.action == CfhActionType.AUTO_IGNORE) { ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(issue.reportedId); Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId); - if (reported != null) - { + if (reported != null) { ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportFriendPrivateChatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportFriendPrivateChatEvent.java index 797d7d65..81d83c8c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportFriendPrivateChatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportFriendPrivateChatEvent.java @@ -13,13 +13,10 @@ import com.eu.habbo.threading.runnables.InsertModToolIssue; import java.util.ArrayList; -public class ReportFriendPrivateChatEvent extends MessageHandler -{ +public class ReportFriendPrivateChatEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(!this.client.getHabbo().getHabboStats().allowTalk()) - { + public void handle() throws Exception { + if (!this.client.getHabbo().getHabboStats().allowTalk()) { this.client.sendResponse(new HelperRequestDisabledComposer()); return; } @@ -32,19 +29,14 @@ public class ReportFriendPrivateChatEvent extends MessageHandler HabboInfo info; Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (target != null) - { + if (target != null) { info = target.getHabboInfo(); - } - else - { + } else { info = HabboManager.getOfflineHabboInfo(userId); } - if (info != null) - { - for (int i = 0; i < count; i++) - { + if (info != null) { + for (int i = 0; i < count; i++) { int chatUserId = this.packet.readInt(); String username = this.packet.readInt() == info.getId() ? info.getUsername() : this.client.getHabbo().getHabboInfo().getUsername(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportRoomEvent.java index 290c27e5..0dc7800b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportRoomEvent.java @@ -4,13 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ReportRoomFormComposer; -import java.util.ArrayList; - -public class RequestReportRoomEvent extends MessageHandler -{ +public class RequestReportRoomEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new ReportRoomFormComposer(Emulator.getGameEnvironment().getModToolManager().openTicketsForHabbo(this.client.getHabbo()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportUserBullyingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportUserBullyingEvent.java index 49c5e6ac..e8c88756 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportUserBullyingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/RequestReportUserBullyingEvent.java @@ -7,23 +7,18 @@ import com.eu.habbo.messages.outgoing.modtool.BullyReportRequestComposer; import java.util.Calendar; -public class RequestReportUserBullyingEvent extends MessageHandler -{ +public class RequestReportUserBullyingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getRecentTicket(this.client.getHabbo()); - if(ticket != null) - { - if(ticket.inProgress()) - { + if (ticket != null) { + if (ticket.inProgress()) { this.client.sendResponse(new BullyReportRequestComposer(BullyReportRequestComposer.ONGOING_HELPER_CASE, 1)); return; } - if((Calendar.getInstance().getTime().getTime() / 1000) - ticket.getDate().getTime() < Emulator.getConfig().getInt("guardians.reporting.cooldown")) - { + if ((Calendar.getInstance().getTime().getTime() / 1000) - ticket.getDate().getTime() < Emulator.getConfig().getInt("guardians.reporting.cooldown")) { this.client.sendResponse(new BullyReportRequestComposer(BullyReportRequestComposer.TOO_RECENT, 1)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/StartSafetyQuizEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/StartSafetyQuizEvent.java index b64f564a..572dfdcd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/StartSafetyQuizEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/StartSafetyQuizEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.messages.incoming.MessageHandler; -public class StartSafetyQuizEvent extends MessageHandler -{ +public class StartSafetyQuizEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String quizName = this.packet.readString(); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SafetyQuizGraduate")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCategoryListModeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCategoryListModeEvent.java index 7805a7c0..3b3e6c4a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCategoryListModeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCategoryListModeEvent.java @@ -5,11 +5,9 @@ import com.eu.habbo.habbohotel.navigation.ListMode; import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.messages.incoming.MessageHandler; -public class NavigatorCategoryListModeEvent extends MessageHandler -{ +public class NavigatorCategoryListModeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String category = this.packet.readString(); int viewMode = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCollapseCategoryEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCollapseCategoryEvent.java index b566726e..549c2786 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCollapseCategoryEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorCollapseCategoryEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.habbohotel.navigation.DisplayMode; import com.eu.habbo.messages.incoming.MessageHandler; -public class NavigatorCollapseCategoryEvent extends MessageHandler -{ +public class NavigatorCollapseCategoryEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String category = this.packet.readString(); this.client.getHabbo().getHabboStats().navigatorWindowSettings.setDisplayMode(category, DisplayMode.COLLAPSED); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorUncollapseCategoryEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorUncollapseCategoryEvent.java index 45e6cc56..2a2eb7c1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorUncollapseCategoryEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NavigatorUncollapseCategoryEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.habbohotel.navigation.DisplayMode; import com.eu.habbo.messages.incoming.MessageHandler; -public class NavigatorUncollapseCategoryEvent extends MessageHandler -{ +public class NavigatorUncollapseCategoryEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String category = this.packet.readString(); this.client.getHabbo().getHabboStats().navigatorWindowSettings.setDisplayMode(category, DisplayMode.VISIBLE); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorActionEvent.java index 6a857ab6..4febfc1e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorActionEvent.java @@ -9,28 +9,20 @@ import com.eu.habbo.messages.outgoing.users.UserHomeRoomComposer; import java.util.ArrayList; import java.util.Collections; -public class NewNavigatorActionEvent extends MessageHandler -{ +public class NewNavigatorActionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String data = this.packet.readString(); - if(data.equals("random_friending_room")) - { + if (data.equals("random_friending_room")) { ArrayList rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(); - if(!rooms.isEmpty()) - { + if (!rooms.isEmpty()) { Collections.shuffle(rooms); this.client.sendResponse(new ForwardToRoomComposer(rooms.get(0).getId())); } - } - else if (data.equalsIgnoreCase("predefined_noob_lobby")) - { + } else if (data.equalsIgnoreCase("predefined_noob_lobby")) { this.client.sendResponse(new ForwardToRoomComposer(Emulator.getConfig().getInt("hotel.room.nooblobby"))); - } - else - { + } else { this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java index d682beee..ef0b56df 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java @@ -5,11 +5,9 @@ import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; -public class RequestCanCreateRoomEvent extends MessageHandler -{ +public class RequestCanCreateRoomEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_VIP : RoomManager.MAXIMUM_ROOMS_USER; this.client.sendResponse(new CanCreateRoomComposer(count, max)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java index 9ea5897d..222063b5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java @@ -11,8 +11,7 @@ import com.eu.habbo.messages.outgoing.navigator.RoomCreatedComposer; public class RequestCreateRoomEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String name = this.packet.readString(); String description = this.packet.readString(); String modelName = this.packet.readString(); @@ -20,41 +19,36 @@ public class RequestCreateRoomEvent extends MessageHandler { int maxUsers = this.packet.readInt(); int tradeType = this.packet.readInt(); - if(!Emulator.getGameEnvironment().getRoomManager().layoutExists(modelName)) - { - Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect layout name \""+modelName+"\". " + this.client.getHabbo().getHabboInfo().getUsername()); + if (!Emulator.getGameEnvironment().getRoomManager().layoutExists(modelName)) { + Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect layout name \"" + modelName + "\". " + this.client.getHabbo().getHabboInfo().getUsername()); return; } RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId); - if(category == null || category.getMinRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) - { - Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect rank or non existing category ID: \""+categoryId+"\"." + this.client.getHabbo().getHabboInfo().getUsername()); + if (category == null || category.getMinRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) { + Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect rank or non existing category ID: \"" + categoryId + "\"." + this.client.getHabbo().getHabboInfo().getUsername()); return; } - if(maxUsers > 250) + if (maxUsers > 250) return; - if(tradeType > 2) + if (tradeType > 2) return; int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_VIP : RoomManager.MAXIMUM_ROOMS_USER; - - if(count >= max) - { + + if (count >= max) { this.client.sendResponse(new CanCreateRoomComposer(count, max)); return; } final Room room = Emulator.getGameEnvironment().getRoomManager().createRoomForHabbo(this.client.getHabbo(), name, description, modelName, maxUsers, categoryId); - if(room != null) - { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (room != null) { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { //Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java index 00438bbc..ffd2565a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java @@ -11,33 +11,26 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class RequestDeleteRoomEvent extends MessageHandler -{ +public class RequestDeleteRoomEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { - if (room.isOwner(this.client.getHabbo())) - { - if(Emulator.getPluginManager().fireEvent(new NavigatorRoomDeletedEvent(this.client.getHabbo(), room)).isCancelled()) - { + if (room != null) { + if (room.isOwner(this.client.getHabbo())) { + if (Emulator.getPluginManager().fireEvent(new NavigatorRoomDeletedEvent(this.client.getHabbo(), room)).isCancelled()) { return; } room.ejectAll(); room.ejectUserFurni(room.getOwnerId()); - if(room.getGuildId() > 0) - { + if (room.getGuildId() > 0) { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()); - if(guild != null) - { + if (guild != null) { Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); } } @@ -46,18 +39,14 @@ public class RequestDeleteRoomEvent extends MessageHandler room.dispose(); Emulator.getGameEnvironment().getRoomManager().uncacheRoom(room); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("DELETE FROM rooms WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("DELETE FROM rooms WHERE id = ? LIMIT 1")) { statement.setInt(1, roomId); statement.execute(); } - if (room.hasCustomLayout()) - { - try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_models_custom WHERE id = ? LIMIT 1")) - { + if (room.hasCustomLayout()) { + try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_models_custom WHERE id = ? LIMIT 1")) { stmt.setInt(1, roomId); stmt.execute(); } @@ -65,31 +54,24 @@ public class RequestDeleteRoomEvent extends MessageHandler Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); - try (PreparedStatement rights = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) - { + try (PreparedStatement rights = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { rights.setInt(1, roomId); rights.execute(); } - try (PreparedStatement votes = connection.prepareStatement("DELETE FROM room_votes WHERE room_id = ?")) - { + try (PreparedStatement votes = connection.prepareStatement("DELETE FROM room_votes WHERE room_id = ?")) { votes.setInt(1, roomId); votes.execute(); } - try (PreparedStatement filter = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ?")) - { + try (PreparedStatement filter = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ?")) { filter.setInt(1, roomId); filter.execute(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } - else - { + } else { String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getName()).replace("%roomowner%", room.getOwnerName()); ScripterManager.scripterDetected(this.client, message); Emulator.getLogging().logUserLine(message); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestHighestScoreRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestHighestScoreRoomsEvent.java index 39f90aac..d74a8ae3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestHighestScoreRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestHighestScoreRoomsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class RequestHighestScoreRoomsEvent extends MessageHandler -{ +public class RequestHighestScoreRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsByScore())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestMyRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestMyRoomsEvent.java index dc3a359a..93476147 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestMyRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestMyRoomsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class RequestMyRoomsEvent extends MessageHandler -{ +public class RequestMyRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()))); } } 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 index a2c3dbe4..0369a07d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNavigatorSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNavigatorSettingsEvent.java @@ -3,14 +3,9 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSettingsComposer; -public class RequestNavigatorSettingsEvent extends MessageHandler -{ +public class RequestNavigatorSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - - - + public void handle() throws Exception { this.client.sendResponse(new NewNavigatorSettingsComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); 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 index dab87f4c..fd9a1b09 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.*; -public class RequestNewNavigatorDataEvent extends MessageHandler -{ +public class RequestNewNavigatorDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new NewNavigatorSettingsComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); this.client.sendResponse(new NewNavigatorMetaDataComposer()); this.client.sendResponse(new NewNavigatorLiftedRoomsComposer()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 9709bfe0..93c5e7c5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -11,11 +11,9 @@ import gnu.trove.map.hash.THashMap; import java.util.*; -public class RequestNewNavigatorRoomsEvent extends MessageHandler -{ +public class RequestNewNavigatorRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String view = this.packet.readString(); String query = this.packet.readString(); @@ -25,41 +23,34 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler String filterField = "anything"; String part = query; NavigatorFilterField field = Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField); - if (filter != null) - { - if (query.contains(":")) - { + if (filter != null) { + if (query.contains(":")) { String[] parts = query.split(":"); - if (parts.length > 1) - { + if (parts.length > 1) { filterField = parts[0]; part = parts[1]; - } else - { + } else { filterField = parts[0].replace(":", ""); - if (!Emulator.getGameEnvironment().getNavigatorManager().filterSettings.containsKey(filterField)) - { + if (!Emulator.getGameEnvironment().getNavigatorManager().filterSettings.containsKey(filterField)) { filterField = "anything"; } } } - if (Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField) != null) - { + if (Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField) != null) { field = Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField); } } - if (field == null || query.isEmpty()) - { + if (field == null || query.isEmpty()) { if (filter == null) return; List resultLists = filter.getResult(this.client.getHabbo()); Collections.sort(resultLists); - if(!query.isEmpty()) { + if (!query.isEmpty()) { resultLists = toQueryResults(resultLists); } @@ -67,23 +58,19 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler return; } - if (filter == null && category != null) - { + if (filter == null && category != null) { filter = Emulator.getGameEnvironment().getNavigatorManager().filters.get("hotel_view"); } if (filter == null) return; - try - { + try { List resultLists = new ArrayList<>(filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1)); filter.filter(field.field, part, resultLists); resultLists = toQueryResults(resultLists); this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists)); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -108,10 +95,8 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler ArrayList nList = new ArrayList<>(); THashMap searchRooms = new THashMap<>(); - for(SearchResultList li : resultLists) - { - for(Room room : li.rooms) - { + for (SearchResultList li : resultLists) { + for (Room room : li.rooms) { searchRooms.put(room.getId(), room); } } @@ -121,44 +106,34 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler return nList; } - private void filter(List resultLists, NavigatorFilter filter, String part) - { + 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) - { + 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)) - { + if (!filteredRooms.containsKey(result.order)) { filteredRooms.put(result.order, new HashMap<>()); } - for (Room room : rooms) - { + 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) - { + 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()) - { + if (resultList.rooms.isEmpty()) { toRemove.add(resultList); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPopularRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPopularRoomsEvent.java index f3745766..b0e0d10f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPopularRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPopularRoomsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class RequestPopularRoomsEvent extends MessageHandler -{ +public class RequestPopularRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getActiveRooms(-1))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPromotedRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPromotedRoomsEvent.java index 8d4ee3ee..5f89e603 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPromotedRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestPromotedRoomsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class RequestPromotedRoomsEvent extends MessageHandler -{ +public class RequestPromotedRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsPromoted())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestRoomCategoriesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestRoomCategoriesEvent.java index fd82cb99..94b644f1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestRoomCategoriesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestRoomCategoriesEvent.java @@ -7,11 +7,9 @@ import com.eu.habbo.messages.outgoing.navigator.RoomCategoriesComposer; import java.util.List; -public class RequestRoomCategoriesEvent extends MessageHandler -{ +public class RequestRoomCategoriesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { List roomCategoryList = Emulator.getGameEnvironment().getRoomManager().roomCategoriesForHabbo(this.client.getHabbo()); this.client.sendResponse(new RoomCategoriesComposer(roomCategoryList)); //this.client.sendResponse(new NewNavigatorEventCategoriesComposer()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestTagsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestTagsEvent.java index 29d3fdaa..87e538de 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestTagsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestTagsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.TagsComposer; -public class RequestTagsEvent extends MessageHandler -{ +public class RequestTagsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new TagsComposer(Emulator.getGameEnvironment().getRoomManager().getTags())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SaveWindowSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SaveWindowSettingsEvent.java index 8cff4916..c5134207 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SaveWindowSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SaveWindowSettingsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.habbohotel.users.HabboNavigatorWindowSettings; import com.eu.habbo.messages.incoming.MessageHandler; -public class SaveWindowSettingsEvent extends MessageHandler -{ +public class SaveWindowSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { HabboNavigatorWindowSettings windowSettings = this.client.getHabbo().getHabboStats().navigatorWindowSettings; windowSettings.x = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsByTagEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsByTagEvent.java index 6812a143..0d572edf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsByTagEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsByTagEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsByTagEvent extends MessageHandler -{ +public class SearchRoomsByTagEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String tag = this.packet.readString(); this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsWithTag(tag))); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsEvent.java index 0239e544..7c910c50 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsEvent.java @@ -11,13 +11,11 @@ import gnu.trove.map.hash.THashMap; import java.util.ArrayList; -public class SearchRoomsEvent extends MessageHandler -{ +public class SearchRoomsEvent extends MessageHandler { public final static THashMap> cachedResults = new THashMap<>(4); @Override - public void handle() throws Exception - { + public void handle() throws Exception { String name = this.packet.readString(); String prefix = ""; @@ -25,45 +23,33 @@ public class SearchRoomsEvent extends MessageHandler ArrayList rooms; ServerMessage message = null; - if (cachedResults.containsKey(this.client.getHabbo().getHabboInfo().getRank())) - { + if (cachedResults.containsKey(this.client.getHabbo().getHabboInfo().getRank())) { message = cachedResults.get(this.client.getHabbo().getHabboInfo().getRank()).get((name + "\t" + query).toLowerCase()); - } - else - { + } else { cachedResults.put(this.client.getHabbo().getHabboInfo().getRank(), new THashMap<>()); } - if (message == null) - { - if (name.startsWith("owner:")) - { + if (message == null) { + if (name.startsWith("owner:")) { query = name.split("owner:")[1]; prefix = "owner:"; rooms = (ArrayList) Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(name); - } - else if (name.startsWith("tag:")) - { + } else if (name.startsWith("tag:")) { query = name.split("tag:")[1]; prefix = "tag:"; rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithTag(name); - } - else if (name.startsWith("group:")) - { + } else if (name.startsWith("group:")) { query = name.split("group:")[1]; prefix = "group:"; rooms = Emulator.getGameEnvironment().getRoomManager().getGroupRoomsWithName(name); - } - else - { + } else { rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithName(name); } message = new PrivateRoomsComposer(rooms).compose(); THashMap map = cachedResults.get(this.client.getHabbo().getHabboInfo().getRank()); - if (map == null) - { + if (map == null) { map = new THashMap<>(1); } @@ -71,8 +57,7 @@ public class SearchRoomsEvent extends MessageHandler cachedResults.put(this.client.getHabbo().getHabboInfo().getRank(), map); NavigatorSearchResultEvent event = new NavigatorSearchResultEvent(this.client.getHabbo(), prefix, query, rooms); - if(Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsNowEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsNowEvent.java index 85be3ab5..ec7e1cfd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsNowEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsNowEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsFriendsNowEvent extends MessageHandler -{ +public class SearchRoomsFriendsNowEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsFriendsNow(this.client.getHabbo()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsOwnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsOwnEvent.java index d18dc9e8..786434b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsOwnEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsFriendsOwnEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsFriendsOwnEvent extends MessageHandler -{ +public class SearchRoomsFriendsOwnEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsFriendsOwn(this.client.getHabbo()))); } } 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 index cedb70fc..6e3d1d96 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsInGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsInGroupEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsInGroupEvent extends MessageHandler -{ +public class SearchRoomsInGroupEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsInGroup(this.client.getHabbo()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsMyFavouriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsMyFavouriteEvent.java index 1b9c742b..452a55fc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsMyFavouriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsMyFavouriteEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsMyFavouriteEvent extends MessageHandler -{ +public class SearchRoomsMyFavouriteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(this.client.getHabbo()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsVisitedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsVisitedEvent.java index 18c775fb..41cb356c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsVisitedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsVisitedEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsVisitedEvent extends MessageHandler -{ +public class SearchRoomsVisitedEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsVisited(this.client.getHabbo(), false, 25))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsWithRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsWithRightsEvent.java index 2dec1cb1..c123d102 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsWithRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/SearchRoomsWithRightsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.PrivateRoomsComposer; -public class SearchRoomsWithRightsEvent extends MessageHandler -{ +public class SearchRoomsWithRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new PrivateRoomsComposer(Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(this.client.getHabbo()))); } } 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 6f194cb2..c9f0168c 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 @@ -4,30 +4,26 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; +import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class AnswerPollEvent extends MessageHandler -{ +public class AnswerPollEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int pollId = this.packet.readInt(); int questionId = this.packet.readInt(); int count = this.packet.readInt(); StringBuilder answer = new StringBuilder(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { answer.append(":").append(this.packet.readString()); } - if (pollId == 0 && questionId <= 0) - { + if (pollId == 0 && questionId <= 0) { this.client.getHabbo().getHabboInfo().getCurrentRoom().handleWordQuiz(this.client.getHabbo(), answer.toString()); return; } @@ -36,35 +32,26 @@ public class AnswerPollEvent extends MessageHandler Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId); - if(poll != null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO polls_answers(poll_id, user_id, question_id, answer) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE answer=VALUES(answer)")) - { + if (poll != null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO polls_answers(poll_id, user_id, question_id, answer) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE answer=VALUES(answer)")) { statement.setInt(1, pollId); statement.setInt(2, this.client.getHabbo().getHabboInfo().getId()); statement.setInt(3, questionId); statement.setString(4, answer.toString()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if(poll.lastQuestionId == questionId) - { - if(poll.badgeReward.length() > 0) - { - if(this.client.getHabbo().getInventory().getBadgesComponent().getBadge(poll.badgeReward) == null) - { + if (poll.lastQuestionId == questionId) { + if (poll.badgeReward.length() > 0) { + if (this.client.getHabbo().getInventory().getBadgesComponent().getBadge(poll.badgeReward) == null) { HabboBadge badge = new HabboBadge(0, poll.badgeReward, 0, this.client.getHabbo()); Emulator.getThreading().run(badge); this.client.getHabbo().getInventory().getBadgesComponent().addBadge(badge); this.client.sendResponse(new AddUserBadgeComposer(badge)); this.client.sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_BADGE)); - } - else - { + } else { this.client.sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java index 5a141212..ef0c8ae5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java @@ -8,28 +8,22 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class CancelPollEvent extends MessageHandler -{ +public class CancelPollEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int pollId = this.packet.readInt(); Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId); - if(poll != null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO polls_answers (poll_id, user_id, question_id, answer) VALUES (?, ?, ?, ?)")) - { + if (poll != null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO polls_answers (poll_id, user_id, question_id, answer) VALUES (?, ?, ?, ?)")) { statement.setInt(1, pollId); statement.setInt(2, this.client.getHabbo().getHabboInfo().getId()); statement.setInt(3, 0); statement.setString(4, ""); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/GetPollDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/GetPollDataEvent.java index 3fecaba7..491b20d1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/GetPollDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/GetPollDataEvent.java @@ -5,17 +5,14 @@ import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.polls.PollQuestionsComposer; -public class GetPollDataEvent extends MessageHandler -{ +public class GetPollDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int pollId = this.packet.readInt(); Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(pollId); - if(poll != null) - { + if (poll != null) { this.client.sendResponse(new PollQuestionsComposer(poll)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/HandleDoorbellEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/HandleDoorbellEvent.java index 6fdb6f3c..e521a7cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/HandleDoorbellEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/HandleDoorbellEvent.java @@ -7,29 +7,22 @@ import com.eu.habbo.messages.outgoing.hotelview.HotelViewComposer; import com.eu.habbo.messages.outgoing.rooms.HideDoorbellComposer; import com.eu.habbo.messages.outgoing.rooms.RoomAccessDeniedComposer; -public class HandleDoorbellEvent extends MessageHandler -{ +public class HandleDoorbellEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { String username = this.packet.readString(); boolean accepted = this.packet.readBoolean(); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); - if(habbo != null && habbo.getHabboInfo().getRoomQueueId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) - { + if (habbo != null && habbo.getHabboInfo().getRoomQueueId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) { this.client.getHabbo().getHabboInfo().getCurrentRoom().removeFromQueue(habbo); - if (accepted) - { + if (accepted) { habbo.getClient().sendResponse(new HideDoorbellComposer("")); Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); - } - else - { + } else { habbo.getClient().sendResponse(new RoomAccessDeniedComposer("")); habbo.getClient().sendResponse(new HotelViewComposer()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java index 28ca737a..e6311df8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java @@ -6,14 +6,11 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class RequestHeightmapEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.client.getHabbo().getHabboInfo().getLoadingRoom()); - if(room != null) - { + if (room != null) { Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), room); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomDataEvent.java index fb7d7d11..a4ba2fdf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomDataEvent.java @@ -5,21 +5,17 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; -public class RequestRoomDataEvent extends MessageHandler -{ +public class RequestRoomDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.packet.readInt()); int something = this.packet.readInt(); int something2 = this.packet.readInt(); - if(room != null) - { + if (room != null) { boolean unknown = true; - if(something == 0 && something2 == 1) - { + if (something == 0 && something2 == 1) { unknown = false; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java index e32d5c61..6e281ce2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java @@ -6,17 +6,13 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomHeightMapComposer; import com.eu.habbo.messages.outgoing.rooms.RoomRelativeMapComposer; -public class RequestRoomHeightmapEvent extends MessageHandler -{ +public class RequestRoomHeightmapEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.client.getHabbo().getHabboInfo().getLoadingRoom()); - if (room != null) - { + if (room != null) { this.client.sendResponse(new RoomRelativeMapComposer(room)); this.client.sendResponse(new RoomHeightMapComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomLoadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomLoadEvent.java index 1fb051f2..9bdaf28a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomLoadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomLoadEvent.java @@ -3,27 +3,21 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; -public class RequestRoomLoadEvent extends MessageHandler -{ +public class RequestRoomLoadEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); String password = this.packet.readString(); - if(this.client.getHabbo().getHabboInfo().getLoadingRoom() == 0 && this.client.getHabbo().getHabboStats().roomEnterTimestamp + 1000 < System.currentTimeMillis()) - { - if (this.client.getHabbo().getRoomUnit() != null && this.client.getHabbo().getRoomUnit().isTeleporting) - { + if (this.client.getHabbo().getHabboInfo().getLoadingRoom() == 0 && this.client.getHabbo().getHabboStats().roomEnterTimestamp + 1000 < System.currentTimeMillis()) { + if (this.client.getHabbo().getRoomUnit() != null && this.client.getHabbo().getRoomUnit().isTeleporting) { return; } Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); room.removeHabbo(this.client.getHabbo(), true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomRightsEvent.java index 1ede9c65..bd6841ac 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomRightsEvent.java @@ -5,18 +5,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomRightsListComposer; -public class RequestRoomRightsEvent extends MessageHandler -{ +public class RequestRoomRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { this.client.sendResponse(new RoomRightsListComposer(room)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java index 577e93db..5a9ad183 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java @@ -6,16 +6,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomSettingsComposer; -public class RequestRoomSettingsEvent extends MessageHandler -{ +public class RequestRoomSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) + if (room != null) this.client.sendResponse(new RoomSettingsComposer(room)); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatFloodFilterSeen")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomWordFilterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomWordFilterEvent.java index 69a2ebad..3d54bfe6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomWordFilterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomWordFilterEvent.java @@ -6,15 +6,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomFilterWordsComposer; -public class RequestRoomWordFilterEvent extends MessageHandler -{ +public class RequestRoomWordFilterEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); - if(room != null && room.hasRights(this.client.getHabbo())) - { + if (room != null && room.hasRights(this.client.getHabbo())) { this.client.sendResponse(new RoomFilterWordsComposer(room)); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModRoomFilterSeen")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomBackgroundEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomBackgroundEvent.java index 3af1cb99..038eba01 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomBackgroundEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomBackgroundEvent.java @@ -6,34 +6,31 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.furniture.FurnitureRoomTonerEvent; -public class RoomBackgroundEvent extends MessageHandler -{ +public class RoomBackgroundEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("acc_placefurni")) - { + if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("acc_placefurni")) { HabboItem item = room.getHabboItem(itemId); - if(item == null) + if (item == null) return; - int hue = this.packet.readInt(); - int saturation = this.packet.readInt(); - int brightness = this.packet.readInt(); + int hue = this.packet.readInt(); + 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 = (FurnitureRoomTonerEvent) Emulator.getPluginManager().fireEvent(new FurnitureRoomTonerEvent(item, this.client.getHabbo(), hue, saturation, brightness)); - if(event.isCancelled()) + if (event.isCancelled()) return; - hue = event.hue % 256; + hue = event.hue % 256; saturation = event.saturation % 256; brightness = event.brightness % 256; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomFavoriteEvent.java index 9b872f0c..9eaef836 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomFavoriteEvent.java @@ -5,27 +5,20 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.FavoriteRoomChangedComposer; -public class RoomFavoriteEvent extends MessageHandler -{ +public class RoomFavoriteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); boolean added = true; - if (room != null) - { - if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId)) - { + if (room != null) { + if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId)) { this.client.getHabbo().getHabboStats().removeFavoriteRoom(roomId); added = false; - } - else - { - if (!this.client.getHabbo().getHabboStats().addFavoriteRoom(roomId)) - { + } else { + if (!this.client.getHabbo().getHabboStats().addFavoriteRoom(roomId)) { return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomMuteEvent.java index d93fe57a..a71e2543 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomMuteEvent.java @@ -4,17 +4,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomMutedComposer; -public class RoomMuteEvent extends MessageHandler -{ +public class RoomMuteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.isOwner(this.client.getHabbo())) - { + if (room != null) { + if (room.isOwner(this.client.getHabbo())) { room.setMuted(!room.isMuted()); this.client.sendResponse(new RoomMutedComposer(room)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomPlacePaintEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomPlacePaintEvent.java index 2130a5ec..6ec977c7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomPlacePaintEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomPlacePaintEvent.java @@ -8,46 +8,36 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.messages.outgoing.rooms.RoomPaintComposer; -public class RoomPlacePaintEvent extends MessageHandler -{ +public class RoomPlacePaintEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("acc_placefurni")) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("acc_placefurni")) { int itemId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); - if(item == null) - { + if (item == null) { this.client.sendResponse(new RemoveHabboItemComposer(itemId)); return; } - if(item.getBaseItem().getName().equals("floor")) - { + if (item.getBaseItem().getName().equals("floor")) { room.setFloorPaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFloor")); - } - else if(item.getBaseItem().getName().equals("wallpaper")) - { + } else if (item.getBaseItem().getName().equals("wallpaper")) { room.setWallPaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoWallpaper")); - } - else if(item.getBaseItem().getName().equals("landscape")) - { + } else if (item.getBaseItem().getName().equals("landscape")) { room.setBackgroundPaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoLandscape")); - } - else + } else return; this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveAllRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveAllRightsEvent.java index 1bd31a8b..5bf9dc04 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveAllRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveAllRightsEvent.java @@ -10,27 +10,21 @@ import com.eu.habbo.messages.outgoing.rooms.RoomRightsComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveRightsComposer; import gnu.trove.procedure.TIntProcedure; -public class RoomRemoveAllRightsEvent extends MessageHandler -{ +public class RoomRemoveAllRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { final Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null || room.getId() != this.packet.readInt()) + if (room == null || room.getId() != this.packet.readInt()) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { - room.getRights().forEach(new TIntProcedure() - { + 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) - { + public boolean execute(int value) { Habbo habbo = room.getHabbo(value); - if(habbo != null) - { + if (habbo != null) { room.sendComposer(new RoomUserRemoveRightsComposer(room, value).compose()); habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); habbo.getClient().sendResponse(new RoomRightsComposer(RoomRightLevels.NONE)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveRightsEvent.java index cacb289e..1e23d538 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRemoveRightsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomRemoveRightsEvent extends MessageHandler -{ +public class RoomRemoveRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Emulator.getGameEnvironment().getRoomManager().getRoom(roomId).removeRights(this.client.getHabbo().getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRequestBannedUsersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRequestBannedUsersEvent.java index 1fc7115f..609e7b4c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRequestBannedUsersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomRequestBannedUsersEvent.java @@ -6,17 +6,14 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomBannedUsersComposer; -public class RoomRequestBannedUsersEvent extends MessageHandler -{ +public class RoomRequestBannedUsersEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { + if (room != null) { this.client.sendResponse(new RoomBannedUsersComposer(room)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java index f85db766..4adf71b4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java @@ -8,36 +8,29 @@ import com.eu.habbo.habbohotel.rooms.RoomState; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.*; -public class RoomSettingsSaveEvent extends MessageHandler -{ +public class RoomSettingsSaveEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { - if(room.isOwner(this.client.getHabbo())) - { + if (room != null) { + if (room.isOwner(this.client.getHabbo())) { String name = this.packet.readString(); - if (name.isEmpty()) - { + if (name.isEmpty()) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_NAME_MISSING, "")); return; } - if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equals(name)) - { + if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equals(name)) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_NAME_BADWORDS, "")); return; } String description = this.packet.readString(); - if (!Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description)) - { + if (!Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description)) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_DESCRIPTION_BADWORDS, "")); return; } @@ -45,8 +38,7 @@ public class RoomSettingsSaveEvent extends MessageHandler RoomState state = RoomState.values()[this.packet.readInt() % RoomState.values().length]; String password = this.packet.readString(); - if (state == RoomState.PASSWORD && password.isEmpty()) - { + if (state == RoomState.PASSWORD && password.isEmpty()) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.PASSWORD_REQUIRED, "")); return; } @@ -55,31 +47,25 @@ public class RoomSettingsSaveEvent extends MessageHandler int categoryId = this.packet.readInt(); StringBuilder tags = new StringBuilder(); int count = Math.min(this.packet.readInt(), 2); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { String tag = this.packet.readString(); - if (tag.length() > 15) - { + if (tag.length() > 15) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.TAGS_TOO_LONG, "")); return; } tags.append(tag).append(";"); } - if (!Emulator.getGameEnvironment().getWordFilter().filter(tags.toString(), this.client.getHabbo()).equals(tags.toString())) - { + if (!Emulator.getGameEnvironment().getWordFilter().filter(tags.toString(), this.client.getHabbo()).equals(tags.toString())) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_TAGS_BADWWORDS, "")); return; } - if (tags.length() > 0) - { - for (String s : Emulator.getConfig().getValue("hotel.room.tags.staff").split(";")) - { - if (tags.toString().contains(s)) - { + if (tags.length() > 0) { + for (String s : Emulator.getConfig().getValue("hotel.room.tags.staff").split(";")) { + if (tags.toString().contains(s)) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.RESTRICTED_TAGS, "1")); return; } @@ -93,20 +79,16 @@ public class RoomSettingsSaveEvent extends MessageHandler room.setUsersMax(usersMax); - if(Emulator.getGameEnvironment().getRoomManager().hasCategory(categoryId, this.client.getHabbo())) + if (Emulator.getGameEnvironment().getRoomManager().hasCategory(categoryId, this.client.getHabbo())) room.setCategory(categoryId); - else - { + else { RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId); String message; - if(category == null) - { + if (category == null) { message = Emulator.getTexts().getValue("scripter.warning.roomsettings.category.nonexisting").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()); - } - else - { + } else { message = Emulator.getTexts().getValue("scripter.warning.roomsettings.category.permission").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%category%", Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId) + ""); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomStaffPickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomStaffPickEvent.java index fec60d86..4a1ba8b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomStaffPickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomStaffPickEvent.java @@ -8,41 +8,31 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; -public class RoomStaffPickEvent extends MessageHandler -{ +public class RoomStaffPickEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().hasPermission("acc_staff_pick")) - { + public void handle() throws Exception { + if (this.client.getHabbo().hasPermission("acc_staff_pick")) { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { + if (room != null) { room.setStaffPromotedRoom(!room.isStaffPromotedRoom()); room.setNeedsUpdate(true); NavigatorPublicCategory publicCategory = Emulator.getGameEnvironment().getNavigatorManager().publicCategories.get(Emulator.getConfig().getInt("hotel.navigator.staffpicks.categoryid")); - if(room.isStaffPromotedRoom()) - { + if (room.isStaffPromotedRoom()) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getOwnerId()); - if(habbo != null) - { + if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("Spr")); } - if (publicCategory != null) - { + if (publicCategory != null) { publicCategory.addRoom(room); } - } - else - { - if (publicCategory != null) - { + } else { + if (publicCategory != null) { publicCategory.removeRoom(room); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomUnFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomUnFavoriteEvent.java index 3aa286fc..2b23d0c8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomUnFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomUnFavoriteEvent.java @@ -5,19 +5,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.FavoriteRoomChangedComposer; -public class RoomUnFavoriteEvent extends MessageHandler -{ +public class RoomUnFavoriteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if (room != null) - { - if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId)) - { + if (room != null) { + if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId)) { this.client.getHabbo().getHabboStats().removeFavoriteRoom(roomId); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomVoteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomVoteEvent.java index a5fc3e8a..57e3dc8f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomVoteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomVoteEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomVoteEvent extends MessageHandler -{ +public class RoomVoteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Emulator.getGameEnvironment().getRoomManager().voteForRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java index 309263bf..287a28f0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java @@ -4,30 +4,23 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomWordFilterModifyEvent extends MessageHandler -{ +public class RoomWordFilterModifyEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); boolean add = this.packet.readBoolean(); String word = this.packet.readString(); - if (word.length() > 25) - { + if (word.length() > 25) { word = word.substring(0, 24); } Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { - if (add) - { + if (room != null) { + if (add) { room.addToWordFilter(word); - } - else - { + } else { room.removeFromWordFilter(word); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java index a7f3566c..3f8544e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java @@ -3,15 +3,12 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserHomeRoomComposer; -public class SetHomeRoomEvent extends MessageHandler -{ +public class SetHomeRoomEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomId = this.packet.readInt(); - if(roomId != this.client.getHabbo().getHabboInfo().getHomeRoom()) - { + if (roomId != this.client.getHabbo().getHabboInfo().getHomeRoom()) { this.client.getHabbo().getHabboInfo().setHomeRoom(roomId); this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java index 8da59a29..6adae312 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class BotPickupEvent extends MessageHandler -{ +public class BotPickupEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Emulator.getGameEnvironment().getBotManager().pickUpBot(this.packet.readInt(), this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPlaceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPlaceEvent.java index fe72d83d..4b9e9c95 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPlaceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPlaceEvent.java @@ -5,19 +5,17 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class BotPlaceEvent extends MessageHandler -{ +public class BotPlaceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Bot bot = this.client.getHabbo().getInventory().getBotsComponent().getBot(this.packet.readInt()); - if(bot == null) + if (bot == null) return; int x = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java index c3149d52..8d9fa8e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java @@ -18,37 +18,33 @@ import org.jsoup.Jsoup; import java.util.ArrayList; -public class BotSaveSettingsEvent extends MessageHandler -{ +public class BotSaveSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); Bot bot = room.getBot(Math.abs(botId)); - if(bot == null) + if (bot == null) return; int settingId = this.packet.readInt(); - switch(settingId) - { + switch (settingId) { case 1: BotSavedLookEvent lookEvent = new BotSavedLookEvent(bot, - this.client.getHabbo().getHabboInfo().getGender(), - this.client.getHabbo().getHabboInfo().getLook(), - this.client.getHabbo().getRoomUnit().getEffectId()); + this.client.getHabbo().getHabboInfo().getGender(), + this.client.getHabbo().getHabboInfo().getLook(), + this.client.getHabbo().getRoomUnit().getEffectId()); Emulator.getPluginManager().fireEvent(lookEvent); - if(lookEvent.isCancelled()) + if (lookEvent.isCancelled()) break; bot.setFigure(lookEvent.newLook); @@ -60,22 +56,22 @@ public class BotSaveSettingsEvent extends MessageHandler case 2: String messageString = this.packet.readString(); - if(messageString.length() > 5112) + 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++) - { - for(String s : data[i].split("\r")) - { + for (int i = 0; i < data.length - 3 && totalChatLength <= 120; i++) { + for (String s : data[i].split("\r")) { String filtered = Jsoup.parse(s).text(); int count = 0; - while (!filtered.equalsIgnoreCase(s)) - { - if (count >=5){ bot.clearChat(); return; } + while (!filtered.equalsIgnoreCase(s)) { + if (count >= 5) { + bot.clearChat(); + return; + } s = filtered; filtered = Jsoup.parse(s).text(); count++; @@ -83,10 +79,8 @@ public class BotSaveSettingsEvent extends MessageHandler String result = Emulator.getGameEnvironment().getWordFilter().filter(s, null); - if (!result.isEmpty()) - { - if (!this.client.getHabbo().hasPermission("acc_chat_no_filter")) - { + if (!result.isEmpty()) { + if (!this.client.getHabbo().hasPermission("acc_chat_no_filter")) { result = Emulator.getGameEnvironment().getWordFilter().filter(result, this.client.getHabbo()); } @@ -99,23 +93,19 @@ public class BotSaveSettingsEvent extends MessageHandler int chatSpeed = 7; - try - { + try { chatSpeed = Integer.valueOf(data[data.length - 2]); - if (chatSpeed < BotManager.MINIMUM_CHAT_SPEED) - { + if (chatSpeed < BotManager.MINIMUM_CHAT_SPEED) { chatSpeed = BotManager.MINIMUM_CHAT_SPEED; } - } - catch (Exception e) - { + } 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); Emulator.getPluginManager().fireEvent(chatEvent); - if(chatEvent.isCancelled()) + if (chatEvent.isCancelled()) break; bot.setChatAuto(chatEvent.autoChat); @@ -132,7 +122,7 @@ public class BotSaveSettingsEvent extends MessageHandler break; case 4: - bot.getRoomUnit().setDanceType(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) %DanceType.values().length]); + bot.getRoomUnit().setDanceType(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) % DanceType.values().length]); room.sendComposer(new RoomUserDanceComposer(bot.getRoomUnit()).compose()); bot.needsUpdate(true); break; @@ -140,12 +130,10 @@ public class BotSaveSettingsEvent extends MessageHandler case 5: String name = this.packet.readString(); boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH; - if (!invalidName) - { - String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(Jsoup.parse(name).text(), null); + if (!invalidName) { + String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(Jsoup.parse(name).text(), null); invalidName = !name.equalsIgnoreCase(filteredName); - if (!invalidName) - { + if (!invalidName) { BotSavedNameEvent nameEvent = new BotSavedNameEvent(bot, name); Emulator.getPluginManager().fireEvent(nameEvent); @@ -159,8 +147,7 @@ public class BotSaveSettingsEvent extends MessageHandler } } - if (invalidName) - { + if (invalidName) { this.client.sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_NAME_NOT_ACCEPT)); } break; @@ -171,8 +158,7 @@ public class BotSaveSettingsEvent extends MessageHandler break; } - if(bot.needsUpdate()) - { + if (bot.needsUpdate()) { Emulator.getThreading().run(bot); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSettingsEvent.java index eeb58f4d..1a5cbdaa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSettingsEvent.java @@ -6,18 +6,15 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.BotSettingsComposer; -public class BotSettingsEvent extends MessageHandler -{ +public class BotSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); Bot bot = room.getBot(Math.abs(botId)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java index 62bf39c9..6fb6b0b6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java @@ -7,11 +7,9 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class AdvertisingSaveEvent extends MessageHandler -{ +public class AdvertisingSaveEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); if (room == null) return; @@ -23,21 +21,17 @@ public class AdvertisingSaveEvent extends MessageHandler if (item == null) return; - if (item instanceof InteractionRoomAds && !this.client.getHabbo().hasPermission("acc_ads_background")) - { + if (item instanceof InteractionRoomAds && !this.client.getHabbo().hasPermission("acc_ads_background")) { this.client.getHabbo().alert(Emulator.getTexts().getValue("hotel.error.roomads.nopermission")); return; } - if(item instanceof InteractionCustomValues) - { + if (item instanceof InteractionCustomValues) { int count = this.packet.readInt(); - for(int i = 0; i < count / 2; i++) - { + for (int i = 0; i < count / 2; i++) { String key = this.packet.readString(); String value = this.packet.readString(); - if (!Emulator.getConfig().getBoolean("camera.use.https")) - { + if (!Emulator.getConfig().getBoolean("camera.use.https")) { value = value.replace("https://", "http://"); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CloseDiceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CloseDiceEvent.java index be480ddf..37ceeed4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CloseDiceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CloseDiceEvent.java @@ -8,37 +8,29 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class CloseDiceEvent extends MessageHandler -{ +public class CloseDiceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if(item != null) - { - if (item instanceof InteractionDice) - { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) - { - if (!item.getExtradata().equals("-1")) - { + if (item != null) { + if (item instanceof InteractionDice) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (!item.getExtradata().equals("-1")) { item.setExtradata("0"); item.needsUpdate(true); Emulator.getThreading().run(item); room.updateItem(item); } } - } - else - { + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.packet.closedice").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%id%", item.getId() + "").replace("%itemname%", item.getBaseItem().getName())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/FootballGateSaveLookEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/FootballGateSaveLookEvent.java index 61774770..aa4d2f30 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/FootballGateSaveLookEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/FootballGateSaveLookEvent.java @@ -5,33 +5,30 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class FootballGateSaveLookEvent extends MessageHandler -{ +public class FootballGateSaveLookEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) + if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) return; HabboItem item = room.getHabboItem(this.packet.readInt()); - if(!(item instanceof InteractionFootballGate)) + if (!(item instanceof InteractionFootballGate)) return; String gender = this.packet.readString(); String look = this.packet.readString(); - switch(gender.toLowerCase()) - { + switch (gender.toLowerCase()) { default: case "m": - ((InteractionFootballGate)item).setFigureM(look); + ((InteractionFootballGate) item).setFigureM(look); room.updateItem(item); break; case "f": - ((InteractionFootballGate)item).setFigureF(look); + ((InteractionFootballGate) item).setFigureF(look); room.updateItem(item); break; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveLookEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveLookEvent.java index e1ddf44e..5def4dee 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveLookEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveLookEvent.java @@ -5,18 +5,16 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class MannequinSaveLookEvent extends MessageHandler -{ +public class MannequinSaveLookEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) + if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) return; HabboItem item = room.getHabboItem(this.packet.readInt()); - if(item == null) + if (item == null) return; String[] data = item.getExtradata().split(":"); @@ -24,25 +22,19 @@ public class MannequinSaveLookEvent extends MessageHandler StringBuilder look = new StringBuilder(); - for (String s : this.client.getHabbo().getHabboInfo().getLook().split("\\.")) - { - if (!s.contains("hr") && !s.contains("hd") && !s.contains("he") && !s.contains("ea") && !s.contains("ha") && !s.contains("fa")) - { + for (String s : this.client.getHabbo().getHabboInfo().getLook().split("\\.")) { + if (!s.contains("hr") && !s.contains("hd") && !s.contains("he") && !s.contains("ea") && !s.contains("ha") && !s.contains("fa")) { look.append(s).append("."); } } - if (look.length() > 0) - { + if (look.length() > 0) { look = new StringBuilder(look.substring(0, look.length() - 1)); } - if(data.length == 3) - { + if (data.length == 3) { item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + data[2]); - } - else - { + } else { item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + this.client.getHabbo().getHabboInfo().getUsername() + "'s look."); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveNameEvent.java index ad7fd320..7715ffd2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MannequinSaveNameEvent.java @@ -5,27 +5,22 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class MannequinSaveNameEvent extends MessageHandler -{ +public class MannequinSaveNameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) + if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) return; HabboItem item = room.getHabboItem(this.packet.readInt()); - if(item == null) + if (item == null) return; String[] data = item.getExtradata().split(":"); String name = this.packet.readString(); - if(data.length == 3) - { + if (data.length == 3) { item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + data[1] + ":" + name); - } - else - { + } else { item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + this.client.getHabbo().getHabboInfo().getLook() + ":" + name); } item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index c6f56484..3c2e8d4e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -8,14 +8,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.MoodLightDataComposer; -public class MoodLightSaveSettingsEvent extends MessageHandler -{ +public class MoodLightSaveSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) + if ((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) return; int id = this.packet.readInt(); @@ -23,25 +21,20 @@ public class MoodLightSaveSettingsEvent extends MessageHandler String color = this.packet.readString(); int intensity = this.packet.readInt(); - for(RoomMoodlightData data : room.getMoodlightData().valueCollection()) - { - if(data.getId() == id) - { + for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + if (data.getId() == id) { data.setBackgroundOnly(backgroundOnly == 2); data.setColor(color); data.setIntensity(intensity); data.enable(); - for(HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) - { + for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { item.setExtradata(data.toString()); item.needsUpdate(true); room.updateItem(item); Emulator.getThreading().run(item); } - } - else - { + } else { data.disable(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSettingsEvent.java index 62815c84..bd1cc107 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSettingsEvent.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.MoodLightDataComposer; -public class MoodLightSettingsEvent extends MessageHandler -{ +public class MoodLightSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) this.client.sendResponse(new MoodLightDataComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom().getMoodlightData())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java index 746caafb..2083c819 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java @@ -7,26 +7,21 @@ import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class MoodLightTurnOnEvent extends MessageHandler -{ +public class MoodLightTurnOnEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) + if ((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) return; - for(HabboItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) - { + for (HabboItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { //Enabled, preset id, background only ? 2 : 1, color, intensity moodLight.setExtradata("2,1,2,#FF00FF,255"); - for(RoomMoodlightData data : room.getMoodlightData().valueCollection()) - { - if(data.isEnabled()) - { + for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + if (data.isEnabled()) { moodLight.setExtradata(data.toString()); break; } 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 c1aee0b6..b583cff8 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 @@ -7,18 +7,15 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -public class MoveWallItemEvent extends MessageHandler -{ +public class MoveWallItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasPermission("acc_placefurni") && !(room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) >= 2)) - { + if (!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasPermission("acc_placefurni") && !(room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) >= 2)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); return; } @@ -26,12 +23,12 @@ public class MoveWallItemEvent extends MessageHandler int itemId = this.packet.readInt(); String wallPosition = this.packet.readString(); - if(itemId <= 0 || wallPosition.length() <= 13) + if (itemId <= 0 || wallPosition.length() <= 13) return; HabboItem item = room.getHabboItem(itemId); - if(item == null) + if (item == null) return; item.setWallPosition(wallPosition); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java index 00770fce..4b5c26f6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItDeleteEvent.java @@ -9,24 +9,20 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveWallItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -public class PostItDeleteEvent extends MessageHandler -{ +public class PostItDeleteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) - { - if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId() || room.isOwner(this.client.getHabbo())) - { + if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { + if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId() || room.isOwner(this.client.getHabbo())) { item.setRoomId(0); room.removeHabboItem(item); room.sendComposer(new RemoveWallItemComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItPlaceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItPlaceEvent.java index dfbbfd6f..45713d4f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItPlaceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItPlaceEvent.java @@ -10,24 +10,19 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.AddWallItemComposer; -public class PostItPlaceEvent extends MessageHandler -{ +public class PostItPlaceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); String location = this.packet.readString(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if (room.hasRights(this.client.getHabbo()) || !room.getRoomSpecialTypes().getItemsOfType(InteractionStickyPole.class).isEmpty()) - { + if (room != null) { + if (room.hasRights(this.client.getHabbo()) || !room.getRoomSpecialTypes().getItemsOfType(InteractionStickyPole.class).isEmpty()) { HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); - if (item instanceof InteractionPostIt) - { + if (item instanceof InteractionPostIt) { room.addHabboItem(item); item.setExtradata("FFFF33"); item.setRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()); @@ -40,8 +35,7 @@ public class PostItPlaceEvent extends MessageHandler item.setFromGift(false); Emulator.getThreading().run(item); - if (room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) - { + if (room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesReceived")); AchievementManager.progressAchievement(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesLeft")); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItRequestDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItRequestDataEvent.java index 36a49414..7a1d3d2b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItRequestDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItRequestDataEvent.java @@ -6,21 +6,17 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.PostItDataComposer; -public class PostItRequestDataEvent extends MessageHandler -{ +public class PostItRequestDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { HabboItem item = room.getHabboItem(itemId); - if(item instanceof InteractionPostIt) - { + if (item instanceof InteractionPostIt) { this.client.sendResponse(new PostItDataComposer((InteractionPostIt) item)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java index fdc616b4..ff4e1fb7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java @@ -8,33 +8,27 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class PostItSaveDataEvent extends MessageHandler -{ +public class PostItSaveDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); String color = this.packet.readString(); String text = this.packet.readString(); - if (text.length() > Emulator.getConfig().getInt("postit.charlimit")) - { + if (text.length() > Emulator.getConfig().getInt("postit.charlimit")) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.sticky.size").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%amount%", text.length() + "").replace("%limit%", "366")); - if (text.length() >= Emulator.getConfig().getInt("postit.charlimit") + 50) - { + if (text.length() >= Emulator.getConfig().getInt("postit.charlimit") + 50) { this.client.getHabbo().alert("8=====D~~~~~

Computer Says:NO"); } return; } text = text.replace(((char) 9) + "", ""); - if(text.startsWith("#") || text.startsWith(" #")) - { + if (text.startsWith("#") || text.startsWith(" #")) { String colorCheck = text.split(" ")[0].replace(" ", "").replace(" #", "").replace("#", ""); - if(colorCheck.length() == 6) - { + if (colorCheck.length() == 6) { color = colorCheck; text = text.replace("#" + colorCheck + " ", ""); } @@ -42,28 +36,24 @@ public class PostItSaveDataEvent extends MessageHandler Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if(!(item instanceof InteractionPostIt)) + if (!(item instanceof InteractionPostIt)) return; - if(!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.hasRights(this.client.getHabbo())&& item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) - { - if(!text.startsWith(item.getExtradata().replace(item.getExtradata().split(" ")[0], ""))) - { + if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.hasRights(this.client.getHabbo()) && item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) { + if (!text.startsWith(item.getExtradata().replace(item.getExtradata().split(" ")[0], ""))) { return; } - } - else - { - if(!room.hasRights(this.client.getHabbo()) && item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) + } else { + if (!room.hasRights(this.client.getHabbo()) && item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; } - if(color.isEmpty()) + if (color.isEmpty()) color = PostItColor.YELLOW.hexColor; item.setUserId(room.getOwnerId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index 99c40950..28fe03b3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -17,28 +17,21 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class RedeemClothingEvent extends MessageHandler -{ +public class RedeemClothingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && - this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && + this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { - if(item instanceof InteractionClothing) - { + if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item instanceof InteractionClothing) { ClothItem clothing = Emulator.getGameEnvironment().getCatalogManager().getClothing(item.getBaseItem().getName()); - if (clothing != null) - { - if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.id)) - { + if (clothing != null) { + if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.id)) { item.setRoomId(0); RoomTile tile = this.client.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(item.getX(), item.getY()); this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); @@ -47,14 +40,11 @@ public class RedeemClothingEvent extends MessageHandler 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 (?, ?)")) - { + 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.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -62,14 +52,10 @@ public class RedeemClothingEvent extends MessageHandler this.client.sendResponse(new UserClothesComposer(this.client.getHabbo())); this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_REDEEMED.key)); - } - else - { + } else { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_OWNED_ALREADY.key)); } - } - else - { + } else { Emulator.getLogging().logErrorLine("[Catalog] No definition in catalog_clothing found for clothing name " + item.getBaseItem().getName() + ". Could not redeem clothing!"); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java index 106c2efb..a5f72a41 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java @@ -9,101 +9,70 @@ import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import com.eu.habbo.messages.outgoing.users.UserCurrencyComposer; -import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.furniture.FurnitureRedeemedEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import gnu.trove.set.hash.THashSet; -import java.util.ArrayList; - -public class RedeemItemEvent extends MessageHandler -{ +public class RedeemItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { HabboItem item = room.getHabboItem(itemId); - if(item != null && this.client.getHabbo().getHabboInfo().getId() == item.getUserId()) - { + if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getUserId()) { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); FurnitureRedeemedEvent furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), 0, FurnitureRedeemedEvent.CREDITS); - if(item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) - { - if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) - { + if (item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) { + if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { int credits; - try - { + try { credits = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse redeemable furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_"); return; } furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), credits, FurnitureRedeemedEvent.CREDITS); - } - else if (item.getBaseItem().getName().startsWith("PF_")) - { + } else if (item.getBaseItem().getName().startsWith("PF_")) { int pixels; - try - { + try { pixels = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse redeemable pixel furniture: " + item.getBaseItem().getName() + ". Must be in format of PF_"); return; } furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), pixels, FurnitureRedeemedEvent.PIXELS); - } - else if (item.getBaseItem().getName().startsWith("DF_")) - { + } else if (item.getBaseItem().getName().startsWith("DF_")) { int pointsType; int points; - try - { + try { pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } - try - { + try { points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), points, pointsType); - } - else if (item.getBaseItem().getName().startsWith("CF_diamond_")) - { + } else if (item.getBaseItem().getName().startsWith("CF_diamond_")) { int points; - try - { + try { points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to parse redeemable diamonds furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_diamond_"); return; } @@ -111,18 +80,17 @@ public class RedeemItemEvent extends MessageHandler furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), points, FurnitureRedeemedEvent.DIAMONDS); } - if(furnitureRedeemEventRegistered) - { + if (furnitureRedeemEventRegistered) { Emulator.getPluginManager().fireEvent(furniRedeemEvent); - if(furniRedeemEvent.isCancelled()) + if (furniRedeemEvent.isCancelled()) return; } - if(furniRedeemEvent.amount < 1) + if (furniRedeemEvent.amount < 1) return; - if(room.getHabboItem(item.getId()) == null) // plugins may cause a lag between which time the item can be removed from the room + if (room.getHabboItem(item.getId()) == null) // plugins may cause a lag between which time the item can be removed from the room return; room.removeHabboItem(item); @@ -133,7 +101,7 @@ public class RedeemItemEvent extends MessageHandler room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), t.relativeHeight()).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); - switch(furniRedeemEvent.currencyID) { + switch (furniRedeemEvent.currencyID) { case FurnitureRedeemedEvent.CREDITS: this.client.getHabbo().getHabboInfo().addCredits(furniRedeemEvent.amount); this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java index 8516fa08..fe4ab2c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java @@ -6,11 +6,9 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomPickupItemEvent extends MessageHandler -{ +public class RoomPickupItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int unknown = this.packet.readInt(); int itemId = this.packet.readInt(); @@ -24,19 +22,14 @@ public class RoomPickupItemEvent extends MessageHandler if (item == null) return; - if(item instanceof InteractionPostIt) + if (item instanceof InteractionPostIt) return; - if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { + if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { room.pickUpItem(item, this.client.getHabbo()); - } - else - { - if (room.hasRights(this.client.getHabbo())) - { - if (this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + } else { + if (room.hasRights(this.client.getHabbo())) { + if (this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { item.setUserId(this.client.getHabbo().getHabboInfo().getId()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java index 478a320f..d689a80a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java @@ -11,64 +11,54 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; -import gnu.trove.set.hash.THashSet; -public class RoomPlaceItemEvent extends MessageHandler -{ +public class RoomPlaceItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String[] values = this.packet.readString().split(" "); int itemId = -1; if (values.length != 0) itemId = Integer.valueOf(values[0]); - if(!this.client.getHabbo().getRoomUnit().isInRoom()) - { + if (!this.client.getHabbo().getRoomUnit().isInRoom()) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); return; } Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) - { + if (room == null) { return; } HabboItem rentSpace = null; - if(this.client.getHabbo().getHabboStats().isRentingSpace()) - { + if (this.client.getHabbo().getHabboStats().isRentingSpace()) { rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().rentedItemId); } HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); - if(item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) + if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) return; - if(room.getId() != item.getRoomId() && item.getRoomId() != 0) + if (room.getId() != item.getRoomId() && item.getRoomId() != 0) return; //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()) - { + if (item instanceof InteractionMoodLight && !room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_DIMMERS.errorCode)); return; } - if (item instanceof InteractionJukeBox && !room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) - { + if (item instanceof InteractionJukeBox && !room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.MAX_SOUNDFURNI.errorCode)); return; } - if (item.getBaseItem().getType() == FurnitureType.FLOOR) - { + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { short x = Short.valueOf(values[1]); short y = Short.valueOf(values[2]); int rotation = Integer.valueOf(values[3]); - if (rentSpace != null && !room.hasRights(this.client.getHabbo())) - { + if (rentSpace != null && !room.hasRights(this.client.getHabbo())) { if (item instanceof InteractionRoller || item instanceof InteractionStackHelper || item instanceof InteractionWired || @@ -76,14 +66,12 @@ public class RoomPlaceItemEvent extends MessageHandler item instanceof InteractionRoomAds || item instanceof InteractionCannon || item instanceof InteractionPuzzleBox || - item.getBaseItem().getType() == FurnitureType.WALL) - { + item.getBaseItem().getType() == FurnitureType.WALL) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); return; } - if (!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))) - { + if (!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 BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); return; } @@ -94,24 +82,19 @@ public class RoomPlaceItemEvent extends MessageHandler RoomTile tile = room.getLayout().getTile(x, y); FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); - if (!error.equals(FurnitureMovementError.NONE)) - { + if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); return; } error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo()); - if (!error.equals(FurnitureMovementError.NONE)) - { + if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); return; } - } - else - { + } else { FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); - if (!error.equals(FurnitureMovementError.NONE)) - { + if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RotateMoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RotateMoveItemEvent.java index c175ff96..22a6b1ec 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RotateMoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RotateMoveItemEvent.java @@ -9,11 +9,9 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer; -public class RotateMoveItemEvent extends MessageHandler -{ +public class RotateMoveItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); if (room == null) @@ -29,16 +27,14 @@ public class RotateMoveItemEvent extends MessageHandler RoomTile tile = room.getLayout().getTile((short) x, (short) y); FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); - if (!error.equals(FurnitureMovementError.NONE)) - { + if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); this.client.sendResponse(new FloorItemUpdateComposer(item)); return; } error = room.moveFurniTo(item, tile, rotation, this.client.getHabbo()); - if (!error.equals(FurnitureMovementError.NONE)) - { + if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, error.errorCode)); this.client.sendResponse(new FloorItemUpdateComposer(item)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java index 7ac1187f..8a672308 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java @@ -10,51 +10,38 @@ import com.eu.habbo.messages.incoming.MessageHandler; import java.time.LocalDate; -public class SavePostItStickyPoleEvent extends MessageHandler -{ +public class SavePostItStickyPoleEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); this.packet.readString(); String color = this.packet.readString(); - if(itemId == -1234) - { - if(this.client.getHabbo().hasPermission("cmd_multi")) - { + if (itemId == -1234) { + if (this.client.getHabbo().hasPermission("cmd_multi")) { String[] commands = this.packet.readString().split("\r"); - for (String command : commands) - { + for (String command : commands) { command = command.replace("
", "\r"); CommandHandler.handleCommand(this.client, command); } - } - else - { + } else { Emulator.getLogging().logUserLine("Scripter Alert! " + this.client.getHabbo().getHabboInfo().getUsername() + " | " + this.packet.readString()); } - } - else - { + } else { String text = this.packet.readString(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); HabboItem sticky = room.getHabboItem(itemId); - if (sticky != null) - { - if (sticky.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { + if (sticky != null) { + if (sticky.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { sticky.setUserId(room.getOwnerId()); - if (color.equalsIgnoreCase(PostItColor.YELLOW.hexColor)) - { + if (color.equalsIgnoreCase(PostItColor.YELLOW.hexColor)) { color = PostItColor.randomColorNotYellow().hexColor; } - if (!InteractionPostIt.STICKYPOLE_PREFIX_TEXT.isEmpty()) - { + if (!InteractionPostIt.STICKYPOLE_PREFIX_TEXT.isEmpty()) { text = InteractionPostIt.STICKYPOLE_PREFIX_TEXT.replace("\\r", "\r").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%timestamp%", LocalDate.now().toString()) + text; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java index 2ca3ff24..4986e685 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java @@ -9,61 +9,50 @@ import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer; import com.eu.habbo.messages.outgoing.rooms.items.UpdateStackHeightTileHeightComposer; import gnu.trove.set.hash.THashSet; -public class SetStackHelperHeightEvent extends MessageHandler -{ +public class SetStackHelperHeightEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; - if(this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) - { + if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item instanceof InteractionStackHelper) - { + if (item instanceof InteractionStackHelper) { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY()); double stackerHeight = this.packet.readInt(); THashSet tiles = room.getLayout().getTilesAt(itemTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - if (stackerHeight == -100) - { - for (RoomTile tile : tiles) - { + if (stackerHeight == -100) { + for (RoomTile tile : tiles) { double stackheight = room.getStackHeight(tile.x, tile.y, false, item) * 100; - if (stackheight > stackerHeight) - { + if (stackheight > stackerHeight) { stackerHeight = stackheight; } } - } - else - { + } else { stackerHeight = Math.min(Math.max(stackerHeight, itemTile.z * 100), 4000); } double height = 0; - if(stackerHeight >= 0) - { + if (stackerHeight >= 0) { height = stackerHeight / 100.0D; } - for (RoomTile tile : tiles) - { + for (RoomTile tile : tiles) { tile.setStackHeight(height); } item.setZ(height); - item.setExtradata((int)(height * 100) + ""); + item.setExtradata((int) (height * 100) + ""); item.needsUpdate(true); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tiles).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int)((height) * 100)).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index e78db148..66f02e49 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -14,13 +14,10 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.set.hash.THashSet; -public class ToggleFloorItemEvent extends MessageHandler -{ +public class ToggleFloorItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { - try - { + public void handle() throws Exception { + try { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); if (room == null) @@ -34,59 +31,45 @@ public class ToggleFloorItemEvent extends MessageHandler if (item == null || item instanceof InteractionDice) return; - if(item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) { THashSet items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY())); HabboItem totemLeg = null; HabboItem totemHead = null; - for(HabboItem totemItem : items) - { - if(totemLeg != null && totemHead != null) - { + for (HabboItem totemItem : items) { + if (totemLeg != null && totemHead != null) { break; } - if(totemItem.getBaseItem().getName().equalsIgnoreCase("totem_leg")) - { + if (totemItem.getBaseItem().getName().equalsIgnoreCase("totem_leg")) { totemLeg = totemItem; } - if(totemItem.getBaseItem().getName().equalsIgnoreCase("totem_head")) - { + if (totemItem.getBaseItem().getName().equalsIgnoreCase("totem_head")) { totemHead = totemItem; } } - if(totemHead != null && totemLeg != null) - { - if (item.getExtradata().equals("2")) - { + if (totemHead != null && totemLeg != null) { + if (item.getExtradata().equals("2")) { if (totemLeg.getExtradata() == null || totemHead.getExtradata() == null) return; - if (totemLeg.getExtradata().equals("2") && totemHead.getExtradata().equals("5")) - { + if (totemLeg.getExtradata().equals("2") && totemHead.getExtradata().equals("5")) { room.giveEffect(this.client.getHabbo(), 23, -1); return; } - if (totemLeg.getExtradata().equals("10") && totemHead.getExtradata().equals("9")) - { + if (totemLeg.getExtradata().equals("10") && totemHead.getExtradata().equals("9")) { room.giveEffect(this.client.getHabbo(), 26, -1); return; } - } else if(item.getExtradata().equals("0")) - { - if(totemLeg.getExtradata().equals("7") && totemHead.getExtradata().equals("10")) - { + } else if (item.getExtradata().equals("0")) { + if (totemLeg.getExtradata().equals("7") && totemHead.getExtradata().equals("10")) { room.giveEffect(this.client.getHabbo(), 24, -1); return; } - } - else if(item.getExtradata().equals("1")) - { - if(totemLeg.getExtradata().equals("9") && totemHead.getExtradata().equals("12")) - { + } else if (item.getExtradata().equals("1")) { + if (totemLeg.getExtradata().equals("9") && totemHead.getExtradata().equals("12")) { room.giveEffect(this.client.getHabbo(), 25, -1); return; } @@ -95,19 +78,15 @@ public class ToggleFloorItemEvent extends MessageHandler } //Do not move to onClick(). Wired could trigger it. - if(item instanceof InteractionMonsterPlantSeed) - { + if (item instanceof InteractionMonsterPlantSeed) { Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); int rarity = 0; if (item.getExtradata().isEmpty()) rarity = InteractionMonsterPlantSeed.randomRarityLevel(); - else - { - try - { + else { + try { rarity = Integer.valueOf(item.getExtradata()) - 1; + } catch (Exception e) { } - catch (Exception e) - {} } MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), item.getBaseItem().getName().contains("rare"), room.getLayout().getTile(item.getX(), item.getY()), rarity); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); @@ -121,25 +100,21 @@ public class ToggleFloorItemEvent extends MessageHandler if ( (item.getBaseItem().getName().equalsIgnoreCase("val11_present") || - item.getBaseItem().getName().equalsIgnoreCase("gnome_box") || - item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box") || - item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg") || - item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg") || - item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) - { + item.getBaseItem().getName().equalsIgnoreCase("gnome_box") || + item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box") || + item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg") || + item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg") || + item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) { this.client.sendResponse(new PetPackageComposer(item)); return; } item.onClick(this.client, room, new Object[]{state}); - if(item instanceof InteractionWired) - { + if (item instanceof InteractionWired) { this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleWallItemEvent.java index d94257d4..8700940c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleWallItemEvent.java @@ -5,11 +5,9 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class ToggleWallItemEvent extends MessageHandler -{ +public class ToggleWallItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); if (room == null) @@ -23,7 +21,7 @@ public class ToggleWallItemEvent extends MessageHandler if (item == null) return; - if(item.getBaseItem().getName().equalsIgnoreCase("poster")) + if (item.getBaseItem().getName().equalsIgnoreCase("poster")) return; item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerColorWheelEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerColorWheelEvent.java index 39cbfa8a..58df4ab3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerColorWheelEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerColorWheelEvent.java @@ -5,22 +5,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class TriggerColorWheelEvent extends MessageHandler -{ +public class TriggerColorWheelEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if(item instanceof InteractionColorWheel) - { + if (item instanceof InteractionColorWheel) { item.onClick(this.client, room, null); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerDiceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerDiceEvent.java index ea8b039d..bc5c91cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerDiceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerDiceEvent.java @@ -6,28 +6,22 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class TriggerDiceEvent extends MessageHandler -{ +public class TriggerDiceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) - { + if (room == null) { return; } HabboItem item = room.getHabboItem(itemId); - if(item != null) - { - if(item instanceof InteractionDice) - { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) - { + if (item != null) { + if (item instanceof InteractionDice) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) { item.onClick(this.client, room, new Object[]{}); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerOneWayGateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerOneWayGateEvent.java index 096b0898..04c9bfd0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerOneWayGateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/TriggerOneWayGateEvent.java @@ -4,23 +4,20 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionOneWayGate; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class TriggerOneWayGateEvent extends MessageHandler -{ +public class TriggerOneWayGateEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; int itemId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item == null) + if (item == null) return; - if(item instanceof InteractionOneWayGate) - { - if(!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting) + if (item instanceof InteractionOneWayGate) { + if (!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting) return; item.onClick(this.client, this.client.getHabbo().getHabboInfo().getCurrentRoom(), null); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java index fabc8d2c..273e62e4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java @@ -5,26 +5,21 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class JukeBoxAddSoundTrackEvent extends MessageHandler -{ +public class JukeBoxAddSoundTrackEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); int unknown = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { HabboItem item = room.getHabboItem(itemId); - if (item instanceof InteractionMusicDisc) - { + if (item instanceof InteractionMusicDisc) { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong(itemId); } } 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 621a75b9..3e4dd7d6 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 @@ -5,11 +5,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer; -public class JukeBoxEventOne extends MessageHandler -{ +public class JukeBoxEventOne extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java index 989411ca..41a86a7d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java @@ -5,11 +5,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer; -public class JukeBoxEventTwo extends MessageHandler -{ +public class JukeBoxEventTwo extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRemoveSoundTrackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRemoveSoundTrackEvent.java index 6cbd539d..0c631861 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRemoveSoundTrackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRemoveSoundTrackEvent.java @@ -3,17 +3,14 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; import com.eu.habbo.messages.incoming.MessageHandler; -public class JukeBoxRemoveSoundTrackEvent extends MessageHandler -{ +public class JukeBoxRemoveSoundTrackEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int index = this.packet.readInt(); InteractionMusicDisc musicDisc = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().getSongs().get(index); - if (musicDisc != null) - { + if (musicDisc != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().removeSong(musicDisc.getId()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java index dfa63dc7..88bcd1c4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java @@ -5,11 +5,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer; -public class JukeBoxRequestPlayListEvent extends MessageHandler -{ +public class JukeBoxRequestPlayListEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/LoveLockStartConfirmEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/LoveLockStartConfirmEvent.java index 34f33b25..d4588cdf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/LoveLockStartConfirmEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/LoveLockStartConfirmEvent.java @@ -7,15 +7,12 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.LoveLockFurniFinishedComposer; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.LoveLockFurniFriendConfirmedComposer; -public class LoveLockStartConfirmEvent extends MessageHandler -{ +public class LoveLockStartConfirmEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); - if (this.packet.readBoolean()) - { + if (this.packet.readBoolean()) { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; @@ -24,24 +21,19 @@ public class LoveLockStartConfirmEvent extends MessageHandler if (item == null) return; - if (item instanceof InteractionLoveLock) - { + if (item instanceof InteractionLoveLock) { int userId = 0; - if (((InteractionLoveLock) item).userOneId == this.client.getHabbo().getHabboInfo().getId() && ((InteractionLoveLock) item).userTwoId != 0) - { + if (((InteractionLoveLock) item).userOneId == this.client.getHabbo().getHabboInfo().getId() && ((InteractionLoveLock) item).userTwoId != 0) { userId = ((InteractionLoveLock) item).userTwoId; - } else if (((InteractionLoveLock) item).userOneId != 0 && ((InteractionLoveLock) item).userTwoId == this.client.getHabbo().getHabboInfo().getId()) - { + } else if (((InteractionLoveLock) item).userOneId != 0 && ((InteractionLoveLock) item).userTwoId == this.client.getHabbo().getHabboInfo().getId()) { userId = ((InteractionLoveLock) item).userOneId; } - if (userId > 0) - { + if (userId > 0) { Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new LoveLockFurniFriendConfirmedComposer((InteractionLoveLock) item)); habbo.getClient().sendResponse(new LoveLockFurniFinishedComposer((InteractionLoveLock) item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceCancelEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceCancelEvent.java index 4be7617f..bc6bd3d2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceCancelEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceCancelEvent.java @@ -6,25 +6,21 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class RentSpaceCancelEvent extends MessageHandler -{ +public class RentSpaceCancelEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || - this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { - if(item instanceof InteractionRentableSpace) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || + this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { + if (item instanceof InteractionRentableSpace) { ((InteractionRentableSpace) item).endRent(); room.updateItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceEvent.java index 17445eca..1df3bd21 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentSpaceEvent.java @@ -5,21 +5,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class RentSpaceEvent extends MessageHandler -{ +public class RentSpaceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = room.getHabboItem(itemId); - if(!(item instanceof InteractionRentableSpace)) + if (!(item instanceof InteractionRentableSpace)) return; ((InteractionRentableSpace) item).rent(this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java index b68267df..3a3d505a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java @@ -7,24 +7,19 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; -public class YoutubeRequestNextVideoEvent extends MessageHandler -{ +public class YoutubeRequestNextVideoEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); int next = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item instanceof InteractionYoutubeTV) - { + if (item instanceof InteractionYoutubeTV) { YoutubeManager.YoutubeItem video = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getVideo(item.getBaseItem(), next); - if (video != null) - { + if (video != null) { this.client.sendResponse(new YoutubeVideoComposer(itemId, video)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java index 7cf6637b..d997a683 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java @@ -6,19 +6,15 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayListComposer; -public class YoutubeRequestPlayListEvent extends MessageHandler -{ +public class YoutubeRequestPlayListEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item instanceof InteractionYoutubeTV) - { + if (item instanceof InteractionYoutubeTV) { this.client.sendResponse(new YoutubeDisplayListComposer(itemId, Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylist(item.getBaseItem()))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java index f3f4c34b..0e1623c7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java @@ -7,24 +7,19 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; -public class YoutubeRequestVideoDataEvent extends MessageHandler -{ +public class YoutubeRequestVideoDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); String videoId = this.packet.readString(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item instanceof InteractionYoutubeTV) - { + if (item instanceof InteractionYoutubeTV) { YoutubeManager.YoutubeItem videoItem = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getVideo(item.getBaseItem(), videoId); - if (videoItem != null) - { + if (videoItem != null) { this.client.sendResponse(new YoutubeVideoComposer(itemId, videoItem)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedMonsterplantsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedMonsterplantsEvent.java index 19977bd1..a297244c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedMonsterplantsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedMonsterplantsEvent.java @@ -4,26 +4,21 @@ import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; -public class BreedMonsterplantsEvent extends MessageHandler -{ +public class BreedMonsterplantsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int unknownInt = this.packet.readInt(); //Something state. 2 = accept - if (unknownInt == 0) - { + if (unknownInt == 0) { Pet petOne = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); Pet petTwo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); - if (petOne == null || petTwo == null) - { + if (petOne == null || petTwo == null) { //TODO Add error return; } - if (petOne instanceof MonsterplantPet && petTwo instanceof MonsterplantPet) - { + if (petOne instanceof MonsterplantPet && petTwo instanceof MonsterplantPet) { ((MonsterplantPet) petOne).breed((MonsterplantPet) petTwo); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java index 4b362122..7a285f5d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java @@ -8,34 +8,26 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.AddFloorItemComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class CompostMonsterplantEvent extends MessageHandler -{ +public class CompostMonsterplantEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); Pet pet = room.getPet(petId); - if (pet != null) - { - if (pet instanceof MonsterplantPet) - { - if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { - if (((MonsterplantPet) pet).isDead()) - { + if (pet != null) { + if (pet instanceof MonsterplantPet) { + if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (((MonsterplantPet) pet).isDead()) { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem("mnstr_compost"); - if (baseItem != null) - { + if (baseItem != null) { HabboItem compost = Emulator.getGameEnvironment().getItemManager().createItem(pet.getUserId(), baseItem, 0, 0, ""); compost.setX(pet.getRoomUnit().getX()); compost.setY(pet.getRoomUnit().getY()); @@ -46,13 +38,10 @@ public class CompostMonsterplantEvent extends MessageHandler } pet.removeFromRoom(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_pets WHERE id = ? LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_pets WHERE id = ? LIMIT 1")) { statement.setInt(1, pet.getId()); statement.executeUpdate(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 12f03c9f..668ee248 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 @@ -4,12 +4,10 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class ConfirmPetBreedingEvent extends MessageHandler -{ +public class ConfirmPetBreedingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); String name = this.packet.readString(); int petOneId = this.packet.readInt(); @@ -17,9 +15,8 @@ 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); + if (item instanceof InteractionPetBreedingNest) { + ((InteractionPetBreedingNest) item).breed(this.client.getHabbo(), name, petOneId, petTwoId); } } } \ No newline at end of file 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 862fa58a..fdd98baf 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 @@ -6,27 +6,21 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class MovePetEvent extends MessageHandler -{ +public class MovePetEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); - if (pet != null) - { + if (pet != null) { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null && room.hasRights(this.client.getHabbo())) - { - if (pet.getRoomUnit() != null) - { + if (room != null && room.hasRights(this.client.getHabbo())) { + if (pet.getRoomUnit() != null) { int x = this.packet.readInt(); int y = this.packet.readInt(); - RoomTile tile = room.getLayout().getTile((short)x, (short)y); + RoomTile tile = room.getLayout().getTile((short) x, (short) y); - if (tile != null) - { + if (tile != null) { pet.getRoomUnit().setLocation(tile); pet.getRoomUnit().setPreviousLocation(tile); pet.getRoomUnit().setZ(this.packet.readInt() + tile.z); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java index 36893168..fd9617c1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java @@ -12,59 +12,46 @@ import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageNameValidationComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -public class PetPackageNameEvent extends MessageHandler -{ +public class PetPackageNameEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); String name = this.packet.readString(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { + if (room != null) { HabboItem item = room.getHabboItem(itemId); - if (item != null) - { - if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { - if (name.matches("^[a-zA-Z0-9]*$")) - { + if (item != null) { + if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (name.matches("^[a-zA-Z0-9]*$")) { Pet pet = null; - if (item.getBaseItem().getName().equalsIgnoreCase("val11_present")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("val11_present")) { pet = Emulator.getGameEnvironment().getPetManager().createPet(11, name, this.client); } - if (item.getBaseItem().getName().equalsIgnoreCase("gnome_box")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("gnome_box")) { pet = Emulator.getGameEnvironment().getPetManager().createGnome(name, room, this.client.getHabbo()); } - if (item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box")) { pet = Emulator.getGameEnvironment().getPetManager().createLeprechaun(name, room, this.client.getHabbo()); } - if (item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg")) { pet = Emulator.getGameEnvironment().getPetManager().createPet(34, name, this.client); } - if (item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg")) { pet = Emulator.getGameEnvironment().getPetManager().createPet(33, name, this.client); } - if (item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) - { + if (item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) { pet = Emulator.getGameEnvironment().getPetManager().createPet(32, name, this.client); } - if (pet != null) - { + if (pet != null) { room.placePet(pet, item.getX(), item.getY(), item.getZ(), item.getRotation()); pet.setUserId(this.client.getHabbo().getHabboInfo().getId()); pet.needsUpdate = true; @@ -77,14 +64,10 @@ public class PetPackageNameEvent extends MessageHandler room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); room.sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.relativeHeight()).compose()); item.setUserId(0); - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } - } - else - { + } else { this.client.sendResponse(new PetPackageNameValidationComposer(itemId, PetPackageNameValidationComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", ""))); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java index 12c7e41c..29dd53f6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java @@ -10,36 +10,30 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; -public class PetPickupEvent extends MessageHandler -{ +public class PetPickupEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Pet pet = room.getPet(petId); - if (pet != null) - { - if (this.client.getHabbo().getHabboInfo().getId() == pet.getId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { - if (this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= Emulator.getConfig().getInt("hotel.pets.max.inventory") && !this.client.getHabbo().hasPermission("acc_unlimited_pets")) - { + if (pet != null) { + if (this.client.getHabbo().getHabboInfo().getId() == pet.getId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { + if (this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= Emulator.getConfig().getInt("hotel.pets.max.inventory") && !this.client.getHabbo().hasPermission("acc_unlimited_pets")) { this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(Emulator.getTexts().getValue("error.pets.max.inventory"), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); return; } - if(pet instanceof RideablePet) { - RideablePet rideablePet = (RideablePet)pet; - if(rideablePet.getRider() != null) { + if (pet instanceof RideablePet) { + RideablePet rideablePet = (RideablePet) pet; + if (rideablePet.getRider() != null) { rideablePet.getRider().getHabboInfo().dismountPet(true); } } @@ -47,17 +41,13 @@ public class PetPickupEvent extends MessageHandler pet.removeFromRoom(); Emulator.getThreading().run(pet); - if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId()) - { + if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId()) { this.client.sendResponse(new AddPetComposer(pet)); this.client.getHabbo().getInventory().getPetsComponent().addPet(pet); - } - else - { + } else { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new AddPetComposer(pet)); habbo.getInventory().getPetsComponent().addPet(pet); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPlaceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPlaceEvent.java index f4dc1c81..b43f8ab7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPlaceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPlaceEvent.java @@ -9,18 +9,15 @@ import com.eu.habbo.messages.outgoing.generic.alerts.PetErrorComposer; import com.eu.habbo.messages.outgoing.inventory.RemovePetComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; -public class PetPlaceEvent extends MessageHandler -{ +public class PetPlaceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId() && !room.isAllowPets() && !(this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_placefurni"))) - { + if (this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId() && !room.isAllowPets() && !(this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_placefurni"))) { this.client.sendResponse(new PetErrorComposer(PetErrorComposer.ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT)); return; } @@ -29,12 +26,10 @@ public class PetPlaceEvent extends MessageHandler Pet pet = this.client.getHabbo().getInventory().getPetsComponent().getPet(petId); - if(pet == null) - { + if (pet == null) { return; } - if(room.getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermission("acc_unlimited_pets")) - { + if (room.getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermission("acc_unlimited_pets")) { this.client.sendResponse(new PetErrorComposer(PetErrorComposer.ROOM_ERROR_MAX_PETS)); return; } @@ -45,35 +40,28 @@ public class PetPlaceEvent extends MessageHandler RoomTile tile; RoomTile playerTile = this.client.getHabbo().getRoomUnit().getCurrentLocation(); - if ((x == 0 && y == 0) || !room.isOwner(this.client.getHabbo())) - { + if ((x == 0 && y == 0) || !room.isOwner(this.client.getHabbo())) { //Place the pet in front of the player. tile = room.getLayout().getTileInFront(this.client.getHabbo().getRoomUnit().getCurrentLocation(), this.client.getHabbo().getRoomUnit().getBodyRotation().getValue()); - if (tile == null || !tile.isWalkable()) - { + if (tile == null || !tile.isWalkable()) { this.client.sendResponse(new PetErrorComposer(PetErrorComposer.ROOM_ERROR_PETS_NO_FREE_TILES)); } //Check if tile exists and is walkable. Else place it in the current location the Habbo is standing. - if (tile == null || !tile.isWalkable()) - { + if (tile == null || !tile.isWalkable()) { tile = playerTile; //If the current tile is not walkable, place it at the door. - if (tile == null || !tile.isWalkable()) - { + if (tile == null || !tile.isWalkable()) { tile = room.getLayout().getDoorTile(); } } - } - else - { + } else { tile = room.getLayout().getTile((short) x, (short) y); } - if(tile == null || !tile.isWalkable() || !tile.getAllowStack()) - { + if (tile == null || !tile.isWalkable() || !tile.getAllowStack()) { this.client.sendResponse(new PetErrorComposer(PetErrorComposer.ROOM_ERROR_PETS_SELECTED_TILE_NOT_FREE)); return; } @@ -81,8 +69,7 @@ public class PetPlaceEvent extends MessageHandler pet.setRoom(room); RoomUnit roomUnit = pet.getRoomUnit(); - if(roomUnit == null) - { + if (roomUnit == null) { roomUnit = new RoomUnit(); } @@ -92,8 +79,7 @@ public class PetPlaceEvent extends MessageHandler roomUnit.setZ(tile.getStackHeight()); roomUnit.setStatus(RoomUnitStatus.SIT, "0"); roomUnit.setRoomUnitType(RoomUnitType.PET); - if (playerTile != null) - { + if (playerTile != null) { roomUnit.lookAtPoint(playerTile); } pet.setRoomUnit(roomUnit); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideEvent.java index 6b84a1c4..fd3a315a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideEvent.java @@ -2,53 +2,50 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; 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.messages.incoming.MessageHandler; import com.eu.habbo.threading.runnables.RoomUnitRidePet; + import java.util.List; -public class PetRideEvent extends MessageHandler -{ +public class PetRideEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); Habbo habbo = this.client.getHabbo(); Room room = habbo.getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Pet pet = room.getPet(petId); - if(!(pet instanceof RideablePet)) + if (!(pet instanceof RideablePet)) return; - RideablePet rideablePet = (RideablePet)pet; + RideablePet rideablePet = (RideablePet) pet; //dismount - if(habbo.getHabboInfo().getRiding() != null) - { + if (habbo.getHabboInfo().getRiding() != null) { habbo.getHabboInfo().dismountPet(); return; } // someone is already on it - if(rideablePet.getRider() != null) + if (rideablePet.getRider() != null) return; // check if able to ride - if(!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) + if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) return; List availableTiles = room.getLayout().getWalkableTilesAround(pet.getRoomUnit().getCurrentLocation()); // if cant reach it then cancel - if(availableTiles.isEmpty()) + if (availableTiles.isEmpty()) return; RoomTile goalTile = availableTiles.get(0); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideSettingsEvent.java index bc452af6..791a628b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetRideSettingsEvent.java @@ -6,19 +6,17 @@ import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer; -public class PetRideSettingsEvent extends MessageHandler -{ +public class PetRideSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; 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)) return; RideablePet rideablePet = ((RideablePet) pet); @@ -26,11 +24,11 @@ public class PetRideSettingsEvent extends MessageHandler rideablePet.setAnyoneCanRide(!rideablePet.anyoneCanRide()); rideablePet.needsUpdate = true; - if(!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { + if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { rideablePet.getRider().getHabboInfo().dismountPet(); } - if(pet instanceof HorsePet) { + if (pet instanceof HorsePet) { this.client.sendResponse(new RoomPetHorseFigureComposer((HorsePet) pet)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java index 6fd22971..2b597245 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java @@ -15,103 +15,78 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -public class PetUseItemEvent extends MessageHandler -{ +public class PetUseItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if(item == null) + if (item == null) return; int petId = this.packet.readInt(); Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); - if(pet instanceof HorsePet) - { - if(item.getBaseItem().getName().toLowerCase().startsWith("horse_dye")) - { + if (pet instanceof HorsePet) { + if (item.getBaseItem().getName().toLowerCase().startsWith("horse_dye")) { int race = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); int raceType = (race * 4) - 2; - if(race >= 13 && race <= 17) + if (race >= 13 && race <= 17) raceType = ((2 + race) * 4) + 1; - if(race == 0) + if (race == 0) raceType = 0; pet.setRace(raceType); ((HorsePet) pet).needsUpdate = true; - } - else if(item.getBaseItem().getName().toLowerCase().startsWith("horse_hairdye")) - { + } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairdye")) { int splittedHairdye = Integer.valueOf(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairdye = 48; - if(splittedHairdye == 0) - { + if (splittedHairdye == 0) { newHairdye = -1; - } - else if(splittedHairdye == 1) - { + } else if (splittedHairdye == 1) { newHairdye = 1; - } - else if(splittedHairdye >= 13 && splittedHairdye <= 17) - { + } else if (splittedHairdye >= 13 && splittedHairdye <= 17) { newHairdye = 68 + splittedHairdye; - } - else - { + } else { newHairdye += splittedHairdye; } ((HorsePet) pet).setHairColor(newHairdye); ((HorsePet) pet).needsUpdate = true; - } - else if(item.getBaseItem().getName().toLowerCase().startsWith("horse_hairstyle")) - { + } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairstyle")) { int splittedHairstyle = Integer.valueOf(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairstyle = 100; - if(splittedHairstyle == 0) - { + if (splittedHairstyle == 0) { newHairstyle = -1; - } - else - { + } else { newHairstyle += splittedHairstyle; } ((HorsePet) pet).setHairStyle(newHairstyle); ((HorsePet) pet).needsUpdate = true; - } - else if(item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) - { + } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) { ((HorsePet) pet).hasSaddle(true); ((HorsePet) pet).needsUpdate = true; } - if(((HorsePet) pet).needsUpdate) - { + if (((HorsePet) pet).needsUpdate) { Emulator.getThreading().run(pet); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomPetHorseFigureComposer((HorsePet) pet).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } - } - else if (pet instanceof MonsterplantPet) - { - if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_revival")) - { - if (((MonsterplantPet) pet).isDead()) - { + } else if (pet instanceof MonsterplantPet) { + if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_revival")) { + if (((MonsterplantPet) pet).isDead()) { ((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive); pet.getRoomUnit().clearStatus(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev"); @@ -126,11 +101,8 @@ public class PetUseItemEvent extends MessageHandler pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } - } - else if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_fert")) - { - if (!((MonsterplantPet) pet).isFullyGrown()) - { + } else if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_fert")) { + if (!((MonsterplantPet) pet).isFullyGrown()) { pet.setCreated(pet.getCreated() - MonsterplantPet.growTime); pet.getRoomUnit().clearStatus(); pet.cycle(); @@ -145,16 +117,13 @@ public class PetUseItemEvent extends MessageHandler pet.cycle(); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } - } - else if (item.getBaseItem().getName().startsWith("mnstr_rebreed")) - { - if (((MonsterplantPet) pet).isFullyGrown() && !((MonsterplantPet) pet).canBreed()) - { + } else if (item.getBaseItem().getName().startsWith("mnstr_rebreed")) { + if (((MonsterplantPet) pet).isFullyGrown() && !((MonsterplantPet) pet).canBreed()) { if ( - (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed") && ((MonsterplantPet) pet).getRarity() <= 5) || - (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed_2") && ((MonsterplantPet) pet).getRarity() >= 6 && ((MonsterplantPet) pet).getRarity() <= 8) || - (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed_3") && ((MonsterplantPet) pet).getRarity() >= 9) - ) + (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed") && ((MonsterplantPet) pet).getRarity() <= 5) || + (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed_2") && ((MonsterplantPet) pet).getRarity() >= 6 && ((MonsterplantPet) pet).getRarity() <= 8) || + (item.getBaseItem().getName().equalsIgnoreCase("mnstr_rebreed_3") && ((MonsterplantPet) pet).getRarity() >= 9) + ) { ((MonsterplantPet) pet).setCanBreed(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetInformationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetInformationEvent.java index 11c71438..e1d86884 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetInformationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetInformationEvent.java @@ -5,22 +5,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.pets.PetInformationComposer; -public class RequestPetInformationEvent extends MessageHandler -{ +public class RequestPetInformationEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Pet pet = room.getPet(petId); - if(pet != null) - { + if (pet != null) { this.client.sendResponse(new PetInformationComposer(pet, room, this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetTrainingPanelEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetTrainingPanelEvent.java index 3b619402..bac9fd20 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetTrainingPanelEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RequestPetTrainingPanelEvent.java @@ -4,19 +4,17 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.pets.PetTrainingPanelComposer; -public class RequestPetTrainingPanelEvent extends MessageHandler -{ +public class RequestPetTrainingPanelEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); - if(pet != null) + if (pet != null) this.client.sendResponse(new PetTrainingPanelComposer(pet)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java index 89dd8393..6189f3e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java @@ -4,22 +4,18 @@ import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; -public class ScratchPetEvent extends MessageHandler -{ +public class ScratchPetEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); - if(pet != null) - { - if(this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) - { + if (pet != null) { + if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) { pet.scratched(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java index b795872f..4370231e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java @@ -4,17 +4,14 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class StopBreedingEvent extends MessageHandler -{ +public class StopBreedingEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item instanceof InteractionPetBreedingNest) - { + if (item instanceof InteractionPetBreedingNest) { ((InteractionPetBreedingNest) item).stopBreeding(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ToggleMonsterplantBreedableEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ToggleMonsterplantBreedableEvent.java index 05a17011..3cbc2d0d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ToggleMonsterplantBreedableEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ToggleMonsterplantBreedableEvent.java @@ -4,21 +4,16 @@ import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; -public class ToggleMonsterplantBreedableEvent extends MessageHandler -{ +public class ToggleMonsterplantBreedableEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int petId = this.packet.readInt(); Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); - if (pet != null) - { - if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) - { - if (pet instanceof MonsterplantPet) - { + if (pet != null) { + if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (pet instanceof MonsterplantPet) { ((MonsterplantPet) pet).setPubliclyBreedable(((MonsterplantPet) pet).isPubliclyBreedable()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java index 877fc2a8..948d0b08 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java @@ -9,11 +9,9 @@ import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; -public class BuyRoomPromotionEvent extends MessageHandler -{ +public class BuyRoomPromotionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int pageId = this.packet.readInt(); int itemId = this.packet.readInt(); int roomId = this.packet.readInt(); @@ -24,39 +22,30 @@ public class BuyRoomPromotionEvent extends MessageHandler CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId); - if(page != null) - { + if (page != null) { CatalogItem item = page.getCatalogItem(itemId); - if(item != null) - { - if(this.client.getHabbo().getHabboInfo().canBuy(item)) - { + if (item != null) { + if (this.client.getHabbo().getHabboInfo().canBuy(item)) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if (!(room.isOwner(this.client.getHabbo()) || room.hasRights(this.client.getHabbo()) || room.guildRightLevel(this.client.getHabbo()) == 3)) - { + if (!(room.isOwner(this.client.getHabbo()) || room.hasRights(this.client.getHabbo()) || room.guildRightLevel(this.client.getHabbo()) == 3)) { return; } - if (room.isPromoted()) - { + if (room.isPromoted()) { room.getPromotion().addEndTimestamp(120 * 60); - } else - { + } else { room.createPromotion(title, description); } - if(room.isPromoted()) - { + if (room.isPromoted()) { if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) this.client.getHabbo().giveCredits(-item.getCredits()); if (!this.client.getHabbo().hasPermission("acc_infinite_points")) this.client.getHabbo().givePoints(item.getPointsType(), -item.getPoints()); this.client.sendResponse(new PurchaseOKComposer()); room.sendComposer(new RoomPromotionMessageComposer(room, room.getPromotion()).compose()); - } - else - { + } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/RequestPromotionRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/RequestPromotionRoomsEvent.java index 32909f90..3ece7382 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/RequestPromotionRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/RequestPromotionRoomsEvent.java @@ -7,11 +7,9 @@ import com.eu.habbo.messages.outgoing.rooms.promotions.PromoteOwnRoomsListCompos import java.util.List; -public class RequestPromotionRoomsEvent extends MessageHandler -{ +public class RequestPromotionRoomsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { List roomsToShow = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()); roomsToShow.addAll(Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(this.client.getHabbo())); roomsToShow.addAll(Emulator.getGameEnvironment().getRoomManager().getRoomsWithAdminRights(this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/UpdateRoomPromotionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/UpdateRoomPromotionEvent.java index 59d27574..22d8900e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/UpdateRoomPromotionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/UpdateRoomPromotionEvent.java @@ -8,12 +8,10 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; -public class UpdateRoomPromotionEvent extends MessageHandler -{ +public class UpdateRoomPromotionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int id = this.packet.readInt(); String promotionName = this.packet.readString(); @@ -21,15 +19,13 @@ public class UpdateRoomPromotionEvent extends MessageHandler Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(id); - if (room == null || room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room == null || room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { return; } RoomPromotion roomPromotion = room.getPromotion(); - if (roomPromotion != null) - { + if (roomPromotion != null) { roomPromotion.setTitle(promotionName); roomPromotion.setDescription(promotionDescription); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreRoomUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreRoomUserEvent.java index 335c7e09..2cd65c81 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreRoomUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreRoomUserEvent.java @@ -7,22 +7,18 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserIgnoredComposer; -public class IgnoreRoomUserEvent extends MessageHandler -{ +public class IgnoreRoomUserEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { String username = this.packet.readString(); Habbo habbo = room.getHabbo(username); - if(habbo != null) - { - if(habbo == this.client.getHabbo()) + if (habbo != null) { + if (habbo == this.client.getHabbo()) return; { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RequestRoomUserTagsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RequestRoomUserTagsEvent.java index 3e72bf39..1cd6777c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RequestRoomUserTagsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RequestRoomUserTagsEvent.java @@ -4,19 +4,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTagsComposer; -public class RequestRoomUserTagsEvent extends MessageHandler -{ +public class RequestRoomUserTagsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int roomUnitId = this.packet.readInt(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboByRoomUnitId(roomUnitId); - if(habbo != null) - { + if (habbo != null) { this.client.sendResponse(new RoomUserTagsComposer(habbo)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java index 6e2911a1..41c29f25 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java @@ -8,22 +8,17 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; -public class RoomUserActionEvent extends MessageHandler -{ +public class RoomUserActionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { Habbo habbo = this.client.getHabbo(); - if(this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) - { - habbo = (Habbo)this.client.getHabbo().getRoomUnit().getCacheable().get("control"); + if (this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) { + habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if(habbo.getHabboInfo().getCurrentRoom() != room) - { + if (habbo.getHabboInfo().getCurrentRoom() != room) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -32,32 +27,23 @@ public class RoomUserActionEvent extends MessageHandler int action = this.packet.readInt(); - if(action == 5) - { + if (action == 5) { UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.ACTION, true); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (event.idle) - { + if (!event.isCancelled()) { + if (event.idle) { room.idle(habbo); - } - else - { + } else { room.unIdle(habbo); } } - } - else - { + } else { UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.ACTION, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { room.unIdle(habbo); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserBanEvent.java index 1519abe7..d806fd39 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserBanEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomUserBanEvent extends MessageHandler -{ +public class RoomUserBanEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); int roomId = this.packet.readInt(); String banName = this.packet.readString(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java index 160bf592..bafd54dd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java @@ -9,25 +9,20 @@ import com.eu.habbo.plugin.events.users.UserIdleEvent; public class RoomUserDanceEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; int danceId = this.packet.readInt(); - if(danceId >= 0 && danceId <= 5) - { - if (this.client.getHabbo().getRoomUnit().isInRoom()) - { + if (danceId >= 0 && danceId <= 5) { + if (this.client.getHabbo().getRoomUnit().isInRoom()) { Habbo habbo = this.client.getHabbo(); - if(this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) - { - habbo = (Habbo)this.client.getHabbo().getRoomUnit().getCacheable().get("control"); + if (this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) { + habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if(habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) - { + if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -39,10 +34,8 @@ public class RoomUserDanceEvent extends MessageHandler { UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.DANCE, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(habbo); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDropHandItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDropHandItemEvent.java index b54fc760..c57318cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDropHandItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDropHandItemEvent.java @@ -4,15 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserHandItemComposer; -public class RoomUserDropHandItemEvent extends MessageHandler -{ +public class RoomUserDropHandItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); this.client.getHabbo().getRoomUnit().setHandItem(0); - if(room != null) - { + if (room != null) { room.unIdle(this.client.getHabbo()); room.sendComposer(new RoomUserHandItemComposer(this.client.getHabbo().getRoomUnit()).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveHandItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveHandItemEvent.java index 8a53fa7a..9342e045 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveHandItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveHandItemEvent.java @@ -10,21 +10,17 @@ import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit; import java.util.ArrayList; import java.util.List; -public class RoomUserGiveHandItemEvent extends MessageHandler -{ +public class RoomUserGiveHandItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { Habbo target = room.getHabbo(userId); - if(target != null) - { + if (target != null) { List executable = new ArrayList<>(); executable.add(new HabboGiveHandItemToHabbo(this.client.getHabbo(), target)); Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.client.getHabbo().getRoomUnit(), target.getRoomUnit(), this.client.getHabbo().getHabboInfo().getCurrentRoom(), executable, executable)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java index 4ec51ba3..d2a46a40 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java @@ -5,19 +5,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserRespectedEvent; -public class RoomUserGiveRespectEvent extends MessageHandler -{ +public class RoomUserGiveRespectEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); - if(this.client.getHabbo().getHabboStats().respectPointsToGive > 0) - { + if (this.client.getHabbo().getHabboStats().respectPointsToGive > 0) { Habbo target = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); - if(Emulator.getPluginManager().isRegistered(UserRespectedEvent.class, false)) { - if(Emulator.getPluginManager().fireEvent(new UserRespectedEvent(target, this.client.getHabbo())).isCancelled()) + if (Emulator.getPluginManager().isRegistered(UserRespectedEvent.class, false)) { + if (Emulator.getPluginManager().fireEvent(new UserRespectedEvent(target, this.client.getHabbo())).isCancelled()) return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRightsEvent.java index 97d88e78..479b0612 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRightsEvent.java @@ -8,35 +8,27 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserRightsGivenEvent; -public class RoomUserGiveRightsEvent extends MessageHandler -{ +public class RoomUserGiveRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { Habbo target = room.getHabbo(userId); - if (target != null) - { - if (!Emulator.getPluginManager().fireEvent(new UserRightsGivenEvent(this.client.getHabbo(), target)).isCancelled()) - { + if (target != null) { + if (!Emulator.getPluginManager().fireEvent(new UserRightsGivenEvent(this.client.getHabbo(), target)).isCancelled()) { room.giveRights(target); } - } - else - { + } else { MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(userId); - if (buddy != null) - { + if (buddy != null) { room.giveRights(userId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java index 2bcb2981..210a8d94 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java @@ -11,42 +11,37 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import com.eu.habbo.plugin.events.users.UserKickEvent; -public class RoomUserKickEvent extends MessageHandler -{ +public class RoomUserKickEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; int userId = this.packet.readInt(); Habbo target = room.getHabbo(userId); - if(target == null) + if (target == null) return; - if (target.hasPermission(Permission.ACC_UNKICKABLE)) - { + if (target.hasPermission(Permission.ACC_UNKICKABLE)) { this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(Emulator.getTexts().getValue("commands.error.cmd_kick.unkickable").replace("%username%", target.getHabboInfo().getUsername()), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); return; } - if (room.isOwner(target)) - { + if (room.isOwner(target)) { return; } UserKickEvent event = new UserKickEvent(this.client.getHabbo(), target); Emulator.getPluginManager().fireEvent(event); - if(event.isCancelled()) + if (event.isCancelled()) return; - if(room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_ambassador")) - { + if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_ambassador")) { if (target.hasPermission(Permission.ACC_UNKICKABLE)) return; room.kickHabbo(target, true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java index ed8ddca5..817c7ef7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java @@ -10,23 +10,19 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; -public class RoomUserLookAtPoint extends MessageHandler -{ +public class RoomUserLookAtPoint extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; Habbo habbo = this.client.getHabbo(); - if(habbo.getRoomUnit().getCacheable().get("control") != null) - { - habbo = (Habbo)this.client.getHabbo().getRoomUnit().getCacheable().get("control"); + if (habbo.getRoomUnit().getCacheable().get("control") != null) { + habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if(habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) - { + if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -35,10 +31,10 @@ public class RoomUserLookAtPoint extends MessageHandler RoomUnit roomUnit = habbo.getRoomUnit(); - if(!roomUnit.canWalk()) + if (!roomUnit.canWalk()) return; - if(roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) + if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) return; if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY)) @@ -47,22 +43,19 @@ public class RoomUserLookAtPoint extends MessageHandler int x = this.packet.readInt(); int y = this.packet.readInt(); - if(x == roomUnit.getX() && y == roomUnit.getY()) + if (x == roomUnit.getX() && y == roomUnit.getY()) return; RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); - if (tile != null) - { + if (tile != null) { roomUnit.lookAtPoint(tile); UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { room.unIdle(habbo); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java index ef5a6861..7c6a770c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java @@ -7,25 +7,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; -public class RoomUserMuteEvent extends MessageHandler -{ +public class RoomUserMuteEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); int roomId = this.packet.readInt(); int minutes = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if (room != null) - { - if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("cmd_mute") || this.client.getHabbo().hasPermission("acc_ambassador")) - { + if (room != null) { + if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermission("cmd_mute") || this.client.getHabbo().hasPermission("acc_ambassador")) { Habbo habbo = room.getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { room.muteHabbo(habbo, minutes); habbo.getClient().sendResponse(new MutedWhisperComposer(minutes * 60)); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModMuteSeen")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserRemoveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserRemoveRightsEvent.java index f7632fc4..cc03c734 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserRemoveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserRemoveRightsEvent.java @@ -4,22 +4,18 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class RoomUserRemoveRightsEvent extends MessageHandler -{ +public class RoomUserRemoveRightsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int amount = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) - { - for(int i = 0; i < amount; i++) - { + if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { + for (int i = 0; i < amount; i++) { int userId = this.packet.readInt(); room.removeRights(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java index 2bcc3528..3e217e75 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java @@ -7,39 +7,31 @@ import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; -public class RoomUserShoutEvent extends MessageHandler -{ +public class RoomUserShoutEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; - if(!this.client.getHabbo().getHabboStats().allowTalk()) + if (!this.client.getHabbo().getHabboStats().allowTalk()) return; RoomChatMessage message = new RoomChatMessage(this); - if (message.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) - { - if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), message, RoomChatType.SHOUT)).isCancelled()) - { + if (message.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) { + if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), message, RoomChatType.SHOUT)).isCancelled()) { return; } this.client.getHabbo().getHabboInfo().getCurrentRoom().talk(this.client.getHabbo(), message, RoomChatType.SHOUT); - if (!message.isCommand) - { - if (RoomChatMessage.SAVE_ROOM_CHATS) - { + if (!message.isCommand) { + if (RoomChatMessage.SAVE_ROOM_CHATS) { Emulator.getThreading().run(message); } } - } - else - { + } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); Emulator.getLogging().logUserLine(reportMessage); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java index c7460f94..3e1200e6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java @@ -13,12 +13,11 @@ public class RoomUserSignEvent extends MessageHandler { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); - if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) - { + if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + ""); this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java index 8f46fdfb..f3c8df7f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java @@ -4,15 +4,11 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserIdleEvent; -public class RoomUserSitEvent extends MessageHandler -{ +public class RoomUserSitEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - if(this.client.getHabbo().getRoomUnit().isWalking()) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (this.client.getHabbo().getRoomUnit().isWalking()) { this.client.getHabbo().getRoomUnit().stopWalking(); } this.client.getHabbo().getHabboInfo().getCurrentRoom().makeSit(this.client.getHabbo()); @@ -20,10 +16,8 @@ public class RoomUserSitEvent extends MessageHandler UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) - { - if (!event.idle) - { + if (!event.isCancelled()) { + if (!event.idle) { this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStartTypingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStartTypingEvent.java index cd82360a..94f471a2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStartTypingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStartTypingEvent.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTypingComposer; -public class RoomUserStartTypingEvent extends MessageHandler -{ +public class RoomUserStartTypingEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) { return; } - if(this.client.getHabbo().getRoomUnit() == null) - { + if (this.client.getHabbo().getRoomUnit() == null) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStopTypingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStopTypingEvent.java index 383ba385..0b9e02d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStopTypingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserStopTypingEvent.java @@ -3,18 +3,14 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTypingComposer; -public class RoomUserStopTypingEvent extends MessageHandler -{ +public class RoomUserStopTypingEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) { return; } - if(this.client.getHabbo().getRoomUnit() == null) - { + if (this.client.getHabbo().getRoomUnit() == null) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java index f5aa92d4..a3debf17 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java @@ -11,36 +11,29 @@ import com.eu.habbo.plugin.events.users.UserTalkEvent; public class RoomUserTalkEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; - if(!this.client.getHabbo().getHabboStats().allowTalk()) + if (!this.client.getHabbo().getHabboStats().allowTalk()) return; RoomChatMessage message = new RoomChatMessage(this); - if (message.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) - { - if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), message, RoomChatType.TALK)).isCancelled()) - { + if (message.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) { + if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), message, RoomChatType.TALK)).isCancelled()) { return; } room.talk(this.client.getHabbo(), message, RoomChatType.TALK); - if (!message.isCommand) - { - if (RoomChatMessage.SAVE_ROOM_CHATS) - { + if (!message.isCommand) { + if (RoomChatMessage.SAVE_ROOM_CHATS) { Emulator.getThreading().run(message); } } - } - else - { + } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); Emulator.getLogging().logUserLine(reportMessage); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 41999947..0d798aaf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -9,13 +9,10 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; -public class RoomUserWalkEvent extends MessageHandler -{ +public class RoomUserWalkEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { int x = this.packet.readInt(); int y = this.packet.readInt(); @@ -28,12 +25,10 @@ public class RoomUserWalkEvent extends MessageHandler if (roomUnit.isKicked) return; - if (roomUnit.getCacheable().get("control") != null) - { + if (roomUnit.getCacheable().get("control") != null) { habbo = (Habbo) roomUnit.getCacheable().get("control"); - if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) - { + if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -42,12 +37,9 @@ public class RoomUserWalkEvent extends MessageHandler roomUnit = habbo.getRoomUnit(); - try - { - if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) - { - if (!roomUnit.cmdTeleport) - { + try { + if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) { + if (!roomUnit.cmdTeleport) { if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) return; @@ -59,35 +51,27 @@ public class RoomUserWalkEvent extends MessageHandler RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); - if (tile == null) - { + if (tile == null) { return; } - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) - { + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { if (habbo.getHabboInfo().getCurrentRoom().getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) return; } - if (tile.isWalkable() || habbo.getHabboInfo().getCurrentRoom().canSitOrLayAt(tile.x, tile.y)) - { + if (tile.isWalkable() || habbo.getHabboInfo().getCurrentRoom().canSitOrLayAt(tile.x, tile.y)) { roomUnit.setGoalLocation(tile); } - } - else - { + } else { RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, habbo.getHabboInfo().getCurrentRoom()).compose()); - if (habbo.getHabboInfo().getRiding() != null) - { + if (habbo.getHabboInfo().getRiding() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, habbo.getHabboInfo().getCurrentRoom()).compose()); } } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java index 9455dcac..7a35384e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java @@ -7,35 +7,28 @@ import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; -public class RoomUserWhisperEvent extends MessageHandler -{ +public class RoomUserWhisperEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + public void handle() throws Exception { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; RoomChatMessage chatMessage = new RoomChatMessage(this); - if (chatMessage.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) - { + if (chatMessage.getMessage().length() <= RoomChatMessage.MAXIMUM_LENGTH) { if (!this.client.getHabbo().getHabboStats().allowTalk() || chatMessage.getTargetHabbo() == null) return; - if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER)).isCancelled()) - { + if (Emulator.getPluginManager().fireEvent(new UserTalkEvent(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER)).isCancelled()) { return; } this.client.getHabbo().getHabboInfo().getCurrentRoom().talk(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER, true); - if (RoomChatMessage.SAVE_ROOM_CHATS) - { + if (RoomChatMessage.SAVE_ROOM_CHATS) { Emulator.getThreading().run(chatMessage); } - } - else - { + } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", chatMessage.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); Emulator.getLogging().logUserLine(reportMessage); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnIgnoreRoomUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnIgnoreRoomUserEvent.java index dd5a3435..39f131eb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnIgnoreRoomUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnIgnoreRoomUserEvent.java @@ -5,23 +5,18 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserIgnoredComposer; -public class UnIgnoreRoomUserEvent extends MessageHandler -{ +public class UnIgnoreRoomUserEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { + if (room != null) { String username = this.packet.readString(); Habbo habbo = room.getHabbo(username); - if(habbo != null) - { - if(habbo.getHabboStats().allowTalk()) - { + if (habbo != null) { + if (habbo.getHabboStats().allowTalk()) { this.client.getHabbo().getHabboStats().unignoreUser(habbo.getHabboInfo().getId()); this.client.sendResponse(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanRoomUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanRoomUserEvent.java index 8eb488fe..a0eebffb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanRoomUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanRoomUserEvent.java @@ -4,20 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -public class UnbanRoomUserEvent extends MessageHandler -{ +public class UnbanRoomUserEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); - if(room != null) - { - if(room.isOwner(this.client.getHabbo())) - { + if (room != null) { + if (room.isOwner(this.client.getHabbo())) { room.unbanHabbo(userId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeAcceptEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeAcceptEvent.java index 8a747f0a..af4c1373 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeAcceptEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeAcceptEvent.java @@ -4,19 +4,17 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeAcceptEvent extends MessageHandler -{ +public class TradeAcceptEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Habbo habbo = this.client.getHabbo(); - if(habbo == null || habbo.getHabboInfo() == null || habbo.getHabboInfo().getCurrentRoom() == null) + if (habbo == null || habbo.getHabboInfo() == null || habbo.getHabboInfo().getCurrentRoom() == null) return; RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); - if(trade == null) + if (trade == null) return; trade.accept(habbo, true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelEvent.java index 2d86136b..b02656bd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelEvent.java @@ -5,20 +5,18 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeCancelEvent extends MessageHandler -{ +public class TradeCancelEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Habbo habbo = this.client.getHabbo(); Room room = habbo.getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; RoomTrade trade = room.getActiveTradeForHabbo(habbo); - if(trade == null) + if (trade == null) return; trade.stopTrade(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelOfferItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelOfferItemEvent.java index 5c795198..94ee24a2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelOfferItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCancelOfferItemEvent.java @@ -4,20 +4,16 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeCancelOfferItemEvent extends MessageHandler -{ +public class TradeCancelOfferItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); - if (trade != null) - { + 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()).getAccepted() && item != null) { trade.removeItem(this.client.getHabbo(), item); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCloseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCloseEvent.java index dc8db6b5..b6ff3e39 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCloseEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeCloseEvent.java @@ -5,20 +5,18 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeCloseEvent extends MessageHandler -{ +public class TradeCloseEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Habbo habbo = this.client.getHabbo(); Room room = habbo.getHabboInfo().getCurrentRoom(); - if(room == null) + if (room == null) return; RoomTrade trade = room.getActiveTradeForHabbo(habbo); - if(trade == null) + if (trade == null) return; trade.stopTrade(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeConfirmEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeConfirmEvent.java index 6ed9a209..94fa15b7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeConfirmEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeConfirmEvent.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeConfirmEvent extends MessageHandler -{ +public class TradeConfirmEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { 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).getAccepted()) return; trade.confirm(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferItemEvent.java index 41483c50..25fb39cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferItemEvent.java @@ -4,22 +4,20 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeOfferItemEvent extends MessageHandler -{ +public class TradeOfferItemEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); - if(trade == null) + if (trade == null) return; HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if(item == null) + if (item == null) return; trade.offerItem(this.client.getHabbo(), item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferMultipleItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferMultipleItemsEvent.java index 19cd701e..098345e4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferMultipleItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeOfferMultipleItemsEvent.java @@ -5,31 +5,27 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import gnu.trove.set.hash.THashSet; -public class TradeOfferMultipleItemsEvent extends MessageHandler -{ +public class TradeOfferMultipleItemsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) return; RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); - if(trade == null) + if (trade == null) return; THashSet items = new THashSet<>(); - + int count = this.packet.readInt(); - for(int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if(item != null) - { + if (item != null) { items.add(item); } } - + trade.offerMultipleItems(this.client.getHabbo(), items); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeStartEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeStartEvent.java index dab61882..c9c5cdb5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeStartEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeStartEvent.java @@ -8,62 +8,46 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.trading.TradeStartFailComposer; -public class TradeStartEvent extends MessageHandler -{ +public class TradeStartEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastTradeTimestamp > 10) - { + public void handle() throws Exception { + if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastTradeTimestamp > 10) { this.client.getHabbo().getHabboStats().lastTradeTimestamp = Emulator.getIntUnixTimestamp(); int userId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) - { - if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getId()) - { + if (room != null) { + if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getId()) { Habbo targetUser = room.getHabboByRoomUnitId(userId); boolean tradeAnywhere = this.client.getHabbo().hasPermission("acc_trade_anywhere"); - if (!RoomTrade.TRADING_ENABLED && !tradeAnywhere) - { + if (!RoomTrade.TRADING_ENABLED && !tradeAnywhere) { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.HOTEL_TRADING_NOT_ALLOWED)); return; } - if ((room.getTradeMode() == 0 || (room.getTradeMode() == 1 && this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId())) && !tradeAnywhere) - { + if ((room.getTradeMode() == 0 || (room.getTradeMode() == 1 && this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId())) && !tradeAnywhere) { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.ROOM_TRADING_NOT_ALLOWED)); return; } - if (targetUser != null) - { - if (!this.client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) - { - if (this.client.getHabbo().getHabboStats().allowTrade()) - { - if (!targetUser.getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) - { - if (targetUser.getHabboStats().allowTrade()) - { + if (targetUser != null) { + if (!this.client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) { + if (this.client.getHabbo().getHabboStats().allowTrade()) { + if (!targetUser.getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) { + if (targetUser.getHabboStats().allowTrade()) { room.startTrade(this.client.getHabbo(), targetUser); - } else - { + } else { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.TARGET_TRADING_NOT_ALLOWED, targetUser.getHabboInfo().getUsername())); } - } else - { + } else { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.TARGET_ALREADY_TRADING, targetUser.getHabboInfo().getUsername())); } - } else - { + } else { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.YOU_TRADING_OFF)); } - } else - { + } else { this.client.sendResponse(new TradeStartFailComposer(TradeStartFailComposer.YOU_ALREADY_TRADING)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeUnAcceptEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeUnAcceptEvent.java index f74f2dc5..138c375d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradeUnAcceptEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradeUnAcceptEvent.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -public class TradeUnAcceptEvent extends MessageHandler -{ +public class TradeUnAcceptEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { Habbo habbo = this.client.getHabbo(); RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); - if(trade == null) + if (trade == null) return; trade.accept(habbo, false); diff --git a/src/main/java/com/eu/habbo/messages/incoming/unknown/RequestResolutionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/unknown/RequestResolutionEvent.java index 2cd23bc3..a076e7c8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/unknown/RequestResolutionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/unknown/RequestResolutionEvent.java @@ -3,16 +3,13 @@ package com.eu.habbo.messages.incoming.unknown; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.events.resolution.NewYearResolutionComposer; -public class RequestResolutionEvent extends MessageHandler -{ +public class RequestResolutionEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); int viewAll = this.packet.readInt(); - if(viewAll == 0) - { + if (viewAll == 0) { this.client.sendResponse(new NewYearResolutionComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent1.java b/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent1.java index cc23a0f9..442406fb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent1.java +++ b/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent1.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.unknown; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.unknown.IgnoredUsersComposer; -public class UnknownEvent1 extends MessageHandler -{ +public class UnknownEvent1 extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new IgnoredUsersComposer()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent2.java b/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent2.java index f4079259..417a56c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent2.java +++ b/src/main/java/com/eu/habbo/messages/incoming/unknown/UnknownEvent2.java @@ -2,10 +2,8 @@ package com.eu.habbo.messages.incoming.unknown; import com.eu.habbo.messages.incoming.MessageHandler; -public class UnknownEvent2 extends MessageHandler -{ +public class UnknownEvent2 extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ActivateEffectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ActivateEffectEvent.java index 1dfa4de8..526da5ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ActivateEffectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ActivateEffectEvent.java @@ -2,15 +2,12 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; -public class ActivateEffectEvent extends MessageHandler -{ +public class ActivateEffectEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int effectId = this.packet.readInt(); - if (this.client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) - { + if (this.client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) { this.client.getHabbo().getInventory().getEffectsComponent().activateEffect(effectId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeChatBubbleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeChatBubbleEvent.java index 7f671f3b..7557b387 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeChatBubbleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeChatBubbleEvent.java @@ -4,19 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.messages.incoming.MessageHandler; -public class ChangeChatBubbleEvent extends MessageHandler -{ +public class ChangeChatBubbleEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int chatBubble = this.packet.readInt(); - if(!this.client.getHabbo().hasPermission("acc_anychatcolor")) - { - for(String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) - { - if(Integer.valueOf(s) == chatBubble) - { + if (!this.client.getHabbo().hasPermission("acc_anychatcolor")) { + for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { + if (Integer.valueOf(s) == chatBubble) { return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java index 8467d889..e640009d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java @@ -9,20 +9,17 @@ import com.eu.habbo.messages.outgoing.users.ChangeNameCheckResultComposer; import java.util.ArrayList; import java.util.List; -public class ChangeNameCheckUsernameEvent extends MessageHandler -{ +public class ChangeNameCheckUsernameEvent extends MessageHandler { public static final String VALID_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."; @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (!this.client.getHabbo().getHabboStats().allowNameChange) return; String name = this.packet.readString(); - if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) - { + if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) { this.client.getHabbo().getHabboStats().allowNameChange = false; this.client.sendResponse(new RoomUserNameChangedComposer(this.client.getHabbo())); return; @@ -31,43 +28,28 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler int errorCode = ChangeNameCheckResultComposer.AVAILABLE; List suggestions = new ArrayList<>(4); - if (false) - { - } - else if (name.length() < 3) - { + if (false) { + } else if (name.length() < 3) { errorCode = ChangeNameCheckResultComposer.TOO_SHORT; - } - else if (name.length() > 15) - { + } else if (name.length() > 15) { errorCode = ChangeNameCheckResultComposer.TOO_LONG; - } - else if (HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) - { + } else if (HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) { errorCode = ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS; suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999)); - } - else if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equalsIgnoreCase(name)) - { + } else if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equalsIgnoreCase(name)) { errorCode = ChangeNameCheckResultComposer.NOT_VALID; - } - else - { + } else { String checkName = name.toUpperCase(); - for (char c : VALID_CHARACTERS.toCharArray()) - { + for (char c : VALID_CHARACTERS.toCharArray()) { checkName = checkName.replace(c + "", ""); } - if (!checkName.isEmpty()) - { + if (!checkName.isEmpty()) { errorCode = ChangeNameCheckResultComposer.NOT_VALID; - } - else - { + } else { this.client.getHabbo().getHabboStats().changeNameChecked = name; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java index 1c2c9ed7..dc75d455 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java @@ -17,20 +17,17 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class ConfirmChangeNameEvent extends MessageHandler -{ +public class ConfirmChangeNameEvent extends MessageHandler { public static final List changingUsernames = new ArrayList<>(2); @Override - public void handle() throws Exception - { + public void handle() throws Exception { if (!this.client.getHabbo().getHabboStats().allowNameChange) return; String name = this.packet.readString(); - if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) - { + if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) { this.client.getHabbo().getHabboStats().allowNameChange = false; this.client.sendResponse(new ChangeNameUpdatedComposer(this.client.getHabbo())); this.client.sendResponse(new RoomUserNameChangedComposer(this.client.getHabbo()).compose()); @@ -38,14 +35,11 @@ public class ConfirmChangeNameEvent extends MessageHandler return; } - if (name.equals(this.client.getHabbo().getHabboStats().changeNameChecked)) - { + if (name.equals(this.client.getHabbo().getHabboStats().changeNameChecked)) { HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(name); - if (habboInfo == null) - { - synchronized (changingUsernames) - { + if (habboInfo == null) { + synchronized (changingUsernames) { if (changingUsernames.contains(name)) return; @@ -58,47 +52,37 @@ public class ConfirmChangeNameEvent extends MessageHandler this.client.getHabbo().getHabboInfo().run(); Emulator.getPluginManager().fireEvent(new UserNameChangedEvent(this.client.getHabbo(), oldName)); - for (Room room : Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo())) - { + for (Room room : Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo())) { room.setOwnerName(name); room.setNeedsUpdate(true); room.save(); } - synchronized (changingUsernames) - { + synchronized (changingUsernames) { changingUsernames.remove(name); } this.client.sendResponse(new ChangeNameUpdatedComposer(this.client.getHabbo())); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserNameChangedComposer(this.client.getHabbo()).compose()); - } - else - { + } else { this.client.sendResponse(new RoomUserNameChangedComposer(this.client.getHabbo()).compose()); } this.client.getHabbo().getMessenger().connectionChanged(this.client.getHabbo(), true, this.client.getHabbo().getHabboInfo().getCurrentRoom() != null); this.client.getHabbo().getClient().sendResponse(new UserDataComposer(this.client.getHabbo())); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO namechange_log (user_id, old_name, new_name, timestamp) VALUES (?, ?, ?, ?) ")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO namechange_log (user_id, old_name, new_name, timestamp) VALUES (?, ?, ?, ?) ")) { statement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); statement.setString(2, oldName); statement.setString(3, name); statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } - else - { + } else { this.client.sendResponse(new ChangeNameCheckResultComposer(ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS, name, new ArrayList<>())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/EnableEffectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/EnableEffectEvent.java index f93d8d5b..29d894f8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/EnableEffectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/EnableEffectEvent.java @@ -2,26 +2,19 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; -public class EnableEffectEvent extends MessageHandler -{ +public class EnableEffectEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int effectId = this.packet.readInt(); - if (effectId > 0) - { - if (this.client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) - { + if (effectId > 0) { + if (this.client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) { this.client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); } - } - else - { + } else { this.client.getHabbo().getInventory().getEffectsComponent().activatedEffect = 0; - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + 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/PickNewUserGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/PickNewUserGiftEvent.java index 3df85263..24530532 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/PickNewUserGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/PickNewUserGiftEvent.java @@ -5,25 +5,20 @@ import com.eu.habbo.habbohotel.items.NewUserGift; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserPickGiftEvent; -public class PickNewUserGiftEvent extends MessageHandler -{ +public class PickNewUserGiftEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int totalItems = this.packet.readInt(); //total items int keyA = this.packet.readInt(); //key 1 int keyB = this.packet.readInt(); //key 2 int index = this.packet.readInt(); - if (!Emulator.getPluginManager().fireEvent(new UserPickGiftEvent(this.client.getHabbo(), keyA, keyB, index)).isCancelled()) - { - if (!this.client.getHabbo().getHabboStats().nuxReward) - { + if (!Emulator.getPluginManager().fireEvent(new UserPickGiftEvent(this.client.getHabbo(), keyA, keyB, index)).isCancelled()) { + if (!this.client.getHabbo().getHabboStats().nuxReward) { this.client.getHabbo().getHabboStats().nuxReward = true; NewUserGift gift = Emulator.getGameEnvironment().getItemManager().getNewUserGift(index + 1); - if (gift != null) - { + if (gift != null) { gift.give(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestMeMenuSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestMeMenuSettingsEvent.java index 85e0bc6e..18aa4e20 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestMeMenuSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestMeMenuSettingsEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.MeMenuSettingsComposer; -public class RequestMeMenuSettingsEvent extends MessageHandler -{ +public class RequestMeMenuSettingsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new MeMenuSettingsComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestProfileFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestProfileFriendsEvent.java index 373bdd74..cc6a0198 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestProfileFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestProfileFriendsEvent.java @@ -6,15 +6,13 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.ProfileFriendsComposer; -public class RequestProfileFriendsEvent extends MessageHandler -{ +public class RequestProfileFriendsEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if(habbo != null) + if (habbo != null) this.client.sendResponse(new ProfileFriendsComposer(habbo)); else this.client.sendResponse(new ProfileFriendsComposer(Messenger.getFriends(userId), userId)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCitizinShipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCitizinShipEvent.java index d9d04c4c..81844d60 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCitizinShipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCitizinShipEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserCitizinShipComposer; -public class RequestUserCitizinShipEvent extends MessageHandler -{ +public class RequestUserCitizinShipEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new UserCitizinShipComposer(this.packet.readString())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserClubEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserClubEvent.java index 7255153f..c560fbb1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserClubEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserClubEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserClubComposer; -public class RequestUserClubEvent extends MessageHandler -{ +public class RequestUserClubEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new UserClubComposer(this.client.getHabbo())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCreditsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCreditsEvent.java index 9141d763..e581fdb3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCreditsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCreditsEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import com.eu.habbo.messages.outgoing.users.UserCurrencyComposer; -public class RequestUserCreditsEvent extends MessageHandler -{ +public class RequestUserCreditsEvent extends MessageHandler { @Override - public void handle() - { + public void handle() { this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo())); this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java index 455104d4..56f75a1b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java @@ -11,13 +11,10 @@ import com.eu.habbo.messages.outgoing.users.UserPerksComposer; import java.util.ArrayList; -public class RequestUserDataEvent extends MessageHandler -{ +public class RequestUserDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo() != null) - { + public void handle() throws Exception { + if (this.client.getHabbo() != null) { //this.client.sendResponse(new TestComposer()); //this.client.sendResponse(new UserDataComposer(this.client.getHabbo())); @@ -39,28 +36,10 @@ public class RequestUserDataEvent extends MessageHandler ArrayList messages = new ArrayList<>(); - - - - - - - - - - - - - - - - - - messages.add(new UserDataComposer(this.client.getHabbo()).compose()); messages.add(new UserPerksComposer(this.client.getHabbo()).compose()); - if(this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) + if (this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) messages.add(new ForwardToRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); else if (RoomManager.HOME_ROOM_ID > 0) messages.add(new ForwardToRoomComposer(RoomManager.HOME_ROOM_ID).compose()); @@ -68,11 +47,6 @@ public class RequestUserDataEvent extends MessageHandler messages.add(new MeMenuSettingsComposer(this.client.getHabbo()).compose()); - - - - - // // @@ -81,31 +55,10 @@ public class RequestUserDataEvent extends MessageHandler // - - - - - - - - - - - - - - - - - - this.client.sendResponses(messages); - - } - else - { + } else { Emulator.getLogging().logDebugLine("Habbo is NULL!"); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserProfileEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserProfileEvent.java index e37b9ec4..e95b7e70 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserProfileEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserProfileEvent.java @@ -6,15 +6,13 @@ import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserProfileComposer; -public class RequestUserProfileEvent extends MessageHandler -{ +public class RequestUserProfileEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int habboId = this.packet.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId); - if(habbo != null) + if (habbo != null) this.client.sendResponse(new UserProfileComposer(habbo, this.client)); else this.client.sendResponse(new UserProfileComposer(HabboManager.getOfflineHabboInfo(habboId), this.client)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserWardrobeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserWardrobeEvent.java index 3ae82261..0e133e0b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserWardrobeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserWardrobeEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserWardrobeComposer; -public class RequestUserWardrobeEvent extends MessageHandler -{ +public class RequestUserWardrobeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.sendResponse(new UserWardrobeComposer(this.client.getHabbo().getInventory().getWardrobeComponent())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestWearingBadgesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestWearingBadgesEvent.java index ce405b13..ade93a20 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestWearingBadgesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestWearingBadgesEvent.java @@ -6,15 +6,13 @@ import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.UserBadgesComposer; -public class RequestWearingBadgesEvent extends MessageHandler -{ +public class RequestWearingBadgesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int userId = this.packet.readInt(); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(userId); - if(habbo == null || habbo.getHabboInfo() == null || habbo.getInventory() == null || habbo.getInventory().getBadgesComponent() == null) + if (habbo == null || habbo.getHabboInfo() == null || habbo.getInventory() == null || habbo.getInventory().getBadgesComponent() == null) this.client.sendResponse(new UserBadgesComposer(BadgesComponent.getBadgesOfflineHabbo(userId), userId)); else this.client.sendResponse(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SaveBlockCameraFollowEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SaveBlockCameraFollowEvent.java index 5d9a4666..f1d66340 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SaveBlockCameraFollowEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SaveBlockCameraFollowEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; -public class SaveBlockCameraFollowEvent extends MessageHandler -{ +public class SaveBlockCameraFollowEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.getHabbo().getHabboStats().blockCameraFollow = this.packet.readBoolean(); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SaveIgnoreRoomInvitesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SaveIgnoreRoomInvitesEvent.java index 29b950a4..b12024c3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SaveIgnoreRoomInvitesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SaveIgnoreRoomInvitesEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; -public class SaveIgnoreRoomInvitesEvent extends MessageHandler -{ +public class SaveIgnoreRoomInvitesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.getHabbo().getHabboStats().blockRoomInvites = this.packet.readBoolean(); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SaveMottoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SaveMottoEvent.java index 58054aa2..d3b2a329 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SaveMottoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SaveMottoEvent.java @@ -6,11 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.plugin.events.users.UserSavedMottoEvent; -public class SaveMottoEvent extends MessageHandler -{ +public class SaveMottoEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String motto = this.packet.readString(); UserSavedMottoEvent event = new UserSavedMottoEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getMotto(), motto); Emulator.getPluginManager().fireEvent(event); @@ -19,12 +17,9 @@ public class SaveMottoEvent extends MessageHandler this.client.getHabbo().getHabboInfo().setMotto(motto); this.client.getHabbo().getHabboInfo().run(); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(this.client.getHabbo()).compose()); - } - else - { + } else { this.client.sendResponse(new RoomUserDataComposer(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SavePreferOldChatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SavePreferOldChatEvent.java index 4f1f46d8..6fbc3b2d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SavePreferOldChatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SavePreferOldChatEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; -public class SavePreferOldChatEvent extends MessageHandler -{ +public class SavePreferOldChatEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { this.client.getHabbo().getHabboStats().preferOldChat = this.packet.readBoolean(); Emulator.getPluginManager().fireEvent(new UserSavedSettingsEvent(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SaveUserVolumesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SaveUserVolumesEvent.java index 852eacde..ff50cb9d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SaveUserVolumesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SaveUserVolumesEvent.java @@ -4,11 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent; -public class SaveUserVolumesEvent extends MessageHandler -{ +public class SaveUserVolumesEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int system = this.packet.readInt(); int furni = this.packet.readInt(); int trax = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SaveWardrobeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SaveWardrobeEvent.java index d5739840..1e58686b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SaveWardrobeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SaveWardrobeEvent.java @@ -6,25 +6,20 @@ import com.eu.habbo.habbohotel.users.inventory.WardrobeComponent; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSavedWardrobeEvent; -public class SaveWardrobeEvent extends MessageHandler -{ +public class SaveWardrobeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int slotId = this.packet.readInt(); String look = this.packet.readString(); String gender = this.packet.readString(); WardrobeComponent.WardrobeItem wardrobeItem; - if(this.client.getHabbo().getInventory().getWardrobeComponent().getLooks().containsKey(slotId)) - { + if (this.client.getHabbo().getInventory().getWardrobeComponent().getLooks().containsKey(slotId)) { wardrobeItem = this.client.getHabbo().getInventory().getWardrobeComponent().getLooks().get(slotId); wardrobeItem.setGender(HabboGender.valueOf(gender)); wardrobeItem.setLook(look); wardrobeItem.setNeedsUpdate(true); - } - else - { + } else { wardrobeItem = this.client.getHabbo().getInventory().getWardrobeComponent().createLook(this.client.getHabbo(), slotId, look); wardrobeItem.setNeedsInsert(true); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java index 35b38208..74b3030d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java @@ -4,19 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.messages.incoming.MessageHandler; -public class UserActivityEvent extends MessageHandler -{ +public class UserActivityEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String type = this.packet.readString(); String value = this.packet.readString(); - switch (type) - { + switch (type) { case "Quiz": - if (value.equalsIgnoreCase("7")) - { + if (value.equalsIgnoreCase("7")) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SafetyQuizGraduate")); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserNuxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserNuxEvent.java index 056eff9a..f29fe54f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserNuxEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserNuxEvent.java @@ -8,10 +8,8 @@ import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; import java.util.HashMap; import java.util.Map; -public class UserNuxEvent extends MessageHandler -{ - public static Map keys = new HashMap() - { +public class UserNuxEvent extends MessageHandler { + public static Map keys = new HashMap() { { this.put(1, "BOTTOM_BAR_RECEPTION"); this.put(2, "BOTTOM_BAR_NAVIGATOR"); @@ -26,30 +24,23 @@ public class UserNuxEvent extends MessageHandler this.put(11, "BOTTOM_BAR_NAVIGATOR"); } }; - @Override - public void handle() throws Exception - { - handle(this.client.getHabbo()); - } - public static void handle(Habbo habbo) - { + public static void handle(Habbo habbo) { habbo.getHabboStats().nux = true; int step = habbo.getHabboStats().nuxStep++; - if (keys.containsKey(step)) - { + if (keys.containsKey(step)) { habbo.getClient().sendResponse(new NuxAlertComposer("helpBubble/add/" + keys.get(step) + "/" + Emulator.getTexts().getValue("nux.step." + step))); - } - else if (!habbo.getHabboStats().nuxReward) - { + } else if (!habbo.getHabboStats().nuxReward) { - - } - else - { + } else { habbo.getClient().sendResponse(new NuxAlertComposer("nux/lobbyoffer/show")); } } + + @Override + public void handle() throws Exception { + handle(this.client.getHabbo()); + } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java index 503a666d..97bcbf93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java @@ -8,22 +8,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; import com.eu.habbo.plugin.events.users.UserSavedLookEvent; -import com.eu.habbo.util.figure.FigureUtil; -public class UserSaveLookEvent extends MessageHandler -{ +public class UserSaveLookEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { String genderCode = this.packet.readString(); HabboGender gender; - try - { + try { gender = HabboGender.valueOf(genderCode); - } - catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { String message = Emulator.getTexts().getValue("scripter.warning.look.gender").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%gender%", genderCode); ScripterManager.scripterDetected(this.client, message); Emulator.getLogging().logUserLine(message); @@ -34,15 +28,14 @@ public class UserSaveLookEvent extends MessageHandler UserSavedLookEvent lookEvent = new UserSavedLookEvent(this.client.getHabbo(), gender, look); Emulator.getPluginManager().fireEvent(lookEvent); - if(lookEvent.isCancelled()) + if (lookEvent.isCancelled()) return; this.client.getHabbo().getHabboInfo().setLook(lookEvent.newLook); this.client.getHabbo().getHabboInfo().setGender(lookEvent.gender); Emulator.getThreading().run(this.client.getHabbo().getHabboInfo()); this.client.sendResponse(new UpdateUserLookComposer(this.client.getHabbo())); - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(this.client.getHabbo()).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserWearBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserWearBadgeEvent.java index 3d7751a2..19d75893 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserWearBadgeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserWearBadgeEvent.java @@ -8,29 +8,25 @@ import com.eu.habbo.messages.outgoing.users.UserBadgesComposer; import java.util.ArrayList; -public class UserWearBadgeEvent extends MessageHandler -{ +public class UserWearBadgeEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { BadgesComponent.resetSlots(this.client.getHabbo()); ArrayList updatedBadges = new ArrayList<>(); ArrayList usedSlots = new ArrayList<>(); - for(int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { int slot = this.packet.readInt(); - if(slot < 1 || slot > 5) + if (slot < 1 || slot > 5) return; String badgeId = this.packet.readString(); - if(badgeId.length() == 0) + if (badgeId.length() == 0) continue; HabboBadge badge = this.client.getHabbo().getInventory().getBadgesComponent().getBadge(badgeId); - if(badge != null && !updatedBadges.contains(badge) && !usedSlots.contains(slot)) - { + if (badge != null && !updatedBadges.contains(badge) && !usedSlots.contains(slot)) { usedSlots.add(slot); badge.setSlot(slot); badge.needsUpdate(true); @@ -39,12 +35,9 @@ public class UserWearBadgeEvent extends MessageHandler } } - if(this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(updatedBadges, this.client.getHabbo().getHabboInfo().getId()).compose()); - } - else - { + } else { this.client.sendResponse(new UserBadgesComposer(updatedBadges, this.client.getHabbo().getHabboInfo().getId())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java index 2a595b71..80302599 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java @@ -7,25 +7,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; -public class WiredConditionSaveDataEvent extends MessageHandler -{ +public class WiredConditionSaveDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) - { + if (room != null) { + if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); - if(condition != null) - { - if(condition.saveData(this.packet)) - { + if (condition != null) { + if (condition.saveData(this.packet)) { this.client.sendResponse(new WiredSavedComposer()); condition.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java index 11f12860..0ad93f85 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java @@ -7,25 +7,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; -public class WiredEffectSaveDataEvent extends MessageHandler -{ +public class WiredEffectSaveDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) - { + if (room != null) { + if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) { InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId); - if(effect != null) - { - if(effect.saveData(this.packet, this.client)) - { + if (effect != null) { + if (effect.saveData(this.packet, this.client)) { this.client.sendResponse(new WiredSavedComposer()); effect.needsUpdate(true); Emulator.getThreading().run(effect); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java index 18ad3f52..c25591b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java @@ -7,25 +7,19 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; -public class WiredTriggerSaveDataEvent extends MessageHandler -{ +public class WiredTriggerSaveDataEvent extends MessageHandler { @Override - public void handle() throws Exception - { + public void handle() throws Exception { int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room != null) - { - if(room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) - { + if (room != null) { + if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission("acc_moverotate")) { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); - if(trigger != null) - { - if(trigger.saveData(this.packet)) - { + if (trigger != null) { + if (trigger.saveData(this.packet)) { this.client.sendResponse(new WiredSavedComposer()); trigger.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/MessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/MessageComposer.java index da47d65c..1afb84ce 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/MessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/MessageComposer.java @@ -2,14 +2,12 @@ package com.eu.habbo.messages.outgoing; import com.eu.habbo.messages.ServerMessage; -public abstract class MessageComposer -{ +public abstract class MessageComposer { protected final ServerMessage response; - - protected MessageComposer() - { + + protected MessageComposer() { this.response = new ServerMessage(); } - + public abstract ServerMessage compose(); } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java index f33b68b5..cc7efef7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java @@ -1,7 +1,6 @@ package com.eu.habbo.messages.outgoing; -public class Outgoing -{ +public class Outgoing { public static final int PetStatusUpdateComposer = 1907;//error 404 public final static int CfhTopicsMessageComposer = 325; @@ -61,13 +60,13 @@ public class Outgoing public final static int GuildRefreshMembersListComposer = 2445; public final static int UserPerksComposer = 2586; public final static int UserCitizinShipComposer = 1203; - public final static int PublicRoomsComposer =-1;//error 404 + public final static int PublicRoomsComposer = -1;//error 404 public final static int MarketplaceOffersComposer = 680; public final static int ModToolComposer = 2696; public final static int UserBadgesComposer = 1087; public final static int GuildManageComposer = 3965; - public final static int RemoveFriendComposer =-1;//error 404 - public final static int BannerTokenComposer =-1;//error 404 + public final static int RemoveFriendComposer = -1;//error 404 + public final static int BannerTokenComposer = -1;//error 404 public final static int UserDataComposer = 2725; public final static int UserSearchResultComposer = 973; public final static int ModToolUserRoomVisitsComposer = 1752; @@ -365,7 +364,7 @@ public class Outgoing public final static int CompetitionEntrySubmitResultComposer = 1177; // PRODUCTION-201611291003-338511768 public final static int ExtendClubMessageComposer = 3964; // PRODUCTION-201611291003-338511768 public final static int HotelViewConcurrentUsersComposer = 2737; // PRODUCTION-201611291003-338511768 - public final static int InventoryAddEffectComposer =-1;//error 404 + public final static int InventoryAddEffectComposer = -1;//error 404 public final static int TalentLevelUpdateComposer = 638; // PRODUCTION-201611291003-338511768 public final static int BullyReportedMessageComposer = 3285; // PRODUCTION-201611291003-338511768 public final static int UnknownQuestComposer3 = 1122; // PRODUCTION-201611291003-338511768 @@ -398,9 +397,6 @@ public class Outgoing public final static int RoomEventMessageComposer = 2274; - - - public final static int JukeBoxMySongsComposer = 2602; // PRODUCTION-201611291003-338511768 public final static int JukeBoxNowPlayingMessageComposer = 469; // PRODUCTION-201611291003-338511768 public final static int JukeBoxPlaylistFullComposer = 105; // PRODUCTION-201611291003-338511768 @@ -459,7 +455,7 @@ public class Outgoing public final static int UnknownComposer_2601 = 1663; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_2621 = 1927; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_2698 = 563; // PRODUCTION-201611291003-338511768 -// 2699; + // 2699; // 2748; // 2773; // 2964; @@ -473,7 +469,7 @@ public class Outgoing // 3291; // 3334; public final static int HabboWayQuizComposer1 = 3379; -// 3391; + // 3391; // 3427; // 347; // 3509; @@ -481,19 +477,19 @@ public class Outgoing // 3581; // 3684; public final static int YouTradingDisabledComposer = 3058; // PRODUCTION-201611291003-338511768 -// 3707; + // 3707; // 3745; // 3759; // 3782; public final static int RoomFloorThicknessUpdatedComposer = 3786; -// 3822; + // 3822; public final static int CameraPurchaseSuccesfullComposer = 2783; // PRODUCTION-201611291003-338511768 public final static int CameraCompetitionStatusComposer = 133; // PRODUCTION-201611291003-338511768 -// 3986; + // 3986; // 467; // 549; public final static int CameraURLComposer = 3696; // PRODUCTION-201611291003-338511768 -// 608; + // 608; // 624; // 675; public final static int HotelViewCatalogPageExpiringComposer = 690; @@ -518,7 +514,7 @@ public class Outgoing public final static int UnknownCatalogPageOfferComposer = 1889; public final static int NuxAlertComposer = 2023; public final static int HotelViewExpiringCatalogPageCommposer = 2515; - public final static int UnknownHabboWayQuizComposer =2772; + public final static int UnknownHabboWayQuizComposer = 2772; public final static int PetLevelUpdatedComposer = 2824; public final static int QuestExpiredComposer = 3027; public final static int UnknownTradeComposer = 3128; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java index 0bc81268..026b0261 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java @@ -9,26 +9,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AchievementListComposer extends MessageComposer -{ +public class AchievementListComposer extends MessageComposer { private final Habbo habbo; - public AchievementListComposer(Habbo habbo) - { + public AchievementListComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AchievementListComposer); - try - { + try { this.response.appendInt(Emulator.getGameEnvironment().getAchievementManager().getAchievements().size()); - for (Achievement achievement : Emulator.getGameEnvironment().getAchievementManager().getAchievements().values()) - { + for (Achievement achievement : Emulator.getGameEnvironment().getAchievementManager().getAchievements().values()) { int achievementProgress; AchievementLevel currentLevel; AchievementLevel nextLevel; @@ -53,9 +48,7 @@ public class AchievementListComposer extends MessageComposer } this.response.appendString(""); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementProgressComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementProgressComposer.java index ac7b1cce..28d41bbb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementProgressComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementProgressComposer.java @@ -8,20 +8,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AchievementProgressComposer extends MessageComposer -{ +public class AchievementProgressComposer extends MessageComposer { private final Habbo habbo; private final Achievement achievement; - public AchievementProgressComposer(Habbo habbo, Achievement achievement) - { + public AchievementProgressComposer(Habbo habbo, Achievement achievement) { this.habbo = habbo; this.achievement = achievement; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AchievementProgressComposer); int achievementProgress; @@ -32,15 +29,15 @@ public class AchievementProgressComposer extends MessageComposer currentLevel = this.achievement.getLevelForProgress(achievementProgress); nextLevel = this.achievement.getNextLevel(currentLevel != null ? currentLevel.level : 0); - if(currentLevel != null && currentLevel.level == this.achievement.levels.size()) + if (currentLevel != null && currentLevel.level == this.achievement.levels.size()) nextLevel = null; int targetLevel = 1; - if(nextLevel != null) + if (nextLevel != null) targetLevel = nextLevel.level; - if(currentLevel != null && currentLevel.level == this.achievement.levels.size()) + if (currentLevel != null && currentLevel.level == this.achievement.levels.size()) targetLevel = currentLevel.level; this.response.appendInt(this.achievement.id); //ID 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 719b4a6f..71489157 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 @@ -7,20 +7,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AchievementUnlockedComposer extends MessageComposer -{ +public class AchievementUnlockedComposer extends MessageComposer { private final Achievement achievement; private final Habbo habbo; - public AchievementUnlockedComposer(Habbo habbo, Achievement achievement) - { + public AchievementUnlockedComposer(Habbo habbo, Achievement achievement) { this.achievement = achievement; this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AchievementUnlockedComposer); AchievementLevel level = this.achievement.getLevelForProgress(this.habbo.getHabboStats().getAchievementProgress(this.achievement)); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpdateComposer.java index e1f95656..6f954e4e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentLevelUpdateComposer.java @@ -7,40 +7,32 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TalentLevelUpdateComposer extends MessageComposer -{ +public class TalentLevelUpdateComposer extends MessageComposer { private final TalentTrackType talentTrackType; private final TalentTrackLevel talentTrackLevel; - public TalentLevelUpdateComposer(TalentTrackType talentTrackType, TalentTrackLevel talentTrackLevel) - { + public TalentLevelUpdateComposer(TalentTrackType talentTrackType, TalentTrackLevel talentTrackLevel) { this.talentTrackType = talentTrackType; this.talentTrackLevel = talentTrackLevel; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TalentLevelUpdateComposer); this.response.appendString(this.talentTrackType.name()); this.response.appendInt(this.talentTrackLevel.level); - if (this.talentTrackLevel.perks != null) - { + if (this.talentTrackLevel.perks != null) { this.response.appendInt(this.talentTrackLevel.perks.length); - for (String s : this.talentTrackLevel.perks) - { + for (String s : this.talentTrackLevel.perks) { this.response.appendString(s); } - } - else - { + } else { this.response.appendInt(0); } this.response.appendInt(this.talentTrackLevel.items.size()); - for (Item item : this.talentTrackLevel.items) - { + for (Item item : this.talentTrackLevel.items) { this.response.appendString(item.getName()); this.response.appendInt(item.getSpriteId()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackComposer.java index 1e562666..d9a00946 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/talenttrack/TalentTrackComposer.java @@ -14,45 +14,24 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -public class TalentTrackComposer extends MessageComposer -{ - public enum TalentTrackState - { - LOCKED(0), - IN_PROGRESS(1), - COMPLETED(2); - - public final int id; - - TalentTrackState(int id) - { - this.id = id; - } - } - +public class TalentTrackComposer extends MessageComposer { public final Habbo habbo; public final TalentTrackType type; - - public TalentTrackComposer(Habbo habbo, TalentTrackType type) - { + public TalentTrackComposer(Habbo habbo, TalentTrackType type) { this.habbo = habbo; this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TalentTrackComposer); this.response.appendString(this.type.name().toLowerCase()); LinkedHashMap talentTrackLevels = Emulator.getGameEnvironment().getAchievementManager().getTalenTrackLevels(this.type); - if (talentTrackLevels != null) - { + if (talentTrackLevels != null) { this.response.appendInt(talentTrackLevels.size()); //Count - for (Map.Entry set : talentTrackLevels.entrySet()) - { - try - { + for (Map.Entry set : talentTrackLevels.entrySet()) { + try { TalentTrackLevel level = set.getValue(); this.response.appendInt(level.level); @@ -61,12 +40,9 @@ public class TalentTrackComposer extends MessageComposer int currentLevel = this.habbo.getHabboStats().talentTrackLevel(this.type); - if (currentLevel + 1 == level.level) - { + if (currentLevel + 1 == level.level) { state = TalentTrackState.IN_PROGRESS; - } - else if (currentLevel >= level.level) - { + } else if (currentLevel >= level.level) { state = TalentTrackState.COMPLETED; } @@ -75,8 +51,7 @@ public class TalentTrackComposer extends MessageComposer final TalentTrackState finalState = state; level.achievements.forEachEntry((achievement, index) -> { - if (achievement != null) - { + if (achievement != null) { this.response.appendInt(achievement.id); //TODO Move this to TalenTrackLevel class @@ -86,30 +61,21 @@ public class TalentTrackComposer extends MessageComposer int progress = Math.max(0, this.habbo.getHabboStats().getAchievementProgress(achievement)); AchievementLevel achievementLevel = achievement.getLevelForProgress(progress); - if (achievementLevel == null) - { + if (achievementLevel == null) { achievementLevel = achievement.firstLevel(); } - if (finalState != TalentTrackState.LOCKED) - { - if (achievementLevel != null && achievementLevel.progress <= progress) - { + if (finalState != TalentTrackState.LOCKED) { + if (achievementLevel != null && achievementLevel.progress <= progress) { this.response.appendInt(2); - } - else - { + } else { this.response.appendInt(1); } - } - else - { + } else { this.response.appendInt(0); } this.response.appendInt(progress); this.response.appendInt(achievementLevel != null ? achievementLevel.progress : 0); - } - else - { + } else { this.response.appendInt(0); this.response.appendInt(0); this.response.appendString(""); @@ -122,43 +88,43 @@ public class TalentTrackComposer extends MessageComposer }); - if (level.perks != null && level.perks.length > 0) - { + if (level.perks != null && level.perks.length > 0) { this.response.appendInt(level.perks.length); - for (String perk : level.perks) - { + for (String perk : level.perks) { this.response.appendString(perk); } - } - else - { + } else { this.response.appendInt(-1); } - if (!level.items.isEmpty()) - { + if (!level.items.isEmpty()) { this.response.appendInt(level.items.size()); - for (Item item : level.items) - { + for (Item item : level.items) { this.response.appendString(item.getName()); this.response.appendInt(0); } - } - else - { + } else { this.response.appendInt(-1); } - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { return null; } } - } - else - { + } else { this.response.appendInt(0); } return this.response; } + + public enum TalentTrackState { + LOCKED(0), + IN_PROGRESS(1), + COMPLETED(2); + + public final int id; + + TalentTrackState(int id) { + this.id = id; + } + } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraCompetitionStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraCompetitionStatusComposer.java index 490f64ec..e013614d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraCompetitionStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraCompetitionStatusComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CameraCompetitionStatusComposer extends MessageComposer -{ +public class CameraCompetitionStatusComposer extends MessageComposer { private final boolean unknownBoolean; private final String unknownString; - public CameraCompetitionStatusComposer(boolean unknownBoolean, String unknownString) - { + public CameraCompetitionStatusComposer(boolean unknownBoolean, String unknownString) { this.unknownBoolean = unknownBoolean; this.unknownString = unknownString; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraCompetitionStatusComposer); this.response.appendBoolean(this.unknownBoolean); this.response.appendString(this.unknownString); 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 77cb1b77..15932016 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 @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CameraPriceComposer extends MessageComposer -{ +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) - { + public CameraPriceComposer(int credits, int points, int pointsType) { this.credits = credits; this.points = points; this.pointsType = pointsType; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraPriceComposer); this.response.appendInt(this.credits); this.response.appendInt(this.points); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java index 67c64b6d..f30d815c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java @@ -4,28 +4,24 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CameraPublishWaitMessageComposer extends MessageComposer -{ +public class CameraPublishWaitMessageComposer extends MessageComposer { public final boolean published; public final int seconds; public final String unknownString; - public CameraPublishWaitMessageComposer(boolean published, int seconds, String unknownString) - { + public CameraPublishWaitMessageComposer(boolean published, int seconds, String unknownString) { this.published = published; this.seconds = seconds; this.unknownString = unknownString; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraPublishWaitMessageComposer); this.response.appendBoolean(this.published); this.response.appendInt(this.seconds); - if (this.published) - { + if (this.published) { this.response.appendString(this.unknownString); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPurchaseSuccesfullComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPurchaseSuccesfullComposer.java index ab151cd6..ffc6b17b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPurchaseSuccesfullComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPurchaseSuccesfullComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CameraPurchaseSuccesfullComposer extends MessageComposer -{ +public class CameraPurchaseSuccesfullComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraPurchaseSuccesfullComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraRoomThumbnailSavedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraRoomThumbnailSavedComposer.java index fe84ea51..ab037eee 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraRoomThumbnailSavedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraRoomThumbnailSavedComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CameraRoomThumbnailSavedComposer extends MessageComposer -{ +public class CameraRoomThumbnailSavedComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraRoomThumbnailSavedComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraURLComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraURLComposer.java index 37c6d315..6096f59a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraURLComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraURLComposer.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; -public class CameraURLComposer extends MessageComposer -{ +public class CameraURLComposer extends MessageComposer { private final String URL; - public CameraURLComposer(String url) - { + public CameraURLComposer(String url) { this.URL = url; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CameraURLComposer); this.response.appendString(this.URL); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertLimitedSoldOutComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertLimitedSoldOutComposer.java index 0dae3850..bea4faca 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertLimitedSoldOutComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertLimitedSoldOutComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AlertLimitedSoldOutComposer extends MessageComposer -{ +public class AlertLimitedSoldOutComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AlertLimitedSoldOutComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseFailedComposer.java index b087d6fb..4a1ad45d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseFailedComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AlertPurchaseFailedComposer extends MessageComposer -{ +public class AlertPurchaseFailedComposer extends MessageComposer { public static final int SERVER_ERROR = 0; public static final int ALREADY_HAVE_BADGE = 1; private final int error; - public AlertPurchaseFailedComposer(int error) - { + public AlertPurchaseFailedComposer(int error) { this.error = error; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AlertPurchaseFailedComposer); this.response.appendInt(this.error); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseUnavailableComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseUnavailableComposer.java index 8d6cd26e..5d426976 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseUnavailableComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/AlertPurchaseUnavailableComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AlertPurchaseUnavailableComposer extends MessageComposer -{ +public class AlertPurchaseUnavailableComposer extends MessageComposer { public final static int ILLEGAL = 0; public final static int REQUIRES_CLUB = 1; private final int code; - public AlertPurchaseUnavailableComposer(int code) - { + public AlertPurchaseUnavailableComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AlertPurchaseUnavailableComposer); this.response.appendInt(this.code); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogModeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogModeComposer.java index 27414534..1fdf629e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogModeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogModeComposer.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; -public class CatalogModeComposer extends MessageComposer -{ +public class CatalogModeComposer extends MessageComposer { private final int mode; - public CatalogModeComposer(int mode) - { + public CatalogModeComposer(int mode) { this.mode = mode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CatalogModeComposer); this.response.appendInt(this.mode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java index 1807642d..82962855 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java @@ -17,63 +17,52 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class CatalogPageComposer extends MessageComposer -{ +public class CatalogPageComposer extends MessageComposer { private final CatalogPage page; private final Habbo habbo; private final String mode; - public CatalogPageComposer(CatalogPage page, Habbo habbo, String mode) - { + public CatalogPageComposer(CatalogPage page, Habbo habbo, String mode) { this.page = page; this.habbo = habbo; this.mode = mode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CatalogPageComposer); this.response.appendInt(this.page.getId()); this.response.appendString(this.mode); this.page.serialize(this.response); - if(this.page instanceof RecentPurchasesLayout) - { + if (this.page instanceof RecentPurchasesLayout) { this.response.appendInt(this.habbo.getHabboStats().getRecentPurchases().size()); - for(Map.Entry item : this.habbo.getHabboStats().getRecentPurchases().entrySet()) - { + for (Map.Entry item : this.habbo.getHabboStats().getRecentPurchases().entrySet()) { item.getValue().serialize(this.response); } - } - else - { + } else { this.response.appendInt(this.page.getCatalogItems().size()); List items = new ArrayList<>(this.page.getCatalogItems().valueCollection()); Collections.sort(items); - for (CatalogItem item : items) - { + for (CatalogItem item : items) { item.serialize(this.response); } } this.response.appendInt(0); this.response.appendBoolean(false); //acceptSeasonCurrencyAsCredits - if (this.page instanceof FrontPageFeaturedLayout || this.page instanceof FrontpageLayout) - { + if (this.page instanceof FrontPageFeaturedLayout || this.page instanceof FrontpageLayout) { this.serializeExtra(this.response); } return this.response; } - public void serializeExtra(ServerMessage message) - { + public void serializeExtra(ServerMessage message) { message.appendInt(Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().size()); - for (CatalogFeaturedPage page : Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().valueCollection()) - { + for (CatalogFeaturedPage page : Emulator.getGameEnvironment().getCatalogManager().getCatalogFeaturedPages().valueCollection()) { page.serialize(message); } } 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 25c63dae..36c84966 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 @@ -9,24 +9,20 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class CatalogPagesListComposer extends MessageComposer -{ +public class CatalogPagesListComposer extends MessageComposer { private final Habbo habbo; private final String mode; private final boolean hasPermission; - public CatalogPagesListComposer(Habbo habbo, String mode) - { + public CatalogPagesListComposer(Habbo habbo, String mode) { this.habbo = habbo; this.mode = mode; this.hasPermission = this.habbo.hasPermission("acc_catalog_ids"); } @Override - public ServerMessage compose() - { - try - { + public ServerMessage compose() { + try { List pages = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(-1, this.habbo); this.response.init(Outgoing.CatalogPagesListComposer); @@ -39,8 +35,7 @@ public class CatalogPagesListComposer extends MessageComposer this.response.appendInt(0); this.response.appendInt(pages.size()); - for (CatalogPage category : pages) - { + for (CatalogPage category : pages) { this.append(category); } @@ -48,17 +43,14 @@ public class CatalogPagesListComposer extends MessageComposer this.response.appendString(this.mode); return this.response; - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - private void append(CatalogPage category) - { + private void append(CatalogPage category) { List pagesList = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(category.getId(), this.habbo); this.response.appendBoolean(category.isVisible()); @@ -68,15 +60,13 @@ public class CatalogPagesListComposer extends MessageComposer this.response.appendString(category.getCaption() + (this.hasPermission ? " (" + category.getId() + ")" : "")); this.response.appendInt(category.getOfferIds().size()); - for(int i : category.getOfferIds().toArray()) - { + for (int i : category.getOfferIds().toArray()) { this.response.appendInt(i); } this.response.appendInt(pagesList.size()); - for (CatalogPage page : pagesList) - { + for (CatalogPage page : pagesList) { this.append(page); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogSearchResultComposer.java index 447e5f01..397e61cd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogSearchResultComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CatalogSearchResultComposer extends MessageComposer -{ +public class CatalogSearchResultComposer extends MessageComposer { private final CatalogItem item; - public CatalogSearchResultComposer(CatalogItem item) - { + public CatalogSearchResultComposer(CatalogItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CatalogSearchResultComposer); this.item.serialize(this.response); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogUpdatedComposer.java index 9dc8ded1..10eeffa7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogUpdatedComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CatalogUpdatedComposer extends MessageComposer -{ +public class CatalogUpdatedComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CatalogUpdatedComposer); this.response.appendBoolean(false); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubCenterDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubCenterDataComposer.java index 37860b6f..800b9df8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubCenterDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubCenterDataComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ClubCenterDataComposer extends MessageComposer -{ +public class ClubCenterDataComposer extends MessageComposer { private final int streakDuration; private final String joinDate; private final double percentage; @@ -14,8 +13,7 @@ public class ClubCenterDataComposer extends MessageComposer private final int spendBonus; private final int delay; - public ClubCenterDataComposer(int streakDuration, String joinDate, double percentage, int creditsSpend, int creditsBonus, int spendBonus, int delay) - { + public ClubCenterDataComposer(int streakDuration, String joinDate, double percentage, int creditsSpend, int creditsBonus, int spendBonus, int delay) { this.streakDuration = streakDuration; this.joinDate = joinDate; this.percentage = percentage; @@ -26,8 +24,7 @@ public class ClubCenterDataComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ClubCenterDataComposer); this.response.appendInt(this.streakDuration); //streakduration in days this.response.appendString(this.joinDate); //joindate diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubDataComposer.java index ca659fdc..787c6eed 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubDataComposer.java @@ -10,28 +10,24 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Calendar; import java.util.List; -public class ClubDataComposer extends MessageComposer -{ +public class ClubDataComposer extends MessageComposer { private final int windowId; private final Habbo habbo; - public ClubDataComposer(Habbo habbo, int windowId) - { + public ClubDataComposer(Habbo habbo, int windowId) { this.habbo = habbo; this.windowId = windowId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ClubDataComposer); List offers = Emulator.getGameEnvironment().getCatalogManager().getClubOffers(); this.response.appendInt(offers.size()); //TODO Change this to a seperate table. - for(ClubOffer offer : offers) - { + for (ClubOffer offer : offers) { this.response.appendInt(offer.getId()); this.response.appendString(offer.getName()); this.response.appendBoolean(false); //unused @@ -44,13 +40,13 @@ public class ClubDataComposer extends MessageComposer long secondsTotal = seconds; - int totalYears = (int)Math.floor((int)seconds / 86400 * 31 * 12); + int totalYears = (int) Math.floor((int) seconds / 86400 * 31 * 12); seconds -= totalYears * 86400 * 31 * 12; - int totalMonths = (int)Math.floor((int)seconds / 86400 * 31); + int totalMonths = (int) Math.floor((int) seconds / 86400 * 31); seconds -= totalMonths * 86400 * 31; - int totalDays = (int)Math.floor((int)seconds / 86400); + int totalDays = (int) Math.floor((int) seconds / 86400); seconds -= totalDays * 86400; this.response.appendInt((int) secondsTotal / 86400 / 31); @@ -60,8 +56,7 @@ public class ClubDataComposer extends MessageComposer int endTimestamp = this.habbo.getHabboStats().getClubExpireTimestamp(); - if (endTimestamp < Emulator.getIntUnixTimestamp()) - { + if (endTimestamp < Emulator.getIntUnixTimestamp()) { endTimestamp = Emulator.getIntUnixTimestamp(); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftsComposer.java index d62d0ad5..eb51719b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftsComposer.java @@ -10,11 +10,9 @@ import gnu.trove.iterator.TIntObjectIterator; import java.util.NoSuchElementException; -public class ClubGiftsComposer extends MessageComposer -{ +public class ClubGiftsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ClubGiftsComposer); this.response.appendInt(0); //Days Until Next Gift @@ -22,63 +20,48 @@ public class ClubGiftsComposer extends MessageComposer CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(Emulator.getConfig().getInt("catalog.page.vipgifts")); - if (page != null) - { + if (page != null) { this.response.appendInt(page.getCatalogItems().size()); TIntObjectIterator iterator = page.getCatalogItems().iterator(); - for (int i = page.getCatalogItems().size(); i-- > 0; ) - { - try - { + for (int i = page.getCatalogItems().size(); i-- > 0; ) { + try { iterator.advance(); CatalogItem item = iterator.value(); - if (item != null) - { + if (item != null) { item.serialize(this.response); } - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } this.response.appendInt(page.getCatalogItems().size()); iterator = page.getCatalogItems().iterator(); - for (int i = page.getCatalogItems().size(); i-- > 0; ) - { - try - { + for (int i = page.getCatalogItems().size(); i-- > 0; ) { + try { iterator.advance(); CatalogItem item = iterator.value(); - if (item != null) - { + if (item != null) { this.response.appendInt(item.getId()); this.response.appendBoolean(true); this.response.appendInt(i); this.response.appendBoolean(true); - } - else - { + } else { this.response.appendInt(-100); this.response.appendBoolean(false); this.response.appendInt(-100); this.response.appendBoolean(false); } - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } - } - else - { + } else { this.response.appendInt(0); this.response.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/DiscountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/DiscountComposer.java index 3a900fc1..966bfa96 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/DiscountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/DiscountComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class DiscountComposer extends MessageComposer -{ +public class DiscountComposer extends MessageComposer { public static int MAXIMUM_ALLOWED_ITEMS = 100; public static int DISCOUNT_BATCH_SIZE = 6; public static int DISCOUNT_AMOUNT_PER_BATCH = 1; @@ -13,8 +12,7 @@ public class DiscountComposer extends MessageComposer public static int[] ADDITIONAL_DISCOUNT_THRESHOLDS = new int[]{40, 99}; @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.DiscountComposer); this.response.appendInt(MAXIMUM_ALLOWED_ITEMS); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftConfigurationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftConfigurationComposer.java index 230c1f5c..466d97a9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftConfigurationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftConfigurationComposer.java @@ -7,18 +7,15 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class GiftConfigurationComposer extends MessageComposer -{ +public class GiftConfigurationComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GiftConfigurationComposer); this.response.appendBoolean(true); this.response.appendInt(Emulator.getConfig().getInt("hotel.gifts.special.price", 2)); this.response.appendInt(Emulator.getGameEnvironment().getCatalogManager().giftWrappers.size()); - for(Integer i : Emulator.getGameEnvironment().getCatalogManager().giftWrappers.keySet()) - { + for (Integer i : Emulator.getGameEnvironment().getCatalogManager().giftWrappers.keySet()) { this.response.appendInt(i); } @@ -47,8 +44,7 @@ public class GiftConfigurationComposer extends MessageComposer this.response.appendInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size()); - for(Map.Entry set : Emulator.getGameEnvironment().getCatalogManager().giftFurnis.entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getCatalogManager().giftFurnis.entrySet()) { this.response.appendInt(set.getKey()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftReceiverNotFoundComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftReceiverNotFoundComposer.java index 0d191018..c848b083 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftReceiverNotFoundComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/GiftReceiverNotFoundComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GiftReceiverNotFoundComposer extends MessageComposer -{ +public class GiftReceiverNotFoundComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GiftReceiverNotFoundComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughPointsTypeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughPointsTypeComposer.java index 3c59bf55..b395ec71 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughPointsTypeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/NotEnoughPointsTypeComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NotEnoughPointsTypeComposer extends MessageComposer -{ +public class NotEnoughPointsTypeComposer extends MessageComposer { private final boolean isCredits; private final boolean isPixels; private final int pointsType; - public NotEnoughPointsTypeComposer(boolean isCredits, boolean isPixels, int pointsType) - { + public NotEnoughPointsTypeComposer(boolean isCredits, boolean isPixels, int pointsType) { this.isCredits = isCredits; this.isPixels = isPixels; this.pointsType = pointsType; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NotEnoughPointsTypeComposer); this.response.appendBoolean(this.isCredits); this.response.appendBoolean(this.isPixels); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBoughtNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBoughtNotificationComposer.java index 2034051b..a44503db 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBoughtNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBoughtNotificationComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetBoughtNotificationComposer extends MessageComposer -{ +public class PetBoughtNotificationComposer extends MessageComposer { private final Pet pet; private final boolean gift; - public PetBoughtNotificationComposer(Pet pet, boolean gift) - { + public PetBoughtNotificationComposer(Pet pet, boolean gift) { this.pet = pet; this.gift = gift; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBoughtNotificationComposer); this.response.appendBoolean(this.gift); this.pet.serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBreedsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBreedsComposer.java index 52ad1fa5..50ee6de8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBreedsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetBreedsComposer.java @@ -6,27 +6,23 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class PetBreedsComposer extends MessageComposer -{ +public class PetBreedsComposer extends MessageComposer { private final String petName; private final THashSet petRaces; - public PetBreedsComposer(String petName, THashSet petRaces) - { + public PetBreedsComposer(String petName, THashSet petRaces) { this.petName = petName; this.petRaces = petRaces; } @Override - public ServerMessage compose() - { - if(this.petRaces == null) + public ServerMessage compose() { + if (this.petRaces == null) return null; this.response.init(Outgoing.PetBreedsComposer); this.response.appendString(this.petName); this.response.appendInt(this.petRaces.size()); - for(PetRace race : this.petRaces) - { + for (PetRace race : this.petRaces) { this.response.appendInt(race.race); this.response.appendInt(race.colorOne); this.response.appendInt(race.colorTwo); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetNameErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetNameErrorComposer.java index 028c0ac0..089d0569 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetNameErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PetNameErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetNameErrorComposer extends MessageComposer -{ +public class PetNameErrorComposer extends MessageComposer { public static final int NAME_OK = 0; public static final int NAME_TO_LONG = 1; public static final int NAME_TO_SHORT = 2; @@ -15,15 +14,13 @@ public class PetNameErrorComposer extends MessageComposer private final int type; private final String value; - public PetNameErrorComposer(int type, String value) - { + public PetNameErrorComposer(int type, String value) { this.type = type; this.value = value; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetNameErrorComposer); this.response.appendInt(this.type); this.response.appendString(this.value); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKComposer.java index 139ea459..26098398 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/PurchaseOKComposer.java @@ -5,30 +5,23 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PurchaseOKComposer extends MessageComposer -{ +public class PurchaseOKComposer extends MessageComposer { private final CatalogItem catalogItem; - public PurchaseOKComposer(CatalogItem catalogItem) - { + public PurchaseOKComposer(CatalogItem catalogItem) { this.catalogItem = catalogItem; } - public PurchaseOKComposer() - { + public PurchaseOKComposer() { this.catalogItem = null; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PurchaseOKComposer); - if(this.catalogItem != null) - { + if (this.catalogItem != null) { this.catalogItem.serialize(this.response); - } - else - { + } else { this.response.appendInt(0); this.response.appendString(""); this.response.appendBoolean(false); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerCompleteComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerCompleteComposer.java index 7a45db1a..22c1e5ba 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerCompleteComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerCompleteComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RecyclerCompleteComposer extends MessageComposer -{ +public class RecyclerCompleteComposer extends MessageComposer { public static final int RECYCLING_COMPLETE = 1; public static final int RECYCLING_CLOSED = 2; private final int code; - public RecyclerCompleteComposer(int code) - { + public RecyclerCompleteComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RecyclerCompleteComposer); this.response.appendInt(this.code); this.response.appendInt(0); //prize ID. diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerLogicComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerLogicComposer.java index c152aab1..4f1acbcd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerLogicComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RecyclerLogicComposer.java @@ -9,20 +9,16 @@ import gnu.trove.set.hash.THashSet; import java.util.Map; -public class RecyclerLogicComposer extends MessageComposer -{ +public class RecyclerLogicComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RecyclerLogicComposer); this.response.appendInt(Emulator.getGameEnvironment().getCatalogManager().prizes.size()); - for(Map.Entry> map : Emulator.getGameEnvironment().getCatalogManager().prizes.entrySet()) - { + 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(map.getValue().size()); - for(Item item : map.getValue()) - { + for (Item item : map.getValue()) { this.response.appendString(item.getName()); this.response.appendInt(1); this.response.appendString(item.getType().code.toLowerCase()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherErrorComposer.java index ab2972b0..3071affb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherErrorComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RedeemVoucherErrorComposer extends MessageComposer -{ +public class RedeemVoucherErrorComposer extends MessageComposer { public static final int INVALID_CODE = 0; public static final int TECHNICAL_ERROR = 1; private final int code; - public RedeemVoucherErrorComposer(int code) - { + public RedeemVoucherErrorComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RedeemVoucherErrorComposer); this.response.appendString(this.code + ""); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherOKComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherOKComposer.java index 7d7c802d..3458f781 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherOKComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/RedeemVoucherOKComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RedeemVoucherOKComposer extends MessageComposer -{ +public class RedeemVoucherOKComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RedeemVoucherOKComposer); this.response.appendString(""); this.response.appendString(""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ReloadRecyclerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ReloadRecyclerComposer.java index f9926b51..2aacdfa9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/ReloadRecyclerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/ReloadRecyclerComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ReloadRecyclerComposer extends MessageComposer -{ +public class ReloadRecyclerComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ReloadRecyclerComposer); this.response.appendInt(1); this.response.appendInt(0); 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 da656ab3..67f8cfa7 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 @@ -7,20 +7,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TargetedOfferComposer extends MessageComposer -{ +public class TargetedOfferComposer extends MessageComposer { private final Habbo habbo; private final TargetOffer offer; - public TargetedOfferComposer(Habbo habbo, TargetOffer offer) - { + public TargetedOfferComposer(Habbo habbo, TargetOffer offer) { this.habbo = habbo; this.offer = offer; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TargetedOfferComposer); HabboOfferPurchase purchase = HabboOfferPurchase.getOrCreate(this.habbo, this.offer.getId()); this.offer.serialize(this.response, purchase); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyErrorComposer.java index 151324fc..d8281ad4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceBuyErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceBuyErrorComposer extends MessageComposer -{ +public class MarketplaceBuyErrorComposer extends MessageComposer { public static final int REFRESH = 1; public static final int SOLD_OUT = 2; public static final int UPDATES = 3; @@ -16,8 +15,7 @@ public class MarketplaceBuyErrorComposer extends MessageComposer private final int offerId; private final int price; - public MarketplaceBuyErrorComposer(int errorCode, int unknown, int offerId, int price) - { + public MarketplaceBuyErrorComposer(int errorCode, int unknown, int offerId, int price) { this.errorCode = errorCode; this.unknown = unknown; this.offerId = offerId; @@ -25,8 +23,7 @@ public class MarketplaceBuyErrorComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceBuyErrorComposer); this.response.appendInt(this.errorCode); //result this.response.appendInt(this.unknown); //newOfferId diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelSaleComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelSaleComposer.java index 5ac62002..2676297a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelSaleComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceCancelSaleComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceCancelSaleComposer extends MessageComposer -{ +public class MarketplaceCancelSaleComposer extends MessageComposer { private final MarketPlaceOffer offer; private final boolean success; - public MarketplaceCancelSaleComposer(MarketPlaceOffer offer, Boolean success) - { + public MarketplaceCancelSaleComposer(MarketPlaceOffer offer, Boolean success) { this.offer = offer; this.success = success; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceCancelSaleComposer); this.response.appendInt(this.offer.getOfferId()); this.response.appendBoolean(this.success); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceConfigComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceConfigComposer.java index cbfd532d..9e52ecbd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceConfigComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceConfigComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceConfigComposer extends MessageComposer -{ +public class MarketplaceConfigComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceConfigComposer); this.response.appendBoolean(true); this.response.appendInt(1); //Commision Percentage. diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemInfoComposer.java index 06686603..896ad5ea 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemInfoComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceItemInfoComposer extends MessageComposer -{ +public class MarketplaceItemInfoComposer extends MessageComposer { private final int itemId; - public MarketplaceItemInfoComposer(int itemId) - { + public MarketplaceItemInfoComposer(int itemId) { this.itemId = itemId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceItemInfoComposer); MarketPlace.serializeItemInfo(this.itemId, this.response); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemPostedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemPostedComposer.java index ed9cbbf2..0f76450f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemPostedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceItemPostedComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceItemPostedComposer extends MessageComposer -{ +public class MarketplaceItemPostedComposer extends MessageComposer { public static final int POST_SUCCESS = 1; public static final int FAILED_TECHNICAL_ERROR = 2; public static final int MARKETPLACE_DISABLED = 3; @@ -13,14 +12,12 @@ public class MarketplaceItemPostedComposer extends MessageComposer private final int code; - public MarketplaceItemPostedComposer(int code) - { + public MarketplaceItemPostedComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceItemPostedComposer); this.response.appendInt(this.code); return this.response; 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 6fedaf65..dca0d0d8 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 @@ -8,39 +8,30 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class MarketplaceOffersComposer extends MessageComposer -{ +public class MarketplaceOffersComposer extends MessageComposer { private final List offers; - public MarketplaceOffersComposer(List offers) - { + public MarketplaceOffersComposer(List offers) { this.offers = offers; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceOffersComposer); int total = 0; this.response.appendInt(this.offers.size()); - for(MarketPlaceOffer offer : this.offers) - { + for (MarketPlaceOffer offer : this.offers) { this.response.appendInt(offer.getOfferId()); this.response.appendInt(1); this.response.appendInt(offer.getType()); this.response.appendInt(offer.getItemId()); - if(offer.getType() == 3) - { + if (offer.getType() == 3) { this.response.appendInt(offer.getLimitedNumber()); this.response.appendInt(offer.getLimitedStack()); - } - else if (offer.getType() == 2) - { + } else if (offer.getType() == 2) { this.response.appendString(""); - } - else - { + } else { this.response.appendInt(0); this.response.appendString(""); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java index 4bd7efe8..04a0f26f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java @@ -8,30 +8,23 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceOwnItemsComposer extends MessageComposer -{ +public class MarketplaceOwnItemsComposer extends MessageComposer { private final Habbo habbo; - public MarketplaceOwnItemsComposer(Habbo habbo) - { + public MarketplaceOwnItemsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceOwnItemsComposer); this.response.appendInt(this.habbo.getInventory().getSoldPriceTotal()); this.response.appendInt(this.habbo.getInventory().getMarketplaceItems().size()); - for(MarketPlaceOffer offer : this.habbo.getInventory().getMarketplaceItems()) - { - try - { - if (offer.getState() == MarketPlaceState.OPEN) - { - if ((offer.getTimestamp() + 172800) - Emulator.getIntUnixTimestamp() <= 0) - { + for (MarketPlaceOffer offer : this.habbo.getInventory().getMarketplaceItems()) { + try { + if (offer.getState() == MarketPlaceState.OPEN) { + if ((offer.getTimestamp() + 172800) - Emulator.getIntUnixTimestamp() <= 0) { offer.setState(MarketPlaceState.CLOSED); Emulator.getThreading().run(offer); } @@ -42,17 +35,12 @@ public class MarketplaceOwnItemsComposer extends MessageComposer this.response.appendInt(offer.getType()); this.response.appendInt(offer.getItemId()); - if (offer.getType() == 3) - { + if (offer.getType() == 3) { this.response.appendInt(offer.getLimitedNumber()); this.response.appendInt(offer.getLimitedStack()); - } - else if (offer.getType() == 2) - { + } else if (offer.getType() == 2) { this.response.appendString(""); - } - else - { + } else { this.response.appendInt(0); this.response.appendString(""); } @@ -65,9 +53,7 @@ public class MarketplaceOwnItemsComposer extends MessageComposer this.response.appendInt(0); this.response.appendInt(0); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceSellItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceSellItemComposer.java index dfb9ecd9..9c87a6e4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceSellItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceSellItemComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MarketplaceSellItemComposer extends MessageComposer -{ +public class MarketplaceSellItemComposer extends MessageComposer { public static final int NOT_ALLOWED = 2; public static final int NO_TRADE_PASS = 3; public static final int NO_ADS_LEFT = 4; @@ -14,16 +13,14 @@ public class MarketplaceSellItemComposer extends MessageComposer private final int valueA; private final int valueB; - public MarketplaceSellItemComposer(int errorCode, int valueA, int valueB) - { + public MarketplaceSellItemComposer(int errorCode, int valueA, int valueB) { this.errorCode = errorCode; this.valueA = valueA; this.valueB = valueB; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MarketplaceSellItemComposer); this.response.appendInt(this.errorCode); this.response.appendInt(this.valueA); 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 a548e0e9..a47a92e5 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 @@ -9,32 +9,27 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Collection; import java.util.List; -public class CraftableProductsComposer extends MessageComposer -{ +public class CraftableProductsComposer extends MessageComposer { private final List recipes; private final Collection ingredients; - public CraftableProductsComposer(List recipes, Collection ingredients) - { + public CraftableProductsComposer(List recipes, Collection ingredients) { this.recipes = recipes; this.ingredients = ingredients; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CraftableProductsComposer); this.response.appendInt(this.recipes.size()); - for (CraftingRecipe recipe : this.recipes) - { + for (CraftingRecipe recipe : this.recipes) { this.response.appendString(recipe.getName()); this.response.appendString(recipe.getReward().getName()); } this.response.appendInt(this.ingredients.size()); - for (Item item : this.ingredients) - { + for (Item item : this.ingredients) { this.response.appendString(item.getName()); } 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 eb1485c8..42630413 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 @@ -8,23 +8,19 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class CraftingRecipeComposer extends MessageComposer -{ +public class CraftingRecipeComposer extends MessageComposer { private final CraftingRecipe recipe; - public CraftingRecipeComposer(CraftingRecipe recipe) - { + public CraftingRecipeComposer(CraftingRecipe recipe) { this.recipe = recipe; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CraftingRecipeComposer); this.response.appendInt(this.recipe.getIngredients().size()); - for (Map.Entry ingredient : this.recipe.getIngredients().entrySet()) - { + for (Map.Entry ingredient : this.recipe.getIngredients().entrySet()) { this.response.appendInt(ingredient.getValue()); this.response.appendString(ingredient.getKey().getName()); } 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 afd97868..7da993a9 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CraftingRecipesAvailableComposer extends MessageComposer -{ +public class CraftingRecipesAvailableComposer extends MessageComposer { private final int count; private final boolean found; - public CraftingRecipesAvailableComposer(int count, boolean found) - { + public CraftingRecipesAvailableComposer(int count, boolean found) { this.count = count; this.found = found; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CraftingComposerFour); this.response.appendInt((this.found ? -1 : 0) + this.count); this.response.appendBoolean(this.found); 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 77abbbc2..0bc63cde 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 @@ -5,32 +5,27 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CraftingResultComposer extends MessageComposer -{ +public class CraftingResultComposer extends MessageComposer { private final CraftingRecipe recipe; private final boolean succes; - public CraftingResultComposer(CraftingRecipe recipe) - { + public CraftingResultComposer(CraftingRecipe recipe) { this.recipe = recipe; this.succes = this.recipe != null; } - public CraftingResultComposer(CraftingRecipe recipe, boolean success) - { + public CraftingResultComposer(CraftingRecipe recipe, boolean success) { this.recipe = recipe; this.succes = success; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CraftingResultComposer); this.response.appendBoolean(this.succes); //succes - if(this.recipe != null) - { + if (this.recipe != null) { this.response.appendString(this.recipe.getName()); this.response.appendString(this.recipe.getReward().getName()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java index 2f189ccc..6ac6c009 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java @@ -6,26 +6,23 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; import gnu.trove.procedure.TIntProcedure; -public class AdventCalendarDataComposer extends MessageComposer -{ +public class AdventCalendarDataComposer extends MessageComposer { private final String eventName; private final int totalDays; private final int currentDay; private final TIntArrayList unlocked; private final boolean lockExpired; - public AdventCalendarDataComposer(String eventName, int totalDays, int currentDay, TIntArrayList unlocked, boolean lockExpired) - { - this.eventName = eventName; - this.totalDays = totalDays; - this.currentDay = currentDay; - this.unlocked = unlocked; + public AdventCalendarDataComposer(String eventName, int totalDays, int currentDay, TIntArrayList unlocked, boolean lockExpired) { + this.eventName = eventName; + this.totalDays = totalDays; + this.currentDay = currentDay; + this.unlocked = unlocked; this.lockExpired = lockExpired; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AdventCalendarDataComposer); this.response.appendString(this.eventName); this.response.appendString(""); @@ -35,17 +32,14 @@ public class AdventCalendarDataComposer extends MessageComposer this.response.appendInt(this.unlocked.size()); TIntArrayList expired = new TIntArrayList(); - for (int i = 0; i < this.totalDays; i++) - { + for (int i = 0; i < this.totalDays; i++) { expired.add(i); expired.remove(this.currentDay); } - this.unlocked.forEach(new TIntProcedure() - { + this.unlocked.forEach(new TIntProcedure() { @Override - public boolean execute(int value) - { + public boolean execute(int value) { AdventCalendarDataComposer.this.response.appendInt(value); expired.remove(value); return true; @@ -53,21 +47,16 @@ public class AdventCalendarDataComposer extends MessageComposer }); - if (this.lockExpired) - { + if (this.lockExpired) { this.response.appendInt(expired.size()); - expired.forEach(new TIntProcedure() - { + expired.forEach(new TIntProcedure() { @Override - public boolean execute(int value) - { + public boolean execute(int value) { AdventCalendarDataComposer.this.response.appendInt(value); return true; } }); - } - else - { + } else { this.response.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java index 78993beb..5352d886 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AdventCalendarProductComposer extends MessageComposer -{ +public class AdventCalendarProductComposer extends MessageComposer { public final boolean visible; public final CalendarRewardObject rewardObject; - public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject) - { + public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject) { this.visible = visible; this.rewardObject = rewardObject; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AdventCalendarProductComposer); this.response.appendBoolean(this.visible); this.response.appendString(this.rewardObject.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxCloseComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxCloseComposer.java index 927bb13e..1955ab93 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxCloseComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxCloseComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MysticBoxCloseComposer extends MessageComposer -{ +public class MysticBoxCloseComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MysticBoxCloseComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxPrizeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxPrizeComposer.java index fd75fdbe..ff450fe2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxPrizeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxPrizeComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MysticBoxPrizeComposer extends MessageComposer -{ +public class MysticBoxPrizeComposer extends MessageComposer { private final String type; private final int itemId; - public MysticBoxPrizeComposer(String type, int itemId) - { + public MysticBoxPrizeComposer(String type, int itemId) { this.type = type; this.itemId = itemId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MysticBoxPrizeComposer); this.response.appendString(this.type); this.response.appendInt(this.itemId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxStartOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxStartOpenComposer.java index 9b699d2e..99b826dd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxStartOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/mysticbox/MysticBoxStartOpenComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MysticBoxStartOpenComposer extends MessageComposer -{ +public class MysticBoxStartOpenComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MysticBoxStartOpenComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionCompletedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionCompletedComposer.java index 5cc82093..4bc4be89 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionCompletedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionCompletedComposer.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; -public class NewYearResolutionCompletedComposer extends MessageComposer -{ +public class NewYearResolutionCompletedComposer extends MessageComposer { public final String badge; - public NewYearResolutionCompletedComposer(String badge) - { + public NewYearResolutionCompletedComposer(String badge) { this.badge = badge; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewYearResolutionCompletedComposer); this.response.appendString(this.badge); this.response.appendString(this.badge); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionComposer.java index fe73253f..7cf0b693 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionComposer.java @@ -4,28 +4,26 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewYearResolutionComposer extends MessageComposer -{ +public class NewYearResolutionComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { //:test 817 i:230 i:1 i:1 i:1 s:NY2013RES i:3 i:0 i:60000000 this.response.init(Outgoing.NewYearResolutionComposer); this.response.appendInt(230); //reward ID or item id? (stuffId) this.response.appendInt(2); //count - this.response.appendInt(1); //achievementId - this.response.appendInt(1); //achievementLevel - this.response.appendString("NY2013RES"); - this.response.appendInt(3); //type ? - this.response.appendInt(0); //Finished/ enabled + this.response.appendInt(1); //achievementId + this.response.appendInt(1); //achievementLevel + this.response.appendString("NY2013RES"); + this.response.appendInt(3); //type ? + this.response.appendInt(0); //Finished/ enabled - this.response.appendInt(2); //achievementId - this.response.appendInt(1); //achievementLevel - this.response.appendString("ADM"); - this.response.appendInt(2); //type ? - this.response.appendInt(0); //Finished/ enabled + this.response.appendInt(2); //achievementId + this.response.appendInt(1); //achievementLevel + this.response.appendString("ADM"); + this.response.appendInt(2); //type ? + this.response.appendInt(0); //Finished/ enabled this.response.appendInt(1000); //Time in secs left. diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionProgressComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionProgressComposer.java index 6304a2eb..8b90878f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionProgressComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/resolution/NewYearResolutionProgressComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewYearResolutionProgressComposer extends MessageComposer -{ +public class NewYearResolutionProgressComposer extends MessageComposer { private final int stuffId; private final int achievementId; private final String achievementName; @@ -13,8 +12,7 @@ public class NewYearResolutionProgressComposer extends MessageComposer private final int progressNeeded; private final int timeLeft; - public NewYearResolutionProgressComposer(int stuffId, int achievementId, String achievementName, int currentProgress, int progressNeeded, int timeLeft) - { + public NewYearResolutionProgressComposer(int stuffId, int achievementId, String achievementName, int currentProgress, int progressNeeded, int timeLeft) { this.stuffId = stuffId; this.achievementId = achievementId; this.achievementName = achievementName; @@ -24,8 +22,7 @@ public class NewYearResolutionProgressComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewYearResolutionProgressComposer); this.response.appendInt(this.stuffId); this.response.appendInt(this.achievementId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorBlockedTilesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorBlockedTilesComposer.java index 590f936e..48635c9f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorBlockedTilesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorBlockedTilesComposer.java @@ -7,25 +7,21 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class FloorPlanEditorBlockedTilesComposer extends MessageComposer -{ +public class FloorPlanEditorBlockedTilesComposer extends MessageComposer { private final Room room; - public FloorPlanEditorBlockedTilesComposer(Room room) - { + public FloorPlanEditorBlockedTilesComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FloorPlanEditorBlockedTilesComposer); THashSet tileList = this.room.getLockedTiles(); this.response.appendInt(tileList.size()); - for(RoomTile node : tileList) - { + for (RoomTile node : tileList) { this.response.appendInt((int) node.x); this.response.appendInt((int) node.y); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorDoorSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorDoorSettingsComposer.java index be153124..0753f323 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorDoorSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/floorplaneditor/FloorPlanEditorDoorSettingsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FloorPlanEditorDoorSettingsComposer extends MessageComposer -{ +public class FloorPlanEditorDoorSettingsComposer extends MessageComposer { private final Room room; - public FloorPlanEditorDoorSettingsComposer(Room room) - { + public FloorPlanEditorDoorSettingsComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FloorPlanEditorDoorSettingsComposer); this.response.appendInt(this.room.getLayout().getDoorX()); this.response.appendInt(this.room.getLayout().getDoorY()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendChatMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendChatMessageComposer.java index aad0cb77..168153ae 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendChatMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendChatMessageComposer.java @@ -7,14 +7,12 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FriendChatMessageComposer extends MessageComposer -{ +public class FriendChatMessageComposer extends MessageComposer { private final Message message; private final int toId; private final int fromId; - public FriendChatMessageComposer(Message message) - { + public FriendChatMessageComposer(Message message) { this.message = message; this.toId = message.getFromId(); this.fromId = message.getFromId(); @@ -27,28 +25,23 @@ public class FriendChatMessageComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendChatMessageComposer); this.response.appendInt(this.toId); this.response.appendString(this.message.getMessage()); this.response.appendInt(Emulator.getIntUnixTimestamp() - this.message.getTimestamp()); - if(this.toId < 0) // group chat + if (this.toId < 0) // group chat { String name = "AUTO_MODERATOR"; String look = "lg-5635282-1193.hd-3091-1.sh-3089-73.cc-156282-64.hr-831-34.ha-1012-1186.ch-3050-62-62"; - if (this.fromId > 0) - { + if (this.fromId > 0) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.fromId); - if (habbo != null) - { + if (habbo != null) { name = habbo.getHabboInfo().getUsername(); look = habbo.getHabboInfo().getLook(); - } - else - { + } else { name = "UNKNOWN"; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendFindingRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendFindingRoomComposer.java index f28f8219..226f906d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendFindingRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendFindingRoomComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FriendFindingRoomComposer extends MessageComposer -{ +public class FriendFindingRoomComposer extends MessageComposer { public static final int NO_ROOM_FOUND = 0; public static final int ROOM_FOUND = 1; private final int errorCode; - public FriendFindingRoomComposer(int errorCode) - { + public FriendFindingRoomComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendFindingRoomComposer); this.response.appendInt(this.errorCode); return this.response; 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 0daf810b..47847c34 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 @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FriendNotificationComposer extends MessageComposer -{ +public class FriendNotificationComposer extends MessageComposer { public final static int INSTANT_MESSAGE = -1; public final static int ROOM_EVENT = 0; public final static int ACHIEVEMENT_COMPLETED = 1; @@ -18,16 +17,14 @@ public class FriendNotificationComposer extends MessageComposer private final int type; private final String data; - public FriendNotificationComposer(int userId, int type, String data) - { + public FriendNotificationComposer(int userId, int type, String data) { this.userId = userId; this.type = type; this.data = data; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendToolbarNotificationComposer); this.response.appendString(this.userId + ""); this.response.appendInt(this.type); 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 index dd492b5d..66188f6e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FriendRequestComposer extends MessageComposer -{ +public class FriendRequestComposer extends MessageComposer { private final Habbo habbo; - public FriendRequestComposer(Habbo habbo) - { + public FriendRequestComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendRequestComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestErrorComposer.java index 5f1ca458..37385c35 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendRequestErrorComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FriendRequestErrorComposer extends MessageComposer -{ +public class FriendRequestErrorComposer extends MessageComposer { public static final int FRIEND_LIST_OWN_FULL = 1; public static final int TARGET_NOT_ACCEPTING_REQUESTS = 3; public static final int TARGET_NOT_FOUND = 4; private final int errorCode; - public FriendRequestErrorComposer(int errorCode) - { + public FriendRequestErrorComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendRequestErrorComposer); this.response.appendInt(0); this.response.appendInt(this.errorCode); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 10ac11cb..8f3ccc3b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -11,20 +11,16 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class FriendsComposer extends MessageComposer -{ +public class FriendsComposer extends MessageComposer { private final Habbo habbo; - public FriendsComposer(Habbo habbo) - { + public FriendsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { - try - { + public ServerMessage compose() { + try { this.response.init(Outgoing.FriendsComposer); //this.response.appendInt(300); @@ -70,9 +66,7 @@ public class FriendsComposer extends MessageComposer }*/ return this.response; - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/LoadFriendRequestsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/LoadFriendRequestsComposer.java index 2a06bb67..b77206c5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/LoadFriendRequestsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/LoadFriendRequestsComposer.java @@ -6,27 +6,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class LoadFriendRequestsComposer extends MessageComposer -{ +public class LoadFriendRequestsComposer extends MessageComposer { private final Habbo habbo; - public LoadFriendRequestsComposer(Habbo habbo) - { + public LoadFriendRequestsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.LoadFriendRequestsComposer); - synchronized (this.habbo.getMessenger().getFriendRequests()) - { + synchronized (this.habbo.getMessenger().getFriendRequests()) { this.response.appendInt(this.habbo.getMessenger().getFriendRequests().size()); this.response.appendInt(this.habbo.getMessenger().getFriendRequests().size()); - for (FriendRequest friendRequest : this.habbo.getMessenger().getFriendRequests()) - { + for (FriendRequest friendRequest : this.habbo.getMessenger().getFriendRequests()) { this.response.appendInt(friendRequest.getId()); this.response.appendString(friendRequest.getUsername()); this.response.appendString(friendRequest.getLook()); 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 46505885..948bfe35 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 @@ -6,27 +6,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MessengerInitComposer extends MessageComposer -{ +public class MessengerInitComposer extends MessageComposer { private final Habbo habbo; - public MessengerInitComposer(Habbo habbo) - { + public MessengerInitComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MessengerInitComposer); - if (this.habbo.hasPermission("acc_infinite_friends")) - { + if (this.habbo.hasPermission("acc_infinite_friends")) { this.response.appendInt(Integer.MAX_VALUE); this.response.appendInt(1337); this.response.appendInt(Integer.MAX_VALUE); - } - else - { + } else { this.response.appendInt(Messenger.MAXIMUM_FRIENDS); this.response.appendInt(1337); this.response.appendInt(Messenger.MAXIMUM_FRIENDS_HC); 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 ea289652..a9c10163 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 @@ -5,30 +5,25 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; -public class RemoveFriendComposer extends MessageComposer -{ +public class RemoveFriendComposer extends MessageComposer { private final TIntArrayList unfriendIds; - public RemoveFriendComposer(TIntArrayList unfriendIds) - { + public RemoveFriendComposer(TIntArrayList unfriendIds) { this.unfriendIds = unfriendIds; } - public RemoveFriendComposer(int i) - { + public RemoveFriendComposer(int i) { this.unfriendIds = new TIntArrayList(); this.unfriendIds.add(i); } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateFriendComposer); this.response.appendInt(0); this.response.appendInt(this.unfriendIds.size()); - for(int i = 0; i < this.unfriendIds.size(); i++) - { + for (int i = 0; i < this.unfriendIds.size(); i++) { this.response.appendInt(-1); this.response.appendInt(this.unfriendIds.get(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 64a51315..3aba1888 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomInviteComposer extends MessageComposer -{ +public class RoomInviteComposer extends MessageComposer { private final int userId; private final String message; - public RoomInviteComposer(int userId, String message) - { + public RoomInviteComposer(int userId, String message) { this.userId = userId; this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomInviteComposer); this.response.appendInt(this.userId); this.response.appendString(this.message); 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 a1106c5b..1543d09c 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 @@ -7,28 +7,23 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -public class RoomInviteErrorComposer extends MessageComposer -{ +public class RoomInviteErrorComposer extends MessageComposer { private final int errorCode; private final THashSet buddies; - public RoomInviteErrorComposer(int errorCode, THashSet buddies) - { + public RoomInviteErrorComposer(int errorCode, THashSet buddies) { this.errorCode = errorCode; this.buddies = buddies; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomInviteErrorComposer); this.response.appendInt(this.errorCode); this.response.appendInt(this.buddies.size()); - this.buddies.forEach(new TObjectProcedure() - { + this.buddies.forEach(new TObjectProcedure() { @Override - public boolean execute(MessengerBuddy object) - { + public boolean execute(MessengerBuddy object) { RoomInviteErrorComposer.this.response.appendInt(object.getId()); return true; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/StalkErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/StalkErrorComposer.java index 71e3f202..cecf26a1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/StalkErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/StalkErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class StalkErrorComposer extends MessageComposer -{ +public class StalkErrorComposer extends MessageComposer { public static final int NOT_IN_FRIEND_LIST = 0; public static final int FRIEND_OFFLINE = 1; public static final int FRIEND_NOT_IN_ROOM = 2; @@ -13,14 +12,12 @@ public class StalkErrorComposer extends MessageComposer private final int errorCode; - public StalkErrorComposer(int errorCode) - { + public StalkErrorComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.StalkErrorComposer); this.response.appendInt(this.errorCode); 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 6d83b140..7f96aab7 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 @@ -7,30 +7,25 @@ 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 -{ +public class UpdateFriendComposer extends MessageComposer { private MessengerBuddy buddy; private Habbo habbo; - public UpdateFriendComposer(MessengerBuddy buddy) - { + public UpdateFriendComposer(MessengerBuddy buddy) { this.buddy = buddy; } - public UpdateFriendComposer(Habbo habbo) - { + public UpdateFriendComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateFriendComposer); - if(this.buddy != null) - { + if (this.buddy != null) { this.response.appendInt(0); this.response.appendInt(1); this.response.appendInt(0); @@ -48,9 +43,7 @@ public class UpdateFriendComposer extends MessageComposer this.response.appendBoolean(false); this.response.appendBoolean(false); this.response.appendShort(this.buddy.getRelation()); - } - else - { + } else { this.response.appendInt(0); this.response.appendInt(1); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java index 31e873c2..d27df321 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java @@ -7,36 +7,30 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class UserSearchResultComposer extends MessageComposer -{ +public class UserSearchResultComposer extends MessageComposer { private final THashSet users; private final THashSet friends; private final Habbo habbo; - public UserSearchResultComposer(THashSet users, THashSet friends, Habbo habbo) - { + public UserSearchResultComposer(THashSet users, THashSet friends, Habbo habbo) { this.users = users; this.friends = friends; this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserSearchResultComposer); THashSet u = new THashSet<>(); - for(MessengerBuddy buddy : this.users) - { - if(!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) - { + for (MessengerBuddy buddy : this.users) { + if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) { u.add(buddy); } } this.response.appendInt(this.friends.size()); - for(MessengerBuddy buddy : this.friends) - { + for (MessengerBuddy buddy : this.friends) { this.response.appendInt(buddy.getId()); this.response.appendString(buddy.getUsername()); this.response.appendString(buddy.getMotto()); @@ -49,8 +43,7 @@ public class UserSearchResultComposer extends MessageComposer } this.response.appendInt(u.size()); - for(MessengerBuddy buddy : u) - { + for (MessengerBuddy buddy : u) { this.response.appendInt(buddy.getId()); this.response.appendString(buddy.getUsername()); this.response.appendString(buddy.getMotto()); @@ -65,11 +58,9 @@ public class UserSearchResultComposer extends MessageComposer return this.response; } - private boolean inFriendList(MessengerBuddy buddy) - { - for(MessengerBuddy friend : this.friends) - { - if(friend.getUsername().equals(buddy.getUsername())) + private boolean inFriendList(MessengerBuddy buddy) { + for (MessengerBuddy friend : this.friends) { + if (friend.getUsername().equals(buddy.getUsername())) return true; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAccountInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAccountInfoComposer.java index 8a7bd355..f44d06ab 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAccountInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAccountInfoComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GameCenterAccountInfoComposer extends MessageComposer -{ +public class GameCenterAccountInfoComposer extends MessageComposer { private final int gameId; private final int gamesLeft; - public GameCenterAccountInfoComposer(int gameId, int gamesLeft) - { + public GameCenterAccountInfoComposer(int gameId, int gamesLeft) { this.gameId = gameId; this.gamesLeft = gamesLeft; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GameCenterAccountInfoComposer); this.response.appendInt(this.gameId); this.response.appendInt(this.gamesLeft); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAchievementsConfigurationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAchievementsConfigurationComposer.java index 18975810..1d7455b5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAchievementsConfigurationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterAchievementsConfigurationComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.gamecenter; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class GameCenterAchievementsConfigurationComposer extends MessageComposer -{ +public class GameCenterAchievementsConfigurationComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2265); this.response.appendInt(0); this.response.appendInt(0); @@ -19,11 +17,11 @@ public class GameCenterAchievementsConfigurationComposer extends MessageComposer this.response.appendInt(0); this.response.appendInt(0); this.response.appendInt(0); - this.response.appendInt(3); - this.response.appendInt(1); - this.response.appendInt(1); - this.response.appendString("BaseJumpBigParachute"); - this.response.appendInt(1); + this.response.appendInt(3); + this.response.appendInt(1); + this.response.appendInt(1); + this.response.appendString("BaseJumpBigParachute"); + this.response.appendInt(1); return this.response; } } \ No newline at end of file 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 89d94eb7..c805811d 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 @@ -4,23 +4,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GameCenterGameComposer extends MessageComposer -{ +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; - public GameCenterGameComposer(int gameId, int status) - { + public GameCenterGameComposer(int gameId, int status) { this.gameId = gameId; this.status = status; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GameCenterGameComposer); this.response.appendInt(this.gameId); this.response.appendInt(this.status); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameListComposer.java index bd844b99..a63dd771 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/GameCenterGameListComposer.java @@ -5,11 +5,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GameCenterGameListComposer extends MessageComposer -{ +public class GameCenterGameListComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GameCenterGameListComposer); this.response.appendInt(2);//Count diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpJoinQueueComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpJoinQueueComposer.java index 47024cde..c47d8520 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpJoinQueueComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpJoinQueueComposer.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; -public class BaseJumpJoinQueueComposer extends MessageComposer -{ +public class BaseJumpJoinQueueComposer extends MessageComposer { private final int gameId; - public BaseJumpJoinQueueComposer(int gameId) - { + public BaseJumpJoinQueueComposer(int gameId) { this.gameId = gameId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BaseJumpJoinQueueComposer); this.response.appendInt(this.gameId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLeaveQueueComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLeaveQueueComposer.java index 8b98d571..423c85e3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLeaveQueueComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLeaveQueueComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BaseJumpLeaveQueueComposer extends MessageComposer -{ +public class BaseJumpLeaveQueueComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BaseJumpLeaveQueueComposer); this.response.appendInt(3); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java index 1e5984f4..0a6a45a8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java @@ -6,26 +6,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BaseJumpLoadGameComposer extends MessageComposer -{ +public class BaseJumpLoadGameComposer extends MessageComposer { public static String FASTFOOD_KEY = ""; private final GameClient client; private final int game; - public BaseJumpLoadGameComposer(GameClient client, int game) - { + public BaseJumpLoadGameComposer(GameClient client, int game) { this.client = client; this.game = game; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BaseJumpLoadGameComposer); - if (this.game == 3) - { + if (this.game == 3) { this.response.appendInt(3); this.response.appendString("basejump"); this.response.appendString(Emulator.getConfig().getValue("basejump.url")); @@ -49,12 +45,6 @@ public class BaseJumpLoadGameComposer extends MessageComposer this.response.appendString("3002"); - - - - - - } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameURLComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameURLComposer.java index f2dcae8f..15caff06 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameURLComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameURLComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BaseJumpLoadGameURLComposer extends MessageComposer -{ +public class BaseJumpLoadGameURLComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BaseJumpLoadGameURLComposer); this.response.appendInt(4); this.response.appendString("1351418858673"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpUnloadGameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpUnloadGameComposer.java index 9770fac9..42b44ba2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpUnloadGameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpUnloadGameComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BaseJumpUnloadGameComposer extends MessageComposer -{ +public class BaseJumpUnloadGameComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BaseJumpUnloadGameComposer); this.response.appendInt(3); this.response.appendString("basejump"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/MinimailCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/MinimailCountComposer.java index 502aac66..6245ffb6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/MinimailCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/MinimailCountComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MinimailCountComposer extends MessageComposer -{ +public class MinimailCountComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MinimailCountComposer); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/PickMonthlyClubGiftNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/PickMonthlyClubGiftNotificationComposer.java index 4f62dd7a..86b194d0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/PickMonthlyClubGiftNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/PickMonthlyClubGiftNotificationComposer.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; -public class PickMonthlyClubGiftNotificationComposer extends MessageComposer -{ +public class PickMonthlyClubGiftNotificationComposer extends MessageComposer { private final int count; - public PickMonthlyClubGiftNotificationComposer(int count) - { + public PickMonthlyClubGiftNotificationComposer(int count) { this.count = count; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PickMonthlyClubGiftNotificationComposer); this.response.appendInt(this.count); return this.response; 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 90b0e30a..8eca297a 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 @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BotErrorComposer extends MessageComposer -{ +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; public static final int ROOM_ERROR_MAX_BOTS = 2; @@ -14,14 +13,12 @@ public class BotErrorComposer extends MessageComposer private final int errorCode; - public BotErrorComposer(int errorCode) - { + public BotErrorComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BotErrorComposer); this.response.appendInt(this.errorCode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertComposer.java index c39ff4ea..4e8cfb46 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertComposer.java @@ -7,38 +7,32 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class BubbleAlertComposer extends MessageComposer -{ +public class BubbleAlertComposer extends MessageComposer { private final String errorKey; private final THashMap keys; - public BubbleAlertComposer(String errorKey, THashMap keys) - { + public BubbleAlertComposer(String errorKey, THashMap keys) { this.errorKey = errorKey; this.keys = keys; } - public BubbleAlertComposer(String errorKey, String message) - { + public BubbleAlertComposer(String errorKey, String message) { this.errorKey = errorKey; this.keys = new THashMap<>(); this.keys.put("message", message); } - public BubbleAlertComposer(String errorKey) - { + public BubbleAlertComposer(String errorKey) { this.errorKey = errorKey; this.keys = new THashMap<>(); } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BubbleAlertComposer); this.response.appendString(this.errorKey); this.response.appendInt(this.keys.size()); - for(Map.Entry set : this.keys.entrySet()) - { + for (Map.Entry set : this.keys.entrySet()) { this.response.appendString(set.getKey()); this.response.appendString(set.getValue()); } 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 5c9da1db..d3f30596 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,7 +1,6 @@ package com.eu.habbo.messages.outgoing.generic.alerts; -public enum BubbleAlertKeys -{ +public enum BubbleAlertKeys { ADMIN_PERSISTENT("admin.persistent"), ADMIN_TRANSIENT("admin.transient"), BUILDERS_CLUB_MEMBERSHIP_EXPIRED("builders_club.membership_expired"), @@ -37,8 +36,7 @@ public enum BubbleAlertKeys public final String key; - BubbleAlertKeys(String key) - { + BubbleAlertKeys(String key) { this.key = key; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomNotificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomNotificationComposer.java index 36432486..9d68bdf4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomNotificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/CustomNotificationComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CustomNotificationComposer extends MessageComposer -{ +public class CustomNotificationComposer extends MessageComposer { public static final int HOPPER_NO_COSTUME = 1; public static final int HOPPER_NO_HC = 2; public static final int GATE_NO_HC = 3; @@ -14,14 +13,12 @@ public class CustomNotificationComposer extends MessageComposer private final int type; - public CustomNotificationComposer(int type) - { + public CustomNotificationComposer(int type) { this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CustomNotificationComposer); this.response.appendInt(this.type); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericAlertComposer.java index ea7b8803..4b98c4ea 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericAlertComposer.java @@ -5,23 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GenericAlertComposer extends MessageComposer -{ +public class GenericAlertComposer extends MessageComposer { private final String message; - public GenericAlertComposer(String message) - { + public GenericAlertComposer(String message) { this.message = message; } - public GenericAlertComposer(String message, Habbo habbo) - { + public GenericAlertComposer(String message, Habbo habbo) { this.message = message.replace("%username%", habbo.getHabboInfo().getUsername()); } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GenericAlertComposer); this.response.appendString(this.message); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorMessagesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorMessagesComposer.java index ea94bff1..198b1556 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorMessagesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/GenericErrorMessagesComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GenericErrorMessagesComposer extends MessageComposer -{ +public class GenericErrorMessagesComposer extends MessageComposer { public static final int AUTHENTICATION_FAILED = -3; public static final int CONNECTING_TO_THE_SERVER_FAILED = -400; public static final int KICKED_OUT_OF_THE_ROOM = 4008; @@ -15,14 +14,12 @@ public class GenericErrorMessagesComposer extends MessageComposer private final int errorCode; - public GenericErrorMessagesComposer(int errorCode) - { + public GenericErrorMessagesComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GenericErrorMessages); this.response.appendInt(this.errorCode); return this.response; 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 88b8198a..123183eb 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelClosedAndOpensComposer extends MessageComposer -{ +public class HotelClosedAndOpensComposer extends MessageComposer { private final int hour; private final int minute; - public HotelClosedAndOpensComposer(int hour, int minute) - { + public HotelClosedAndOpensComposer(int hour, int minute) { this.hour = hour; this.minute = minute; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelClosedAndOpensComposer); this.response.appendInt(this.hour); this.response.appendInt(this.minute); 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 cb8ad53a..44c51ca9 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 @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelClosesAndWillOpenAtComposer extends MessageComposer -{ +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) - { + public HotelClosesAndWillOpenAtComposer(int hour, int minute, boolean disconnected) { this.hour = hour; this.minute = minute; this.disconnected = disconnected; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelClosesAndWillOpenAtComposer); this.response.appendInt(this.hour); this.response.appendInt(this.minute); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesAndBackInComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesAndBackInComposer.java index e38e3c25..0c7b29b8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesAndBackInComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/HotelWillCloseInMinutesAndBackInComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelWillCloseInMinutesAndBackInComposer extends MessageComposer -{ +public class HotelWillCloseInMinutesAndBackInComposer extends MessageComposer { private final int closeInMinutes; private final int reopenInMinutes; - public HotelWillCloseInMinutesAndBackInComposer(int closeInMinutes, int reopenInMinutes) - { + public HotelWillCloseInMinutesAndBackInComposer(int closeInMinutes, int reopenInMinutes) { this.closeInMinutes = closeInMinutes; this.reopenInMinutes = reopenInMinutes; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelWillCloseInMinutesAndBackInComposer); this.response.appendBoolean(true); this.response.appendInt(this.closeInMinutes); 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 617e46f9..30811bec 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 @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelWillCloseInMinutesComposer extends MessageComposer -{ +public class HotelWillCloseInMinutesComposer extends MessageComposer { private final int minutes; - public HotelWillCloseInMinutesComposer(int minutes) - { + public HotelWillCloseInMinutesComposer(int minutes) { this.minutes = minutes; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelWillCloseInMinutesComposer); this.response.appendInt(this.minutes); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MessagesForYouComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MessagesForYouComposer.java index e6ac7820..cdb7e3b7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MessagesForYouComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/MessagesForYouComposer.java @@ -7,36 +7,30 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; import java.util.List; -public class MessagesForYouComposer extends MessageComposer -{ +public class MessagesForYouComposer extends MessageComposer { private final String[] messages; private final List newMessages; - public MessagesForYouComposer(String[] messages) - { + public MessagesForYouComposer(String[] messages) { this.messages = messages; this.newMessages = new ArrayList<>(); } - public MessagesForYouComposer(List newMessages) - { + public MessagesForYouComposer(List newMessages) { this.newMessages = newMessages; this.messages = new String[]{}; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MessagesForYouComposer); this.response.appendInt(this.messages.length + this.newMessages.size()); - for(String s : this.messages) - { + for (String s : this.messages) { this.response.appendString(s); } - for (String s : this.newMessages) - { + for (String s : this.newMessages) { this.response.appendString(s); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetErrorComposer.java index 0caaef9d..ccffcdfe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/PetErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetErrorComposer extends MessageComposer -{ +public class PetErrorComposer extends MessageComposer { public static final int ROOM_ERROR_PETS_FORBIDDEN_IN_HOTEL = 0; public static final int ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT = 1; public static final int ROOM_ERROR_MAX_PETS = 2; @@ -15,14 +14,12 @@ public class PetErrorComposer extends MessageComposer private final int errorCode; - public PetErrorComposer(int errorCode) - { + public PetErrorComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetErrorComposer); this.response.appendInt(this.errorCode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertAndOpenHabboWayComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertAndOpenHabboWayComposer.java index 7dadc242..438af967 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertAndOpenHabboWayComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertAndOpenHabboWayComposer.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; -public class StaffAlertAndOpenHabboWayComposer extends MessageComposer -{ +public class StaffAlertAndOpenHabboWayComposer extends MessageComposer { private final String message; - public StaffAlertAndOpenHabboWayComposer(String message) - { + public StaffAlertAndOpenHabboWayComposer(String message) { this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.StaffAlertAndOpenHabboWayComposer); this.response.appendString(this.message); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWIthLinkAndOpenHabboWayComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWIthLinkAndOpenHabboWayComposer.java index 93b4cee7..3df101ef 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWIthLinkAndOpenHabboWayComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWIthLinkAndOpenHabboWayComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class StaffAlertWIthLinkAndOpenHabboWayComposer extends MessageComposer -{ +public class StaffAlertWIthLinkAndOpenHabboWayComposer extends MessageComposer { private final String message; private final String link; - public StaffAlertWIthLinkAndOpenHabboWayComposer(String message, String link) - { + public StaffAlertWIthLinkAndOpenHabboWayComposer(String message, String link) { this.message = message; this.link = link; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.StaffAlertWIthLinkAndOpenHabboWayComposer); this.response.appendString(this.message); this.response.appendString(this.link); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWithLinkComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWithLinkComposer.java index fe42c034..ce52ba79 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWithLinkComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/StaffAlertWithLinkComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class StaffAlertWithLinkComposer extends MessageComposer -{ +public class StaffAlertWithLinkComposer extends MessageComposer { private final String message; private final String link; - public StaffAlertWithLinkComposer(String message, String link) - { + public StaffAlertWithLinkComposer(String message, String link) { this.message = message; this.link = link; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.StaffAlertWithLinkComposer); this.response.appendString(this.message); this.response.appendString(this.link); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UpdateFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UpdateFailedComposer.java index 96142123..21094a88 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UpdateFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/UpdateFailedComposer.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; -public class UpdateFailedComposer extends MessageComposer -{ +public class UpdateFailedComposer extends MessageComposer { private final String message; - public UpdateFailedComposer(String message) - { + public UpdateFailedComposer(String message) { this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateFailedComposer); this.response.appendString(this.message); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/testcomposer.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/testcomposer.java index b1ff3f84..49caea29 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/testcomposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/testcomposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.generic; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class testcomposer extends MessageComposer -{ +public class testcomposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3019); this.response.appendInt(3); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianNewReportReceivedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianNewReportReceivedComposer.java index cb8c859c..e5323e30 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianNewReportReceivedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianNewReportReceivedComposer.java @@ -1,16 +1,13 @@ package com.eu.habbo.messages.outgoing.guardians; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.guides.GuardianTicket; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuardianNewReportReceivedComposer extends MessageComposer -{ +public class GuardianNewReportReceivedComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuardianNewReportReceivedComposer); this.response.appendInt(Emulator.getConfig().getInt("guardians.accept.timer")); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingRequestedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingRequestedComposer.java index e6229829..9365c4d3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingRequestedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingRequestedComposer.java @@ -9,18 +9,15 @@ import gnu.trove.map.hash.TIntIntHashMap; import java.util.Calendar; -public class GuardianVotingRequestedComposer extends MessageComposer -{ +public class GuardianVotingRequestedComposer extends MessageComposer { private final GuardianTicket ticket; - public GuardianVotingRequestedComposer(GuardianTicket ticket) - { + public GuardianVotingRequestedComposer(GuardianTicket ticket) { this.ticket = ticket; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { TIntIntHashMap mappedUsers = new TIntIntHashMap(); mappedUsers.put(this.ticket.getReported().getHabboInfo().getId(), 0); @@ -35,10 +32,8 @@ public class GuardianVotingRequestedComposer extends MessageComposer fullMessage.append("\r"); - for(ModToolChatLog chatLog : this.ticket.getChatLogs()) - { - if(!mappedUsers.containsKey(chatLog.habboId)) - { + for (ModToolChatLog chatLog : this.ticket.getChatLogs()) { + if (!mappedUsers.containsKey(chatLog.habboId)) { mappedUsers.put(chatLog.habboId, mappedUsers.size()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingResultComposer.java index 4060444a..684d0a12 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingResultComposer.java @@ -9,29 +9,25 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class GuardianVotingResultComposer extends MessageComposer -{ +public class GuardianVotingResultComposer extends MessageComposer { private final GuardianTicket ticket; private final GuardianVote vote; - public GuardianVotingResultComposer(GuardianTicket ticket, GuardianVote vote) - { + public GuardianVotingResultComposer(GuardianTicket ticket, GuardianVote vote) { this.ticket = ticket; this.vote = vote; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuardianVotingResultComposer); this.response.appendInt(this.ticket.getVerdict().getType()); //Final Verdict this.response.appendInt(this.vote.type.getType()); //Your vote this.response.appendInt(this.ticket.getVotes().size() - 1); //Other votes count. - for(Map.Entry set : this.ticket.getVotes().entrySet()) - { - if(set.getValue().equals(this.vote)) + for (Map.Entry set : this.ticket.getVotes().entrySet()) { + if (set.getValue().equals(this.vote)) continue; this.response.appendInt(set.getValue().type.getType()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingTimeEnded.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingTimeEnded.java index 561db3ef..32527594 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingTimeEnded.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingTimeEnded.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuardianVotingTimeEnded extends MessageComposer -{ +public class GuardianVotingTimeEnded extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuardianVotingTimeEnded); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingVotesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingVotesComposer.java index 3c0d78bf..feeea391 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingVotesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guardians/GuardianVotingVotesComposer.java @@ -9,28 +9,24 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; -public class GuardianVotingVotesComposer extends MessageComposer -{ +public class GuardianVotingVotesComposer extends MessageComposer { private final GuardianTicket ticket; private final Habbo guardian; - public GuardianVotingVotesComposer(GuardianTicket ticket, Habbo guardian) - { + public GuardianVotingVotesComposer(GuardianTicket ticket, Habbo guardian) { this.ticket = ticket; this.guardian = guardian; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuardianVotingVotesComposer); ArrayList votes = this.ticket.getSortedVotes(this.guardian); this.response.appendInt(votes.size()); - for(GuardianVote vote : votes) - { + for (GuardianVote vote : votes) { this.response.appendInt(vote.type.getType()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/BullyReportClosedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/BullyReportClosedComposer.java index 6b680d49..e8a048ef 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/BullyReportClosedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/BullyReportClosedComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BullyReportClosedComposer extends MessageComposer -{ +public class BullyReportClosedComposer extends MessageComposer { public final static int CLOSED = 1; public final static int MISUSE = 2; public final int code; - public BullyReportClosedComposer(int code) - { + public BullyReportClosedComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BullyReportClosedComposer); this.response.appendInt(this.code); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedComposer.java index 41ccb3b9..60ff434e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionAttachedComposer.java @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionAttachedComposer extends MessageComposer -{ +public class GuideSessionAttachedComposer extends MessageComposer { private final GuideTour tour; private final boolean isHelper; - public GuideSessionAttachedComposer(GuideTour tour, boolean isHelper) - { + public GuideSessionAttachedComposer(GuideTour tour, boolean isHelper) { this.tour = tour; this.isHelper = isHelper; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { //:test 3549 b:1 i:1 s:abcd i:100 this.response.init(Outgoing.GuideSessionAttachedComposer); this.response.appendBoolean(this.isHelper); //? //isHelper diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionDetachedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionDetachedComposer.java index 6db271c9..8db0a8ac 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionDetachedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionDetachedComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionDetachedComposer extends MessageComposer -{ +public class GuideSessionDetachedComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionDetachedComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedComposer.java index 739553ac..7ed37fdc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionEndedComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionEndedComposer extends MessageComposer -{ +public class GuideSessionEndedComposer extends MessageComposer { public static final int SOMETHING_WRONG = 0; public static final int HELP_CASE_CLOSED = 1; private final int errorCode; - public GuideSessionEndedComposer(int errorCode) - { + public GuideSessionEndedComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionEndedComposer); this.response.appendInt(this.errorCode); //? return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorComposer.java index 21dd58c0..4f8da806 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionErrorComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionErrorComposer extends MessageComposer -{ - public static final int SOMETHING_WRONG_REQUEST = 0; - public static final int NO_HELPERS_AVAILABLE = 1; - public static final int NO_GUARDIANS_AVAILABLE = 2; +public class GuideSessionErrorComposer extends MessageComposer { + public static final int SOMETHING_WRONG_REQUEST = 0; + public static final int NO_HELPERS_AVAILABLE = 1; + public static final int NO_GUARDIANS_AVAILABLE = 2; private final int errorCode; - public GuideSessionErrorComposer(int errorCode) - { + public GuideSessionErrorComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionErrorComposer); this.response.appendInt(this.errorCode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomComposer.java index 82c7b761..d4641448 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomComposer.java @@ -5,19 +5,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionInvitedToGuideRoomComposer extends MessageComposer -{ +public class GuideSessionInvitedToGuideRoomComposer extends MessageComposer { private final Room room; - public GuideSessionInvitedToGuideRoomComposer(Room room) - { + public GuideSessionInvitedToGuideRoomComposer(Room room) { this.room = room; } //Helper invites noob @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionInvitedToGuideRoomComposer); this.response.appendInt(this.room != null ? this.room.getId() : 0); this.response.appendString(this.room != null ? this.room.getName() : ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageComposer.java index 7c6bc903..1dc03b79 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionMessageComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionMessageComposer extends MessageComposer -{ +public class GuideSessionMessageComposer extends MessageComposer { private final GuideChatMessage message; - public GuideSessionMessageComposer(GuideChatMessage message) - { + public GuideSessionMessageComposer(GuideChatMessage message) { this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionMessageComposer); this.response.appendString(this.message.message); //Message this.response.appendInt(this.message.userId); //Sender ID diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsPlayingComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsPlayingComposer.java index f730f5a1..43ef1793 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsPlayingComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionPartnerIsPlayingComposer.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; -public class GuideSessionPartnerIsPlayingComposer extends MessageComposer -{ +public class GuideSessionPartnerIsPlayingComposer extends MessageComposer { public final boolean isPlaying; - public GuideSessionPartnerIsPlayingComposer(boolean isPlaying) - { + public GuideSessionPartnerIsPlayingComposer(boolean isPlaying) { this.isPlaying = isPlaying; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionPartnerIsPlayingComposer); this.response.appendBoolean(this.isPlaying); 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 e8389bbb..c587f548 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 @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionPartnerIsTypingComposer extends MessageComposer -{ +public class GuideSessionPartnerIsTypingComposer extends MessageComposer { private final boolean typing; - public GuideSessionPartnerIsTypingComposer(boolean typing) - { + public GuideSessionPartnerIsTypingComposer(boolean typing) { this.typing = typing; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionPartnerIsTypingComposer); this.response.appendBoolean(this.typing); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomComposer.java index c887f8b4..c0b4ead6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionRequesterRoomComposer extends MessageComposer -{ +public class GuideSessionRequesterRoomComposer extends MessageComposer { private final Room room; - public GuideSessionRequesterRoomComposer(Room room) - { + public GuideSessionRequesterRoomComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionRequesterRoomComposer); this.response.appendInt(this.room != null ? this.room.getId() : 0); return this.response; 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 5aee29e3..d0e0ae64 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideSessionStartedComposer extends MessageComposer -{ +public class GuideSessionStartedComposer extends MessageComposer { private final GuideTour tour; - public GuideSessionStartedComposer(GuideTour tour) - { + public GuideSessionStartedComposer(GuideTour tour) { this.tour = tour; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideSessionStartedComposer); this.response.appendInt(this.tour.getNoob().getHabboInfo().getId()); this.response.appendString(this.tour.getNoob().getHabboInfo().getUsername()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideToolsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideToolsComposer.java index 966ae307..cd4da1ff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideToolsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideToolsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuideToolsComposer extends MessageComposer -{ +public class GuideToolsComposer extends MessageComposer { private final boolean onDuty; - public GuideToolsComposer(boolean onDuty) - { + public GuideToolsComposer(boolean onDuty) { this.onDuty = onDuty; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuideToolsComposer); this.response.appendBoolean(this.onDuty); //OnDuty this.response.appendInt(0); //Guides On Duty diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildAcceptMemberErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildAcceptMemberErrorComposer.java index fd43293d..fdd2e4ba 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildAcceptMemberErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildAcceptMemberErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildAcceptMemberErrorComposer extends MessageComposer -{ +public class GuildAcceptMemberErrorComposer extends MessageComposer { public final static int NO_LONGER_MEMBER = 0; public final static int ALREADY_REJECTED = 1; public final static int ALREADY_ACCEPTED = 2; @@ -13,15 +12,13 @@ public class GuildAcceptMemberErrorComposer extends MessageComposer private final int guildId; private final int errorCode; - public GuildAcceptMemberErrorComposer(int guildId, int errorCode) - { + public GuildAcceptMemberErrorComposer(int guildId, int errorCode) { this.guildId = guildId; this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildAcceptMemberErrorComposer); this.response.appendInt(this.guildId); this.response.appendInt(this.errorCode); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBoughtComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBoughtComposer.java index 07d38735..e8c3ed71 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBoughtComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBoughtComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildBoughtComposer extends MessageComposer -{ +public class GuildBoughtComposer extends MessageComposer { private final Guild guild; - public GuildBoughtComposer(Guild guild) - { + public GuildBoughtComposer(Guild guild) { this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildBoughtComposer); this.response.appendInt(this.guild.getRoomId()); this.response.appendInt(this.guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBuyRoomsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBuyRoomsComposer.java index 8b7de7a6..fe038f26 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBuyRoomsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildBuyRoomsComposer.java @@ -7,24 +7,20 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class GuildBuyRoomsComposer extends MessageComposer -{ +public class GuildBuyRoomsComposer extends MessageComposer { private final THashSet rooms; - public GuildBuyRoomsComposer(THashSet rooms) - { + public GuildBuyRoomsComposer(THashSet rooms) { this.rooms = rooms; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildBuyRoomsComposer); this.response.appendInt(Emulator.getConfig().getInt("catalog.guild.price")); this.response.appendInt(this.rooms.size()); - for (Room room : this.rooms) - { + for (Room room : this.rooms) { this.response.appendInt(room.getId()); this.response.appendString(room.getName()); this.response.appendBoolean(false); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildConfirmRemoveMemberComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildConfirmRemoveMemberComposer.java index 4a124ffb..cba6099f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildConfirmRemoveMemberComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildConfirmRemoveMemberComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildConfirmRemoveMemberComposer extends MessageComposer -{ +public class GuildConfirmRemoveMemberComposer extends MessageComposer { private int userId; private int furniCount; - public GuildConfirmRemoveMemberComposer(int userId, int furniCount) - { + public GuildConfirmRemoveMemberComposer(int userId, int furniCount) { this.userId = userId; this.furniCount = furniCount; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildConfirmRemoveMemberComposer); this.response.appendInt(this.userId); this.response.appendInt(this.furniCount); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailComposer.java index 5e15647f..eea708f8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildEditFailComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildEditFailComposer extends MessageComposer -{ +public class GuildEditFailComposer 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; @@ -13,14 +12,12 @@ public class GuildEditFailComposer extends MessageComposer private int errorCode; - public GuildEditFailComposer(int errorCode) - { + public GuildEditFailComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildEditFailComposer); this.response.appendInt(this.errorCode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java index 8e1a2190..118a57d7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildFavoriteRoomUserUpdateComposer extends MessageComposer -{ +public class GuildFavoriteRoomUserUpdateComposer extends MessageComposer { private RoomUnit roomUnit; private Guild guild; - public GuildFavoriteRoomUserUpdateComposer(RoomUnit roomUnit, Guild guild) - { + public GuildFavoriteRoomUserUpdateComposer(RoomUnit roomUnit, Guild guild) { this.roomUnit = roomUnit; this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildFavoriteRoomUserUpdateComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniWidgetComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniWidgetComposer.java index c68838d1..4b75f522 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniWidgetComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniWidgetComposer.java @@ -8,22 +8,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildFurniWidgetComposer extends MessageComposer -{ +public class GuildFurniWidgetComposer extends MessageComposer { private final HabboItem item; private final Guild guild; private final Habbo habbo; - public GuildFurniWidgetComposer(Habbo habbo, Guild guild, HabboItem item) - { + public GuildFurniWidgetComposer(Habbo habbo, Guild guild, HabboItem item) { this.habbo = habbo; this.item = item; this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildFurniWidgetComposer); this.response.appendInt(item.getId()); this.response.appendInt(this.guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java index acb91038..5cf963a9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java @@ -11,15 +11,13 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.text.SimpleDateFormat; import java.util.Date; -public class GuildInfoComposer extends MessageComposer -{ +public class GuildInfoComposer extends MessageComposer { private final Guild guild; private final GameClient client; private final boolean newWindow; private final GuildMember member; - public GuildInfoComposer(Guild guild, GameClient client, boolean newWindow, GuildMember member) - { + public GuildInfoComposer(Guild guild, GameClient client, boolean newWindow, GuildMember member) { this.guild = guild; this.client = client; this.newWindow = newWindow; @@ -27,8 +25,7 @@ public class GuildInfoComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission("acc_guild_admin"); this.response.init(Outgoing.GuildInfoComposer); this.response.appendInt(this.guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildJoinErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildJoinErrorComposer.java index 09a3a381..d7b12c31 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildJoinErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildJoinErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildJoinErrorComposer extends MessageComposer -{ +public class GuildJoinErrorComposer extends MessageComposer { public static final int GROUP_FULL = 0; public static final int GROUP_LIMIT_EXCEED = 1; public static final int GROUP_CLOSED = 2; @@ -16,14 +15,12 @@ public class GuildJoinErrorComposer extends MessageComposer private final int code; - public GuildJoinErrorComposer(int code) - { + public GuildJoinErrorComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildJoinErrorComposer); this.response.appendInt(this.code); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildListComposer.java index 494e691b..7793c232 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildListComposer.java @@ -8,24 +8,20 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class GuildListComposer extends MessageComposer -{ +public class GuildListComposer extends MessageComposer { private final THashSet guilds; private final Habbo habbo; - public GuildListComposer(THashSet guilds, Habbo habbo) - { + public GuildListComposer(THashSet guilds, Habbo habbo) { this.guilds = guilds; this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildListComposer); this.response.appendInt(this.guilds.size()); - for(Guild guild : this.guilds) - { + for (Guild guild : this.guilds) { this.response.appendInt(guild.getId()); this.response.appendString(guild.getName()); this.response.appendString(guild.getBadge()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildManageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildManageComposer.java index 8dd1bf77..893d4e12 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildManageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildManageComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildManageComposer extends MessageComposer -{ +public class GuildManageComposer extends MessageComposer { private final Guild guild; - public GuildManageComposer(Guild guild) - { + public GuildManageComposer(Guild guild) { this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildManageComposer); this.response.appendInt(1); this.response.appendInt(guild.getRoomId()); @@ -40,21 +37,19 @@ public class GuildManageComposer extends MessageComposer int req = 5 - data.length; int i = 0; - for(String s : data) - { + for (String s : data) { this.response.appendInt((s.length() >= 6 ? Integer.parseInt(s.substring(0, 3)) : Integer.parseInt(s.substring(0, 2)))); this.response.appendInt((s.length() >= 6 ? Integer.parseInt(s.substring(3, 5)) : Integer.parseInt(s.substring(2, 4)))); - if(s.length() < 5) + if (s.length() < 5) this.response.appendInt(0); - else if(s.length() >= 6) + else if (s.length() >= 6) this.response.appendInt(Integer.parseInt(s.substring(5, 6))); else this.response.appendInt(Integer.parseInt(s.substring(4, 5))); } - while(i != req) - { + while (i != req) { this.response.appendInt(0); this.response.appendInt(0); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberUpdateComposer.java index 1ba65071..f4979b51 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMemberUpdateComposer.java @@ -6,27 +6,24 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildMemberUpdateComposer extends MessageComposer -{ +public class GuildMemberUpdateComposer extends MessageComposer { private final Guild guild; private final GuildMember guildMember; - public GuildMemberUpdateComposer(Guild guild, GuildMember guildMember) - { + public GuildMemberUpdateComposer(Guild guild, GuildMember guildMember) { this.guildMember = guildMember; this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildMemberUpdateComposer); this.response.appendInt(this.guild.getId()); this.response.appendInt(this.guildMember.getRank().type); 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().type != 0 ? this.guildMember.getJoinDate() + "" : ""); return this.response; } } 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 63b8f061..312305a8 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 @@ -11,8 +11,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.TimeZone; -public class GuildMembersComposer extends MessageComposer -{ +public class GuildMembersComposer extends MessageComposer { private final ArrayList members; private final Guild guild; private final Habbo session; @@ -21,8 +20,7 @@ public class GuildMembersComposer extends MessageComposer private final String searchValue; private final boolean isAdmin; - public GuildMembersComposer(Guild guild, ArrayList members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin) - { + public GuildMembersComposer(Guild guild, ArrayList members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin) { this.guild = guild; this.members = members; this.session = session; @@ -33,8 +31,7 @@ public class GuildMembersComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildMembersComposer); this.response.appendInt(this.guild.getId()); this.response.appendString(this.guild.getName()); @@ -44,8 +41,7 @@ public class GuildMembersComposer extends MessageComposer this.response.appendInt(this.members.size()); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); - for(GuildMember member : this.members) - { + for (GuildMember member : this.members) { cal.setTimeInMillis(member.getJoinDate() * 1000L); this.response.appendInt(member.getRank().type); this.response.appendInt(member.getUserId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildPartsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildPartsComposer.java index 8b6adec0..348bbd19 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildPartsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildPartsComposer.java @@ -6,45 +6,38 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildPartsComposer extends MessageComposer -{ +public class GuildPartsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GroupPartsComposer); this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getBases().size()); - for(GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBases()) - { + 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(Emulator.getGameEnvironment().getGuildManager().getSymbols().size()); - for(GuildPart part : Emulator.getGameEnvironment().getGuildManager().getSymbols()) - { + 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(Emulator.getGameEnvironment().getGuildManager().getBaseColors().size()); - for(GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBaseColors()) - { + for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBaseColors()) { this.response.appendInt(part.id); this.response.appendString(part.valueA); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getSymbolColors().size()); - for(GuildPart part : Emulator.getGameEnvironment().getGuildManager().getSymbolColors()) - { + for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getSymbolColors()) { this.response.appendInt(part.id); this.response.appendString(part.valueA); } this.response.appendInt(Emulator.getGameEnvironment().getGuildManager().getBackgroundColors().size()); - for(GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBackgroundColors()) - { + for (GuildPart part : Emulator.getGameEnvironment().getGuildManager().getBackgroundColors()) { this.response.appendInt(part.id); this.response.appendString(part.valueA); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildRefreshMembersListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildRefreshMembersListComposer.java index c5fc3e90..b66be090 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildRefreshMembersListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildRefreshMembersListComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildRefreshMembersListComposer extends MessageComposer -{ +public class GuildRefreshMembersListComposer extends MessageComposer { private final Guild guild; - public GuildRefreshMembersListComposer(Guild guild) - { + public GuildRefreshMembersListComposer(Guild guild) { this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildRefreshMembersListComposer); this.response.appendInt(this.guild.getId()); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/RemoveGuildFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/RemoveGuildFromRoomComposer.java index 9f65c6d0..1d06750f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/RemoveGuildFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/RemoveGuildFromRoomComposer.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; -public class RemoveGuildFromRoomComposer extends MessageComposer -{ +public class RemoveGuildFromRoomComposer extends MessageComposer { private int guildId; - public RemoveGuildFromRoomComposer(int guildId) - { + public RemoveGuildFromRoomComposer(int guildId) { this.guildId = guildId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveGuildFromRoomComposer); this.response.appendInt(this.guildId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumAddCommentComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumAddCommentComposer.java index c953e40b..8f267d61 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumAddCommentComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumAddCommentComposer.java @@ -5,8 +5,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildForumAddCommentComposer extends MessageComposer -{ +public class GuildForumAddCommentComposer extends MessageComposer { private final ForumThreadComment comment; public GuildForumAddCommentComposer(ForumThreadComment comment) { @@ -14,8 +13,7 @@ public class GuildForumAddCommentComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildForumAddCommentComposer); this.response.appendInt(this.comment.getThread().getGuildId()); //guild_id this.response.appendInt(this.comment.getThreadId()); //thread_id diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumCommentsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumCommentsComposer.java index 43252148..688480c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumCommentsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumCommentsComposer.java @@ -4,17 +4,16 @@ 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 java.util.Collection; -public class GuildForumCommentsComposer extends MessageComposer -{ +public class GuildForumCommentsComposer extends MessageComposer { private final int guildId; private final int threadId; private final int index; private final Collection guildForumCommentList; - public GuildForumCommentsComposer(int guildId, int threadId, int index, Collection guildForumCommentList) - { + public GuildForumCommentsComposer(int guildId, int threadId, int index, Collection guildForumCommentList) { this.guildId = guildId; this.threadId = threadId; this.index = index; @@ -22,8 +21,7 @@ public class GuildForumCommentsComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildForumCommentsComposer); this.response.appendInt(this.guildId); //guild_id @@ -31,8 +29,7 @@ public class GuildForumCommentsComposer extends MessageComposer this.response.appendInt(this.index); //start_index this.response.appendInt(this.guildForumCommentList.size()); - for (ForumThreadComment comment : this.guildForumCommentList) - { + for (ForumThreadComment comment : this.guildForumCommentList) { comment.serialize(this.response); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java index fc8370e2..19f05af4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java @@ -28,6 +28,72 @@ public class GuildForumDataComposer extends MessageComposer { this.habbo = habbo; } + public static void serializeForumData(ServerMessage response, Guild guild, Habbo habbo) { + + final THashSet forumThreads = ForumThread.getByGuildId(guild.getId()); + int lastSeenAt = 0; + + int totalComments = 0; + int newComments = 0; + int totalThreads = 0; + ForumThreadComment lastComment = null; + + synchronized (forumThreads) { + for (ForumThread thread : forumThreads) { + totalThreads++; + totalComments += thread.getPostsCount(); + + ForumThreadComment comment = thread.getLastComment(); + if (comment != null && (lastComment == null || lastComment.getCreatedAt() < comment.getCreatedAt())) { + lastComment = comment; + } + } + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( + "SELECT COUNT(*) " + + "FROM guilds_forums_threads A " + + "JOIN ( " + + "SELECT * " + + "FROM `guilds_forums_comments` " + + "WHERE `id` IN ( " + + "SELECT id " + + "FROM `guilds_forums_comments` B " + + "ORDER BY B.`id` ASC " + + ") " + + "ORDER BY `id` DESC " + + ") B ON A.`id` = B.`thread_id` " + + "WHERE A.`guild_id` = ? AND B.`created_at` > ?" + )) { + statement.setInt(1, guild.getId()); + statement.setInt(2, lastSeenAt); + + ResultSet set = statement.executeQuery(); + while (set.next()) { + newComments = set.getInt(1); + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + response.appendInt(guild.getId()); + + response.appendString(guild.getName()); + response.appendString(guild.getDescription()); + response.appendString(guild.getBadge()); + + response.appendInt(totalThreads); + response.appendInt(0); //Rating + + response.appendInt(totalComments); //Total comments + response.appendInt(newComments); //Unread comments + + response.appendInt(lastComment != null ? lastComment.getThreadId() : -1); + response.appendInt(lastComment != null ? lastComment.getUserId() : -1); + response.appendString(lastComment != null && lastComment.getHabbo() != null ? lastComment.getHabbo().getHabboInfo().getUsername() : ""); + response.appendInt(lastComment != null ? Emulator.getIntUnixTimestamp() - lastComment.getCreatedAt() : 0); + } + @Override public ServerMessage compose() { @@ -68,8 +134,7 @@ public class GuildForumDataComposer extends MessageComposer { if (guild.canModForum().state == 3 && guild.getOwnerId() != this.habbo.getHabboInfo().getId() && !isStaff) { errorModerate = "not_owner"; - } - else if (!isAdmin && !isStaff) { + } else if (!isAdmin && !isStaff) { errorModerate = "not_admin"; } @@ -84,81 +149,11 @@ public class GuildForumDataComposer extends MessageComposer { this.response.appendString(""); //citizen this.response.appendBoolean(guild.getOwnerId() == this.habbo.getHabboInfo().getId()); //Forum Settings this.response.appendBoolean(guild.getOwnerId() == this.habbo.getHabboInfo().getId() || isStaff); //Can Mod (staff) - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return new ConnectionErrorComposer(500).compose(); } return this.response; } - - public static void serializeForumData(ServerMessage response, Guild guild, Habbo habbo) { - - final THashSet forumThreads = ForumThread.getByGuildId(guild.getId()); - int lastSeenAt = 0; - - int totalComments = 0; - int newComments = 0; - int totalThreads = 0; - ForumThreadComment lastComment = null; - - synchronized (forumThreads) { - for (ForumThread thread : forumThreads) { - totalThreads++; - totalComments += thread.getPostsCount(); - - ForumThreadComment comment = thread.getLastComment(); - if (comment != null && (lastComment == null || lastComment.getCreatedAt() < comment.getCreatedAt())) { - lastComment = comment; - } - } - } - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( - "SELECT COUNT(*) " + - "FROM guilds_forums_threads A " + - "JOIN ( " + - "SELECT * " + - "FROM `guilds_forums_comments` " + - "WHERE `id` IN ( " + - "SELECT id " + - "FROM `guilds_forums_comments` B " + - "ORDER BY B.`id` ASC " + - ") " + - "ORDER BY `id` DESC " + - ") B ON A.`id` = B.`thread_id` " + - "WHERE A.`guild_id` = ? AND B.`created_at` > ?" - )) - { - statement.setInt(1, guild.getId()); - statement.setInt(2, lastSeenAt); - - ResultSet set = statement.executeQuery(); - while(set.next()) { - newComments = set.getInt(1); - } - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); - } - - response.appendInt(guild.getId()); - - response.appendString(guild.getName()); - response.appendString(guild.getDescription()); - response.appendString(guild.getBadge()); - - response.appendInt(totalThreads); - response.appendInt(0); //Rating - - response.appendInt(totalComments); //Total comments - response.appendInt(newComments); //Unread comments - - response.appendInt(lastComment != null ? lastComment.getThreadId() : -1); - response.appendInt(lastComment != null ? lastComment.getUserId() : -1); - response.appendString(lastComment != null && lastComment.getHabbo() != null ? lastComment.getHabbo().getHabboInfo().getUsername() : ""); - response.appendInt(lastComment != null ? Emulator.getIntUnixTimestamp() - lastComment.getCreatedAt() : 0); - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java index a4d7a8ae..f3050354 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java @@ -5,9 +5,8 @@ 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 com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import gnu.trove.set.hash.THashSet; -import java.sql.SQLException; + import java.util.Iterator; public class GuildForumListComposer extends MessageComposer { @@ -36,15 +35,15 @@ public class GuildForumListComposer extends MessageComposer { this.response.appendInt(count); - for(int i = 0; i < index; i++) { - if(!it.hasNext()) + for (int i = 0; i < index; i++) { + if (!it.hasNext()) break; it.next(); } - for(int i = 0; i < count; i++) { - if(!it.hasNext()) + for (int i = 0; i < count; i++) { + if (!it.hasNext()) break; GuildForumDataComposer.serializeForumData(this.response, it.next(), habbo); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadMessagesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadMessagesComposer.java index 04c37175..7fff374c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadMessagesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumThreadMessagesComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class GuildForumThreadMessagesComposer extends MessageComposer -{ +public class GuildForumThreadMessagesComposer extends MessageComposer { public final ForumThread thread; - public GuildForumThreadMessagesComposer(ForumThread thread) - { + public GuildForumThreadMessagesComposer(ForumThread thread) { this.thread = thread; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildForumThreadMessagesComposer); this.response.appendInt(this.thread.getGuildId()); this.thread.serialize(this.response); 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 2c0493a8..1a48b688 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 @@ -7,22 +7,22 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; -public class GuildForumThreadsComposer extends MessageComposer -{ +public class GuildForumThreadsComposer extends MessageComposer { public final Guild guild; public final int index; - public GuildForumThreadsComposer(Guild guild, int index) - { + public GuildForumThreadsComposer(Guild guild, int index) { this.guild = guild; this.index = index; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { ArrayList threads; try { @@ -42,15 +42,15 @@ public class GuildForumThreadsComposer extends MessageComposer this.response.appendInt(this.index); this.response.appendInt(count); - for(int i = 0; i < index; i++) { - if(!it.hasNext()) + for (int i = 0; i < index; i++) { + if (!it.hasNext()) break; it.next(); } - for(int i = 0; i < count; i++) { - if(!it.hasNext()) + for (int i = 0; i < count; i++) { + if (!it.hasNext()) break; it.next().serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumsUnreadMessagesCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumsUnreadMessagesCountComposer.java index 3aab71b0..7adce912 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumsUnreadMessagesCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumsUnreadMessagesCountComposer.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; -public class GuildForumsUnreadMessagesCountComposer extends MessageComposer -{ +public class GuildForumsUnreadMessagesCountComposer extends MessageComposer { public final int count; - public GuildForumsUnreadMessagesCountComposer(int count) - { + public GuildForumsUnreadMessagesCountComposer(int count) { this.count = count; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.GuildForumsUnreadMessagesCountComposer); this.response.appendInt(this.count); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostUpdateMessageComposer.java index ac632494..a825a44c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/PostUpdateMessageComposer.java @@ -5,22 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PostUpdateMessageComposer extends MessageComposer -{ +public class PostUpdateMessageComposer extends MessageComposer { public final int guildId; public final int threadId; public final ForumThreadComment comment; - public PostUpdateMessageComposer(int guildId, int threadId, ForumThreadComment comment) - { + public PostUpdateMessageComposer(int guildId, int threadId, ForumThreadComment comment) { this.guildId = guildId; this.threadId = threadId; this.comment = comment; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PostUpdateMessageComposer); this.response.appendInt(this.guildId); //guild_id diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java index 4a12236b..c7138ef8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java @@ -43,7 +43,7 @@ public class ThreadUpdatedMessageComposer extends MessageComposer { if (this.habbo.getHabboInfo().getId() != guild.getOwnerId() || guild.canModForum().state == 2 && (Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.ADMIN - || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.MOD) + || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.MOD) || this.habbo.hasPermission("acc_modtool_ticket_q")) { this.thread.setPinned(isPinned); this.thread.setLocked(isLocked); 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 796dc1e2..e790df29 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 @@ -4,25 +4,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HabboWayQuizComposer1 extends MessageComposer -{ +public class HabboWayQuizComposer1 extends MessageComposer { public final String name; public final int[] items; - public HabboWayQuizComposer1(String name, int[] items) - { + public HabboWayQuizComposer1(String name, int[] items) { this.name = name; this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HabboWayQuizComposer1); this.response.appendString(this.name); this.response.appendInt(this.items.length); - for (int item : this.items) - { + for (int item : this.items) { this.response.appendInt(item); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer2.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer2.java index a12df06b..d7af917a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer2.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/HabboWayQuizComposer2.java @@ -4,25 +4,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HabboWayQuizComposer2 extends MessageComposer -{ +public class HabboWayQuizComposer2 extends MessageComposer { public final String name; public final int[] items; - public HabboWayQuizComposer2(String name, int[] items) - { + public HabboWayQuizComposer2(String name, int[] items) { this.name = name; this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HabboWayQuizComposer2); this.response.appendString(this.name); this.response.appendInt(this.items.length); - for (int item : this.items) - { + for (int item : this.items) { this.response.appendInt(item); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserGiftComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserGiftComposer.java index 7c59fc11..3dcdb902 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserGiftComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserGiftComposer.java @@ -7,27 +7,22 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class NewUserGiftComposer extends MessageComposer -{ +public class NewUserGiftComposer extends MessageComposer { private final List> options; - public NewUserGiftComposer(List> options) - { + public NewUserGiftComposer(List> options) { this.options = options; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewUserGiftComposer); this.response.appendInt(this.options.size()); - for (List option : this.options) - { + for (List option : this.options) { this.response.appendInt(1); this.response.appendInt(3); this.response.appendInt(option.size()); - for (NewUserGift gift : option) - { + for (NewUserGift gift : option) { gift.serialize(this.response); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserIdentityComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserIdentityComposer.java index 67f9f4df..ab33e8c5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserIdentityComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NewUserIdentityComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewUserIdentityComposer extends MessageComposer -{ +public class NewUserIdentityComposer extends MessageComposer { private final Habbo habbo; - public NewUserIdentityComposer(Habbo habbo) - { + public NewUserIdentityComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewUserIdentityComposer); this.response.appendInt(this.habbo.noobStatus()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NuxAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NuxAlertComposer.java index a88f8289..6f77c800 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NuxAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/habboway/nux/NuxAlertComposer.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; -public class NuxAlertComposer extends MessageComposer -{ +public class NuxAlertComposer extends MessageComposer { private final String link; - public NuxAlertComposer(String link) - { + public NuxAlertComposer(String link) { this.link = link; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NuxAlertComposer); this.response.appendString(this.link); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/BannerTokenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/BannerTokenComposer.java index e93ad5f1..fb94d89a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/BannerTokenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/BannerTokenComposer.java @@ -4,19 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BannerTokenComposer extends MessageComposer -{ +public class BannerTokenComposer extends MessageComposer { private final String token; private final boolean unknown; - public BannerTokenComposer(String token, boolean unknown) - { + public BannerTokenComposer(String token, boolean unknown) { this.token = token; this.unknown = unknown; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BannerTokenComposer); this.response.appendString(this.token); this.response.appendBoolean(this.unknown); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/ConnectionErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/ConnectionErrorComposer.java index 53d24db6..6548dbe1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/ConnectionErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/ConnectionErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ConnectionErrorComposer extends MessageComposer -{ +public class ConnectionErrorComposer extends MessageComposer { private final int messageId; private final int errorCode; private final String timestamp; @@ -23,8 +22,7 @@ public class ConnectionErrorComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ConnectionErrorComposer); this.response.appendInt(this.messageId); this.response.appendInt(this.errorCode); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/DebugConsoleComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/DebugConsoleComposer.java index 469f80d1..d55249a9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/DebugConsoleComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/DebugConsoleComposer.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; -public class DebugConsoleComposer extends MessageComposer -{ +public class DebugConsoleComposer extends MessageComposer { private final boolean debugging; - public DebugConsoleComposer(boolean debugging) - { + public DebugConsoleComposer(boolean debugging) { this.debugging = debugging; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.DebugConsoleComposer); this.response.appendBoolean(this.debugging); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/MachineIDComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/MachineIDComposer.java index 3a5fa8d1..136ba08c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/MachineIDComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/MachineIDComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MachineIDComposer extends MessageComposer -{ +public class MachineIDComposer extends MessageComposer { private final GameClient client; - public MachineIDComposer(GameClient client) - { + public MachineIDComposer(GameClient client) { this.client = client; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MachineIDComposer); this.response.appendString(this.client.getMachineId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/PongComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/PongComposer.java index 6e7a44c5..a3f793aa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/PongComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/PongComposer.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; -public class PongComposer extends MessageComposer -{ +public class PongComposer extends MessageComposer { private final int id; - public PongComposer(int id) - { + public PongComposer(int id) { this.id = id; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PongComposer); this.response.appendInt(this.id); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SecureLoginOKComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SecureLoginOKComposer.java index 38df4801..f744fea0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SecureLoginOKComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SecureLoginOKComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class SecureLoginOKComposer extends MessageComposer -{ +public class SecureLoginOKComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SecureLoginOKComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SessionRightsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SessionRightsComposer.java index 83d1f768..a015de24 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SessionRightsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SessionRightsComposer.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; -public class SessionRightsComposer extends MessageComposer -{ +public class SessionRightsComposer extends MessageComposer { private static final boolean unknownBooleanOne = true; //true private static final boolean unknownBooleanTwo = false; @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SessionRightsComposer); this.response.appendBoolean(unknownBooleanOne); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SomeConnectionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SomeConnectionComposer.java index 6b1c3421..1214e126 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/handshake/SomeConnectionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/handshake/SomeConnectionComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class SomeConnectionComposer extends MessageComposer -{ +public class SomeConnectionComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SomeConnectionComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareComposer.java index 606e8767..183a66b5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/BonusRareComposer.java @@ -6,18 +6,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BonusRareComposer extends MessageComposer -{ +public class BonusRareComposer extends MessageComposer { private final Habbo habbo; - public BonusRareComposer(Habbo habbo) - { + public BonusRareComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BonusRareComposer); this.response.appendString(Emulator.getConfig().getValue("hotelview.promotional.reward.name", "prizetrophy_breed_gold")); //Furniture Name. Note: Image is in external_variables.txt this.response.appendInt(Emulator.getConfig().getInt("hotelview.promotional.reward.id", 0)); //Furniture ID diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HallOfFameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HallOfFameComposer.java index e2e0a722..4fd87102 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HallOfFameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HallOfFameComposer.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.hotelview; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.hotelview.HallOfFame; import com.eu.habbo.habbohotel.hotelview.HallOfFameWinner; import com.eu.habbo.messages.ServerMessage; @@ -11,18 +10,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class HallOfFameComposer extends MessageComposer -{ +public class HallOfFameComposer extends MessageComposer { private final HallOfFame hallOfFame; - public HallOfFameComposer(HallOfFame hallOfFame) - { + public HallOfFameComposer(HallOfFame hallOfFame) { this.hallOfFame = hallOfFame; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HallOfFameComposer); this.response.appendString(this.hallOfFame.getCompetitionName()); this.response.appendInt(this.hallOfFame.getWinners().size()); @@ -31,8 +27,7 @@ public class HallOfFameComposer extends MessageComposer List winners = new ArrayList<>(this.hallOfFame.getWinners().values()); Collections.sort(winners); - for(HallOfFameWinner winner : winners) - { + for (HallOfFameWinner winner : winners) { this.response.appendInt(winner.getId()); this.response.appendString(winner.getUsername()); this.response.appendString(winner.getLook()); 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 efd03ed6..8fea5e48 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewBadgeButtonConfigComposer extends MessageComposer -{ +public class HotelViewBadgeButtonConfigComposer extends MessageComposer { private final String badge; private final boolean enabled; - public HotelViewBadgeButtonConfigComposer(String badge, boolean enabled) - { + public HotelViewBadgeButtonConfigComposer(String badge, boolean enabled) { this.badge = badge; this.enabled = enabled; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewBadgeButtonConfigComposer); this.response.appendString(this.badge); this.response.appendBoolean(this.enabled); 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 b1d3f5b8..d7078845 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 @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewCatalogPageExpiringComposer extends MessageComposer -{ +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) - { + public HotelViewCatalogPageExpiringComposer(String name, int time, String image) { this.name = name; this.time = time; this.image = image; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewCatalogPageExpiringComposer); this.response.appendString(this.name); this.response.appendInt(this.time); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCommunityGoalComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCommunityGoalComposer.java index 8a752073..29d2be40 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCommunityGoalComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewCommunityGoalComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewCommunityGoalComposer extends MessageComposer -{ +public class HotelViewCommunityGoalComposer extends MessageComposer { private final boolean achieved; private final int personalContributionScore; private final int personalRank; @@ -26,8 +25,7 @@ public class HotelViewCommunityGoalComposer extends MessageComposer int percentCompletionTowardsNextLevel, String competitionName, int timeLeft, - int[] rankData) - { + int[] rankData) { this.achieved = achieved; this.personalContributionScore = personalContributionScore; this.personalRank = personalRank; @@ -42,8 +40,7 @@ public class HotelViewCommunityGoalComposer extends MessageComposer //: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 - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewCommunityGoalComposer); this.response.appendBoolean(this.achieved); //Achieved? this.response.appendInt(this.personalContributionScore); //User Amount @@ -55,8 +52,7 @@ public class HotelViewCommunityGoalComposer extends MessageComposer this.response.appendString(this.competitionName); this.response.appendInt(this.timeLeft); //Timer this.response.appendInt(this.rankData.length); //Rank Count - for (int i : this.rankData) - { + for (int i : this.rankData) { this.response.appendInt(i); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewComposer.java index f52e286a..7fe5d3d6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewComposer extends MessageComposer -{ +public class HotelViewComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewConcurrentUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewConcurrentUsersComposer.java index 952e0bb2..78185a7a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewConcurrentUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewConcurrentUsersComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewConcurrentUsersComposer extends MessageComposer -{ +public class HotelViewConcurrentUsersComposer extends MessageComposer { public static final int ACTIVE = 0; public static final int HIDDEN = 2; public static final int ACHIEVED = 3; @@ -14,16 +13,14 @@ public class HotelViewConcurrentUsersComposer extends MessageComposer private final int userCount; private final int goal; - public HotelViewConcurrentUsersComposer(int state, int userCount, int goal) - { - this.state = state; - this.userCount = userCount; - this.goal = goal; + public HotelViewConcurrentUsersComposer(int state, int userCount, int goal) { + this.state = state; + this.userCount = userCount; + this.goal = goal; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewConcurrentUsersComposer); this.response.appendInt(this.state); this.response.appendInt(this.userCount); 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 08f4e237..656a4b14 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewCustomTimerComposer extends MessageComposer -{ +public class HotelViewCustomTimerComposer extends MessageComposer { private final String name; private final int seconds; - public HotelViewCustomTimerComposer(String name, int seconds) - { + public HotelViewCustomTimerComposer(String name, int seconds) { this.name = name; this.seconds = seconds; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewCustomTimerComposer); this.response.appendString(this.name); //Send by the client. this.response.appendInt(this.seconds); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewDataComposer.java index 6ba0f18c..c6ca95ce 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewDataComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewDataComposer extends MessageComposer -{ +public class HotelViewDataComposer extends MessageComposer { private final String data; private final String key; - public HotelViewDataComposer(String data, String key) - { + public HotelViewDataComposer(String data, String key) { this.data = data; this.key = key; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewDataComposer); this.response.appendString(this.data); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewExpiringCatalogPageCommposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewExpiringCatalogPageCommposer.java index d9c0eed7..7421e972 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewExpiringCatalogPageCommposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewExpiringCatalogPageCommposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewExpiringCatalogPageCommposer extends MessageComposer -{ +public class HotelViewExpiringCatalogPageCommposer extends MessageComposer { private final CatalogPage page; private final String image; - public HotelViewExpiringCatalogPageCommposer(CatalogPage page, String image) - { + public HotelViewExpiringCatalogPageCommposer(CatalogPage page, String image) { this.page = page; this.image = image; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewExpiringCatalogPageCommposer); this.response.appendString(this.page.getCaption()); this.response.appendInt(this.page.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewHideCommunityVoteButtonComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewHideCommunityVoteButtonComposer.java index 0a532809..149568c4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewHideCommunityVoteButtonComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewHideCommunityVoteButtonComposer.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; -public class HotelViewHideCommunityVoteButtonComposer extends MessageComposer -{ +public class HotelViewHideCommunityVoteButtonComposer extends MessageComposer { private final boolean unknownBoolean; - public HotelViewHideCommunityVoteButtonComposer(boolean unknownBoolean) - { + public HotelViewHideCommunityVoteButtonComposer(boolean unknownBoolean) { this.unknownBoolean = unknownBoolean; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewHideCommunityVoteButtonComposer); this.response.appendBoolean(this.unknownBoolean); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewNextLTDAvailableComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewNextLTDAvailableComposer.java index 55d6a67f..f4c78872 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewNextLTDAvailableComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewNextLTDAvailableComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HotelViewNextLTDAvailableComposer extends MessageComposer -{ +public class HotelViewNextLTDAvailableComposer extends MessageComposer { private final int time; private final int pageId; private final int itemId; private final String itemName; - public HotelViewNextLTDAvailableComposer(int time, int pageId, int itemId, String itemName) - { + public HotelViewNextLTDAvailableComposer(int time, int pageId, int itemId, String itemName) { this.time = time; this.pageId = pageId; this.itemId = itemId; @@ -20,8 +18,7 @@ public class HotelViewNextLTDAvailableComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HotelViewNextLTDAvailableComposer); this.response.appendInt(this.time); this.response.appendInt(this.pageId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/NewsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/NewsListComposer.java index 75f9799b..5e3a029c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/NewsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/NewsListComposer.java @@ -7,18 +7,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewsListComposer extends MessageComposer -{ +public class NewsListComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewsWidgetsComposer); NewsList newsList = Emulator.getGameEnvironment().getHotelViewManager().getNewsList(); this.response.appendInt(newsList.getNewsWidgets().size()); - for(NewsWidget widget : newsList.getNewsWidgets()) - { + for (NewsWidget widget : newsList.getNewsWidgets()) { this.response.appendInt(widget.getId()); this.response.appendString(widget.getTitle()); this.response.appendString(widget.getMessage()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddBotComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddBotComposer.java index bdda9f07..7f618642 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddBotComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddBotComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AddBotComposer extends MessageComposer -{ +public class AddBotComposer extends MessageComposer { private final Bot bot; - public AddBotComposer(Bot bot) - { + public AddBotComposer(Bot bot) { this.bot = bot; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddBotComposer); this.response.appendInt(this.bot.getId()); this.response.appendString(this.bot.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddHabboItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddHabboItemComposer.java index a470601c..841f4307 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddHabboItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddHabboItemComposer.java @@ -9,30 +9,11 @@ import gnu.trove.set.hash.THashSet; import java.util.List; import java.util.Map; -public class AddHabboItemComposer extends MessageComposer -{ - public enum AddHabboItemCategory { - OWNED_FURNI(1), - RENTED_FURNI(2), - PET(3), - BADGE(4), - BOT(5), - GAME(6); - - public final int number; - - AddHabboItemCategory(int number) - { - this.number = number; - } - } - +public class AddHabboItemComposer extends MessageComposer { private THashSet itemsList; private HabboItem item; - private int[] ids; private AddHabboItemCategory category; - private Map> entries; public AddHabboItemComposer(THashSet itemsList) { @@ -60,8 +41,7 @@ public class AddHabboItemComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddHabboItemComposer); if (this.ids != null) { @@ -99,4 +79,19 @@ public class AddHabboItemComposer extends MessageComposer return this.response; } + + public enum AddHabboItemCategory { + OWNED_FURNI(1), + RENTED_FURNI(2), + PET(3), + BADGE(4), + BOT(5), + GAME(6); + + public final int number; + + AddHabboItemCategory(int number) { + this.number = number; + } + } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddPetComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddPetComposer.java index da696b5c..616a5167 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddPetComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/AddPetComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AddPetComposer extends MessageComposer -{ +public class AddPetComposer extends MessageComposer { private final Pet pet; - public AddPetComposer(Pet pet) - { + public AddPetComposer(Pet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddPetComposer); this.pet.serialize(this.response); this.response.appendBoolean(false); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListAddComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListAddComposer.java index 929a08f5..8e26067c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListAddComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListAddComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class EffectsListAddComposer extends MessageComposer -{ +public class EffectsListAddComposer extends MessageComposer { public final EffectsComponent.HabboEffect effect; - public EffectsListAddComposer(EffectsComponent.HabboEffect effect) - { + public EffectsListAddComposer(EffectsComponent.HabboEffect effect) { this.effect = effect; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.EffectsListAddComposer); this.response.appendInt(this.effect.effect); //Type this.response.appendInt(0); //Unknown Costume? diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListEffectEnableComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListEffectEnableComposer.java index 0ce0a41a..c3408a6f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListEffectEnableComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListEffectEnableComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class EffectsListEffectEnableComposer extends MessageComposer -{ +public class EffectsListEffectEnableComposer extends MessageComposer { public final EffectsComponent.HabboEffect effect; - public EffectsListEffectEnableComposer(EffectsComponent.HabboEffect effect) - { + public EffectsListEffectEnableComposer(EffectsComponent.HabboEffect effect) { this.effect = effect; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.EffectsListEffectEnableComposer); this.response.appendInt(this.effect.effect); //Type this.response.appendInt(this.effect.duration); //Duration diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListRemoveComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListRemoveComposer.java index 0ea3a636..a142fa52 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListRemoveComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/EffectsListRemoveComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class EffectsListRemoveComposer extends MessageComposer -{ +public class EffectsListRemoveComposer extends MessageComposer { public final EffectsComponent.HabboEffect effect; - public EffectsListRemoveComposer(EffectsComponent.HabboEffect effect) - { + public EffectsListRemoveComposer(EffectsComponent.HabboEffect effect) { this.effect = effect; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.EffectsListRemoveComposer); this.response.appendInt(this.effect.effect); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryAchievementsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryAchievementsComposer.java index bf2648b5..0e25b703 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryAchievementsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryAchievementsComposer.java @@ -9,28 +9,22 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; -public class InventoryAchievementsComposer extends MessageComposer -{ +public class InventoryAchievementsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.InventoryAchievementsComposer); - synchronized (Emulator.getGameEnvironment().getAchievementManager().getAchievements()) - { + synchronized (Emulator.getGameEnvironment().getAchievementManager().getAchievements()) { THashMap achievements = Emulator.getGameEnvironment().getAchievementManager().getAchievements(); this.response.appendInt(achievements.size()); - achievements.forEachValue(new TObjectProcedure() - { + achievements.forEachValue(new TObjectProcedure() { @Override - public boolean execute(Achievement achievement) - { + public boolean execute(Achievement achievement) { InventoryAchievementsComposer.this.response.appendString((achievement.name.startsWith("ACH_") ? achievement.name.replace("ACH_", "") : achievement.name)); InventoryAchievementsComposer.this.response.appendInt(achievement.levels.size()); - for (AchievementLevel level : achievement.levels.values()) - { + for (AchievementLevel level : achievement.levels.values()) { InventoryAchievementsComposer.this.response.appendInt(level.level); InventoryAchievementsComposer.this.response.appendInt(level.progress); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBadgesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBadgesComposer.java index 3fda5c9a..b5fc6e45 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBadgesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBadgesComposer.java @@ -7,19 +7,16 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class InventoryBadgesComposer extends MessageComposer -{ +public class InventoryBadgesComposer extends MessageComposer { private final Habbo habbo; - public InventoryBadgesComposer(Habbo habbo) - { + public InventoryBadgesComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { - if(this.habbo == null) + public ServerMessage compose() { + if (this.habbo == null) return null; THashSet equippedBadges = new THashSet<>(); @@ -27,19 +24,17 @@ public class InventoryBadgesComposer extends MessageComposer this.response.init(Outgoing.InventoryBadgesComposer); this.response.appendInt(this.habbo.getInventory().getBadgesComponent().getBadges().size()); - for(HabboBadge badge : this.habbo.getInventory().getBadgesComponent().getBadges()) - { + for (HabboBadge badge : this.habbo.getInventory().getBadgesComponent().getBadges()) { this.response.appendInt(badge.getId()); this.response.appendString(badge.getCode()); - if(badge.getSlot() > 0) + if (badge.getSlot() > 0) equippedBadges.add(badge); } this.response.appendInt(equippedBadges.size()); - for(HabboBadge badge : equippedBadges) - { + for (HabboBadge badge : equippedBadges) { this.response.appendInt(badge.getSlot()); this.response.appendString(badge.getCode()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBotsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBotsComposer.java index 0992044d..a44772bf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBotsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBotsComposer.java @@ -7,24 +7,20 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; -public class InventoryBotsComposer extends MessageComposer -{ +public class InventoryBotsComposer extends MessageComposer { private final Habbo habbo; - public InventoryBotsComposer(Habbo habbo) - { + public InventoryBotsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.InventoryBotsComposer); THashMap userBots = this.habbo.getInventory().getBotsComponent().getBots(); this.response.appendInt(userBots.size()); - for(Bot bot : userBots.values()) - { + for (Bot bot : userBots.values()) { this.response.appendInt(bot.getId()); this.response.appendString(bot.getName()); this.response.appendString(bot.getMotto()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index 6073a2f3..6115ef3b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -10,24 +10,20 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; import gnu.trove.procedure.TIntObjectProcedure; -public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure -{ +public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure { private final int page; private final int out; private final TIntObjectMap items; - public InventoryItemsComposer(int page, int out, TIntObjectMap items) - { + public InventoryItemsComposer(int page, int out, TIntObjectMap items) { this.page = page; this.out = out; this.items = items; } @Override - public ServerMessage compose() - { - try - { + public ServerMessage compose() { + try { this.response.init(Outgoing.InventoryItemsComposer); this.response.appendInt(this.out); this.response.appendInt(this.page - 1); @@ -35,9 +31,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.items.forEachEntry(this); return this.response; - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -45,29 +39,32 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec } @Override - public boolean execute(int a, HabboItem habboItem) - { + public boolean execute(int a, HabboItem habboItem) { this.response.appendInt(habboItem.getGiftAdjustedId()); this.response.appendString(habboItem.getBaseItem().getType().code); this.response.appendInt(habboItem.getId()); this.response.appendInt(habboItem.getBaseItem().getSpriteId()); - if(habboItem.getBaseItem().getName().equals("floor") || 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; + if (habboItem.getBaseItem().getName().equals("floor") || 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; } this.response.appendInt(0); this.response.appendString(habboItem.getExtradata()); - } - else - { - if(habboItem.getBaseItem().getName().equals("gnome_box")) + } else { + if (habboItem.getBaseItem().getName().equals("gnome_box")) this.response.appendInt(13); else this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); @@ -82,7 +79,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.response.appendBoolean(true); this.response.appendInt(-1); - if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR ) { + if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.response.appendString(""); this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryPetsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryPetsComposer.java index 21eb1a1b..696fbad1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryPetsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryPetsComposer.java @@ -9,18 +9,15 @@ import gnu.trove.iterator.TIntObjectIterator; import java.util.NoSuchElementException; -public class InventoryPetsComposer extends MessageComposer -{ +public class InventoryPetsComposer extends MessageComposer { private final Habbo habbo; - public InventoryPetsComposer(Habbo habbo) - { + public InventoryPetsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.InventoryPetsComposer); this.response.appendInt(1); @@ -29,14 +26,10 @@ public class InventoryPetsComposer extends MessageComposer TIntObjectIterator petIterator = this.habbo.getInventory().getPetsComponent().getPets().iterator(); - for(int i = this.habbo.getInventory().getPetsComponent().getPets().size(); i-- > 0;) - { - try - { + for (int i = this.habbo.getInventory().getPetsComponent().getPets().size(); i-- > 0; ) { + try { petIterator.advance(); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } petIterator.value().serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryRefreshComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryRefreshComposer.java index d5c9b428..97f2c099 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryRefreshComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryRefreshComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class InventoryRefreshComposer extends MessageComposer -{ +public class InventoryRefreshComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.InventoryRefreshComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryUpdateItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryUpdateItemComposer.java index 82567fb2..d7971230 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryUpdateItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryUpdateItemComposer.java @@ -6,42 +6,43 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class InventoryUpdateItemComposer extends MessageComposer -{ +public class InventoryUpdateItemComposer extends MessageComposer { private final HabboItem habboItem; - public InventoryUpdateItemComposer(HabboItem item) - { + public InventoryUpdateItemComposer(HabboItem item) { this.habboItem = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.InventoryItemUpdateComposer); this.response.appendInt(this.habboItem.getGiftAdjustedId()); this.response.appendString(this.habboItem.getBaseItem().getType().code); this.response.appendInt(this.habboItem.getId()); 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; + 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; } - if(this.habboItem.isLimited()) - { + if (this.habboItem.isLimited()) { this.response.appendInt(1); this.response.appendInt(256); this.response.appendString(this.habboItem.getExtradata()); this.response.appendInt(this.habboItem.getLimitedSells()); this.response.appendInt(this.habboItem.getLimitedStack()); - } - else - { + } else { this.response.appendInt(1); this.response.appendInt(0); this.response.appendString(this.habboItem.getExtradata()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveBotComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveBotComposer.java index f444e606..040de015 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveBotComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveBotComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RemoveBotComposer extends MessageComposer -{ +public class RemoveBotComposer extends MessageComposer { private final Bot bot; - public RemoveBotComposer(Bot bot) - { + public RemoveBotComposer(Bot bot) { this.bot = bot; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveBotComposer); this.response.appendInt(this.bot.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveHabboItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveHabboItemComposer.java index 64abb1d1..c28bc240 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveHabboItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemoveHabboItemComposer.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; -public class RemoveHabboItemComposer extends MessageComposer -{ +public class RemoveHabboItemComposer extends MessageComposer { private final int itemId; - public RemoveHabboItemComposer(final int itemId) - { + public RemoveHabboItemComposer(final int itemId) { this.itemId = itemId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveHabboItemComposer); this.response.appendInt(this.itemId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemovePetComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemovePetComposer.java index 50f751fe..72a6928a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemovePetComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/RemovePetComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RemovePetComposer extends MessageComposer -{ +public class RemovePetComposer extends MessageComposer { private final int petId; - public RemovePetComposer(Pet pet) - { + public RemovePetComposer(Pet pet) { this.petId = pet.getId(); } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemovePetComposer); this.response.appendInt(this.petId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java index bb4e19a0..ddf8bd80 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java @@ -8,28 +8,22 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.procedure.TObjectProcedure; -public class UserEffectsListComposer extends MessageComposer -{ +public class UserEffectsListComposer extends MessageComposer { public final Habbo habbo; - public UserEffectsListComposer(Habbo habbo) - { + public UserEffectsListComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserEffectsListComposer); - synchronized (this.habbo.getInventory().getEffectsComponent().effects) - { + synchronized (this.habbo.getInventory().getEffectsComponent().effects) { this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size()); - this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure() - { + this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure() { @Override - public boolean execute(EffectsComponent.HabboEffect effect) - { + public boolean execute(EffectsComponent.HabboEffect effect) { UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(0); UserEffectsListComposer.this.response.appendInt(effect.duration); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportRequestComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportRequestComposer.java index cbf925b0..6dea5de4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportRequestComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportRequestComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BullyReportRequestComposer extends MessageComposer -{ +public class BullyReportRequestComposer extends MessageComposer { public static final int START_REPORT = 0; public static final int ONGOING_HELPER_CASE = 1; public static final int INVALID_REQUESTS = 2; @@ -14,30 +13,27 @@ public class BullyReportRequestComposer extends MessageComposer private final int errorCode; private final int errorCodeType; - public BullyReportRequestComposer(int errorCode, int errorCodeType) - { + public BullyReportRequestComposer(int errorCode, int errorCodeType) { this.errorCode = errorCode; this.errorCodeType = errorCodeType; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BullyReportRequestComposer); this.response.appendInt(this.errorCode); - if(this.errorCode == ONGOING_HELPER_CASE) - { + if (this.errorCode == ONGOING_HELPER_CASE) { this.response.appendInt(this.errorCodeType); this.response.appendInt(1); //Timestamp this.response.appendBoolean(true); //Pending guide session. 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) - { + switch (this.errorCodeType) { case 3: - this.response.appendString("room Name"); break; + this.response.appendString("room Name"); + break; case 1: this.response.appendString("description"); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportedMessageComposer.java index e0936f56..e77e4492 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/BullyReportedMessageComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BullyReportedMessageComposer extends MessageComposer -{ +public class BullyReportedMessageComposer extends MessageComposer { public static final int RECEIVED = 0; public static final int IGNORED = 1; public static final int NO_CHAT = 2; @@ -14,14 +13,12 @@ public class BullyReportedMessageComposer extends MessageComposer private final int code; - public BullyReportedMessageComposer(int code) - { + public BullyReportedMessageComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BullyReportedMessageComposer); this.response.appendInt(this.code); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsMessageComposer.java index 02f0ae6f..73694a4b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhTopicsMessageComposer.java @@ -8,27 +8,21 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.procedure.TObjectProcedure; -public class CfhTopicsMessageComposer extends MessageComposer -{ +public class CfhTopicsMessageComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CfhTopicsMessageComposer); this.response.appendInt(Emulator.getGameEnvironment().getModToolManager().getCfhCategories().valueCollection().size()); - Emulator.getGameEnvironment().getModToolManager().getCfhCategories().forEachValue(new TObjectProcedure() - { + Emulator.getGameEnvironment().getModToolManager().getCfhCategories().forEachValue(new TObjectProcedure() { @Override - public boolean execute(CfhCategory category) - { + public boolean execute(CfhCategory category) { CfhTopicsMessageComposer.this.response.appendString(category.getName()); CfhTopicsMessageComposer.this.response.appendInt(category.getTopics().valueCollection().size()); - category.getTopics().forEachValue(new TObjectProcedure() - { + category.getTopics().forEachValue(new TObjectProcedure() { @Override - public boolean execute(CfhTopic topic) - { + public boolean execute(CfhTopic topic) { CfhTopicsMessageComposer.this.response.appendString(topic.name); CfhTopicsMessageComposer.this.response.appendInt(topic.id); CfhTopicsMessageComposer.this.response.appendString(topic.action.toString()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/HelperRequestDisabledComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/HelperRequestDisabledComposer.java index 679e73a3..aa136701 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/HelperRequestDisabledComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/HelperRequestDisabledComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HelperRequestDisabledComposer extends MessageComposer -{ +public class HelperRequestDisabledComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HelperRequestDisabledComposer); this.response.appendString(""); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolComposer.java index 6c654c28..0e05c84f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolComposer.java @@ -14,34 +14,30 @@ import gnu.trove.set.hash.THashSet; import java.util.Iterator; -public class ModToolComposer extends MessageComposer implements TObjectProcedure -{ +public class ModToolComposer extends MessageComposer implements TObjectProcedure { private final Habbo habbo; - public ModToolComposer(Habbo habbo) - { + public ModToolComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolComposer); - if(this.habbo.hasPermission("acc_modtool_ticket_q")) - { + if (this.habbo.hasPermission("acc_modtool_ticket_q")) { THashSet openTickets = new THashSet<>(); THashMap tickets = Emulator.getGameEnvironment().getModToolManager().getTickets(); - for(ModToolIssue t : tickets.values()) { - if(t.state != ModToolTicketState.CLOSED) + for (ModToolIssue t : tickets.values()) { + if (t.state != ModToolTicketState.CLOSED) openTickets.add(t); } int ticketsCount = openTickets.size(); - if(ticketsCount > 100) { + if (ticketsCount > 100) { ticketsCount = 100; } @@ -49,21 +45,16 @@ public class ModToolComposer extends MessageComposer implements TObjectProcedure Iterator it = openTickets.iterator(); - for(int i = 0; i < ticketsCount; i++) - { + for (int i = 0; i < ticketsCount; i++) { it.next().serialize(this.response); } - } - else - { + } else { this.response.appendInt(0); } - synchronized (Emulator.getGameEnvironment().getModToolManager().getPresets()) - { + synchronized (Emulator.getGameEnvironment().getModToolManager().getPresets()) { this.response.appendInt(Emulator.getGameEnvironment().getModToolManager().getPresets().get("user").size()); - for (String s : Emulator.getGameEnvironment().getModToolManager().getPresets().get("user")) - { + for (String s : Emulator.getGameEnvironment().getModToolManager().getPresets().get("user")) { this.response.appendString(s); } } @@ -80,11 +71,9 @@ public class ModToolComposer extends MessageComposer implements TObjectProcedure this.response.appendBoolean(this.habbo.hasPermission("acc_modtool_room_info")); //room info ??Not sure this.response.appendBoolean(this.habbo.hasPermission("acc_modtool_room_logs")); //room chatlogs ??Not sure - synchronized (Emulator.getGameEnvironment().getModToolManager().getPresets()) - { + synchronized (Emulator.getGameEnvironment().getModToolManager().getPresets()) { this.response.appendInt(Emulator.getGameEnvironment().getModToolManager().getPresets().get("room").size()); - for (String s : Emulator.getGameEnvironment().getModToolManager().getPresets().get("room")) - { + for (String s : Emulator.getGameEnvironment().getModToolManager().getPresets().get("room")) { this.response.appendString(s); } } @@ -93,8 +82,7 @@ public class ModToolComposer extends MessageComposer implements TObjectProcedure } @Override - public boolean execute(ModToolCategory category) - { + public boolean execute(ModToolCategory category) { this.response.appendString(category.getName()); @@ -103,24 +91,6 @@ public class ModToolComposer extends MessageComposer implements TObjectProcedure // - - - - - - - - - - - - - - - - - - return true; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java index 8f39a29e..1aac7aea 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java @@ -12,23 +12,20 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; -public class ModToolIssueChatlogComposer extends MessageComposer -{ +public class ModToolIssueChatlogComposer extends MessageComposer { public static SimpleDateFormat format = new SimpleDateFormat("HH:mm"); private final ModToolIssue issue; private final ArrayList chatlog; private final String roomName; - public ModToolIssueChatlogComposer(ModToolIssue issue, ArrayList chatlog, String roomName) - { + public ModToolIssueChatlogComposer(ModToolIssue issue, ArrayList chatlog, String roomName) { this.issue = issue; this.chatlog = chatlog; this.roomName = roomName; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueChatlogComposer); this.response.appendInt(this.issue.id); this.response.appendInt(this.issue.senderId); @@ -37,23 +34,20 @@ public class ModToolIssueChatlogComposer extends MessageComposer Collections.sort(this.chatlog); - if(this.chatlog.isEmpty()) + if (this.chatlog.isEmpty()) return null; //ChatRecordData //for(ModToolRoomVisit visit : chatlog) //{ - this.response.appendByte(1); //Report Type + this.response.appendByte(1); //Report Type - if (this.issue.type == ModToolTicketType.IM) - { + if (this.issue.type == ModToolTicketType.IM) { this.response.appendShort(1); ModToolChatRecordDataContext.MESSAGE_ID.append(this.response); this.response.appendInt(this.issue.senderId); - } - else - { + } else { this.response.appendShort(3); //Context Count ModToolChatRecordDataContext.ROOM_NAME.append(this.response); @@ -66,15 +60,14 @@ public class ModToolIssueChatlogComposer extends MessageComposer this.response.appendInt(12); } - 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(false); - } + 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(false); + } //} return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandledComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandledComposer.java index 02f0ede6..5dd301c0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandledComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandledComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolIssueHandledComposer extends MessageComposer -{ +public class ModToolIssueHandledComposer extends MessageComposer { public static final int HANDLED = 0; public static final int USELESS = 1; public static final int ABUSIVE = 2; @@ -13,21 +12,18 @@ public class ModToolIssueHandledComposer extends MessageComposer private final int code; private final String message; - public ModToolIssueHandledComposer(int code) - { + public ModToolIssueHandledComposer(int code) { this.code = code; this.message = ""; } - public ModToolIssueHandledComposer(String message) - { + public ModToolIssueHandledComposer(String message) { this.code = 0; this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueHandledComposer); this.response.appendInt(this.code); this.response.appendString(this.message); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandlerDimensionsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandlerDimensionsComposer.java index e294cdfc..b30e5d0f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandlerDimensionsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueHandlerDimensionsComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolIssueHandlerDimensionsComposer extends MessageComposer -{ +public class ModToolIssueHandlerDimensionsComposer extends MessageComposer { private final int x; private final int y; private final int width; private final int height; - public ModToolIssueHandlerDimensionsComposer(int x, int y, int width, int height) - { + public ModToolIssueHandlerDimensionsComposer(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; @@ -20,8 +18,7 @@ public class ModToolIssueHandlerDimensionsComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueHandlerDimensionsComposer); this.response.appendInt(this.x); this.response.appendInt(this.y); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueInfoComposer.java index 64732ada..ce57afa3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueInfoComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolIssueInfoComposer extends MessageComposer -{ +public class ModToolIssueInfoComposer extends MessageComposer { private final ModToolIssue issue; - public ModToolIssueInfoComposer(ModToolIssue issue) - { + public ModToolIssueInfoComposer(ModToolIssue issue) { this.issue = issue; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueInfoComposer); this.issue.serialize(this.response); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueResponseAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueResponseAlertComposer.java index cb9f69e1..8f22f10c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueResponseAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueResponseAlertComposer.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; -public class ModToolIssueResponseAlertComposer extends MessageComposer -{ +public class ModToolIssueResponseAlertComposer extends MessageComposer { private final String message; - public ModToolIssueResponseAlertComposer(String message) - { + public ModToolIssueResponseAlertComposer(String message) { this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueResponseAlertComposer); this.response.appendString(this.message); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueUpdateComposer.java index da660ad6..5034b424 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueUpdateComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolIssueUpdateComposer extends MessageComposer -{ +public class ModToolIssueUpdateComposer extends MessageComposer { private final ModToolIssue issue; - public ModToolIssueUpdateComposer(ModToolIssue issue) - { + public ModToolIssueUpdateComposer(ModToolIssue issue) { this.issue = issue; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueUpdateComposer); this.issue.serialize(this.response); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolReportReceivedAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolReportReceivedAlertComposer.java index b76e0424..064385b9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolReportReceivedAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolReportReceivedAlertComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolReportReceivedAlertComposer extends MessageComposer -{ +public class ModToolReportReceivedAlertComposer extends MessageComposer { public static final int REPORT_RECEIVED = 0; public static final int REPORT_WINDOW = 1; public static final int REPORT_ABUSIVE = 2; @@ -13,15 +12,13 @@ public class ModToolReportReceivedAlertComposer extends MessageComposer private final int errorCode; private final String message; - public ModToolReportReceivedAlertComposer(int errorCode, String message) - { + public ModToolReportReceivedAlertComposer(int errorCode, String message) { this.errorCode = errorCode; this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolReportReceivedAlertComposer); this.response.appendInt(this.errorCode); this.response.appendString(this.message); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomChatlogComposer.java index 45324b8a..1be09ca0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomChatlogComposer.java @@ -10,20 +10,17 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; -public class ModToolRoomChatlogComposer extends MessageComposer -{ +public class ModToolRoomChatlogComposer extends MessageComposer { private final Room room; private final ArrayList chatlog; - public ModToolRoomChatlogComposer(Room room, ArrayList chatlog) - { + public ModToolRoomChatlogComposer(Room room, ArrayList chatlog) { this.room = room; this.chatlog = chatlog; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolRoomChatlogComposer); this.response.appendByte(1); this.response.appendShort(2); @@ -35,10 +32,9 @@ public class ModToolRoomChatlogComposer extends MessageComposer this.response.appendInt(this.room.getId()); SimpleDateFormat formatDate = new SimpleDateFormat("HH:mm"); - + this.response.appendShort(this.chatlog.size()); - for(ModToolChatLog line : this.chatlog) - { + 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); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomInfoComposer.java index 57fb3445..47792774 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolRoomInfoComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolRoomInfoComposer extends MessageComposer -{ +public class ModToolRoomInfoComposer extends MessageComposer { private final Room room; - public ModToolRoomInfoComposer(Room room) - { + public ModToolRoomInfoComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolRoomInfoComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(this.room.getCurrentHabbos().size()); @@ -24,13 +21,11 @@ public class ModToolRoomInfoComposer extends MessageComposer this.response.appendInt(this.room.getOwnerId()); this.response.appendString(this.room.getOwnerName()); this.response.appendBoolean(!this.room.isPublicRoom()); - if(!this.room.isPublicRoom()) - { + if (!this.room.isPublicRoom()) { this.response.appendString(this.room.getName()); this.response.appendString(this.room.getDescription()); this.response.appendInt(this.room.getTags().split(";").length); - for(int i = 0; i < this.room.getTags().split(";").length; i++) - { + for (int i = 0; i < this.room.getTags().split(";").length; i++) { this.response.appendString(this.room.getTags().split(";")[i]); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index 731dd6a9..3e24b6a8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolSanctionInfoComposer extends MessageComposer -{ +public class ModToolSanctionInfoComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolSanctionInfoComposer); this.response.appendBoolean(false); //Has Last Sanction. this.response.appendBoolean(false); //Is probabtion. diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserChatlogComposer.java index 59814b15..1c8c9ac9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserChatlogComposer.java @@ -9,30 +9,26 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.text.SimpleDateFormat; import java.util.ArrayList; -public class ModToolUserChatlogComposer extends MessageComposer -{ +public class ModToolUserChatlogComposer extends MessageComposer { public static SimpleDateFormat format = new SimpleDateFormat("HH:mm"); private final ArrayList set; private final int userId; private final String username; - public ModToolUserChatlogComposer(ArrayList set, int userId, String username) - { + public ModToolUserChatlogComposer(ArrayList set, int userId, String username) { this.set = set; this.userId = userId; this.username = username; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolUserChatlogComposer); this.response.appendInt(this.userId); this.response.appendString(this.username); this.response.appendInt(this.set.size()); - for(ModToolRoomVisit visit : this.set) - { + for (ModToolRoomVisit visit : this.set) { this.response.appendByte(1); this.response.appendShort(2); this.response.appendString("roomName"); @@ -43,8 +39,7 @@ public class ModToolUserChatlogComposer extends MessageComposer this.response.appendInt(visit.roomId); this.response.appendShort(visit.chat.size()); - for(ModToolChatLog chatLog : visit.chat) - { + for (ModToolChatLog chatLog : visit.chat) { this.response.appendString(format.format(chatLog.timestamp * 1000L)); this.response.appendInt(chatLog.habboId); this.response.appendString(chatLog.username); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index 2a4336e9..804ec6e1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -8,21 +8,17 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.sql.ResultSet; import java.sql.SQLException; -public class ModToolUserInfoComposer extends MessageComposer -{ +public class ModToolUserInfoComposer extends MessageComposer { private final ResultSet set; - public ModToolUserInfoComposer(ResultSet set) - { + public ModToolUserInfoComposer(ResultSet set) { this.set = set; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolUserInfoComposer); - try - { + try { this.response.appendInt(this.set.getInt("user_id")); this.response.appendString(this.set.getString("username")); this.response.appendString(this.set.getString("look")); @@ -47,10 +43,8 @@ public class ModToolUserInfoComposer extends MessageComposer this.response.appendInt(31); } return this.response; - } - catch (SQLException e) - { - Emulator.getLogging().logSQLException(e); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java index 392cd467..25ffcc8a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java @@ -10,28 +10,24 @@ import gnu.trove.set.hash.THashSet; import java.util.Calendar; import java.util.TimeZone; -public class ModToolUserRoomVisitsComposer extends MessageComposer -{ +public class ModToolUserRoomVisitsComposer extends MessageComposer { private final Habbo habbo; private final THashSet roomVisits; - public ModToolUserRoomVisitsComposer(Habbo habbo, THashSet roomVisits) - { + public ModToolUserRoomVisitsComposer(Habbo habbo, THashSet roomVisits) { this.habbo = habbo; this.roomVisits = roomVisits; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolUserRoomVisitsComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendInt(this.roomVisits.size()); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); - for(ModToolRoomVisit visit : this.roomVisits) - { + for (ModToolRoomVisit visit : this.roomVisits) { cal.setTimeInMillis(visit.timestamp * 1000); this.response.appendInt(visit.roomId); this.response.appendString(visit.roomName); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ReportRoomFormComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ReportRoomFormComposer.java index fd6c278d..63601f50 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ReportRoomFormComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ReportRoomFormComposer.java @@ -5,26 +5,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import java.util.ArrayList; import java.util.List; -public class ReportRoomFormComposer extends MessageComposer -{ +public class ReportRoomFormComposer extends MessageComposer { private final List pendingIssues; - public ReportRoomFormComposer(List issues) - { + public ReportRoomFormComposer(List issues) { this.pendingIssues = issues; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ReportRoomFormComposer); this.response.appendInt(this.pendingIssues.size()); //Current standing help request(s) amount: - for (ModToolIssue issue : this.pendingIssues) - { + for (ModToolIssue issue : this.pendingIssues) { this.response.appendString(issue.id + ""); this.response.appendString(issue.timestamp + ""); this.response.appendString(issue.message); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateEventComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateEventComposer.java index ab10e458..0df277ba 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateEventComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/CanCreateEventComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CanCreateEventComposer extends MessageComposer -{ +public class CanCreateEventComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CanCreateEventComposer); this.response.appendBoolean(true); this.response.appendInt(0); 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 5aafbe79..4bd0ffc0 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CanCreateRoomComposer extends MessageComposer -{ +public class CanCreateRoomComposer extends MessageComposer { private final int count; private final int max; - public CanCreateRoomComposer(int count, int max) - { + public CanCreateRoomComposer(int count, int max) { this.count = count; this.max = max; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CanCreateRoomComposer); this.response.appendInt(this.count >= this.max ? 1 : 0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCategoryUserCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCategoryUserCountComposer.java index 03622acc..311cd900 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCategoryUserCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCategoryUserCountComposer.java @@ -7,23 +7,19 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class NewNavigatorCategoryUserCountComposer extends MessageComposer -{ +public class NewNavigatorCategoryUserCountComposer extends MessageComposer { public final List roomCategories; - public NewNavigatorCategoryUserCountComposer(List roomCategories) - { + public NewNavigatorCategoryUserCountComposer(List roomCategories) { this.roomCategories = roomCategories; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorCategoryUserCountComposer); this.response.appendInt(this.roomCategories.size()); - for (RoomCategory category : this.roomCategories) - { + for (RoomCategory category : this.roomCategories) { this.response.appendInt(0); this.response.appendInt(0); this.response.appendInt(200); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCollapsedCategoriesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCollapsedCategoriesComposer.java index 92521bd7..c075460d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCollapsedCategoriesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorCollapsedCategoriesComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorCollapsedCategoriesComposer extends MessageComposer -{ +public class NewNavigatorCollapsedCategoriesComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorCollapsedCategoriesComposer); this.response.appendInt(46); this.response.appendString("new_ads"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java index 13b53c26..aacf54cb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorEventCategoriesComposer extends MessageComposer -{ +public class NewNavigatorEventCategoriesComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorEventCategoriesComposer); this.response.appendInt(11); this.response.appendInt(1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorLiftedRoomsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorLiftedRoomsComposer.java index bd416ae7..63c1eff3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorLiftedRoomsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorLiftedRoomsComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorLiftedRoomsComposer extends MessageComposer -{ +public class NewNavigatorLiftedRoomsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorLiftedRoomsComposer); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorMetaDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorMetaDataComposer.java index 2a4673a9..ae8617f2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorMetaDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorMetaDataComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorMetaDataComposer extends MessageComposer -{ +public class NewNavigatorMetaDataComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorMetaDataComposer); this.response.appendInt(4); this.response.appendString("official_view"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java index d058c978..ff153a7f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorSavedSearchesComposer extends MessageComposer -{ +public class NewNavigatorSavedSearchesComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorSavedSearchesComposer); this.response.appendInt(4); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSearchResultsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSearchResultsComposer.java index f40ba655..83c4bcb1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSearchResultsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSearchResultsComposer.java @@ -7,30 +7,26 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class NewNavigatorSearchResultsComposer extends MessageComposer -{ +public class NewNavigatorSearchResultsComposer extends MessageComposer { private final String searchCode; private final String searchQuery; private final List resultList; - public NewNavigatorSearchResultsComposer(String searchCode, String searchQuery, List resultList) - { - this.searchCode = searchCode; + public NewNavigatorSearchResultsComposer(String searchCode, String searchQuery, List resultList) { + this.searchCode = searchCode; this.searchQuery = searchQuery; - this.resultList = resultList; + this.resultList = resultList; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorSearchResultsComposer); this.response.appendString(this.searchCode); this.response.appendString(this.searchQuery); this.response.appendInt(this.resultList.size()); //Count - for (SearchResultList item : this.resultList) - { + for (SearchResultList item : this.resultList) { item.serialize(this.response); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSettingsComposer.java index dbb6987f..a893e5af 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSettingsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class NewNavigatorSettingsComposer extends MessageComposer -{ +public class NewNavigatorSettingsComposer extends MessageComposer { private final HabboNavigatorWindowSettings windowSettings; - public NewNavigatorSettingsComposer(HabboNavigatorWindowSettings windowSettings) - { + public NewNavigatorSettingsComposer(HabboNavigatorWindowSettings windowSettings) { this.windowSettings = windowSettings; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorSettingsComposer); this.response.appendInt(this.windowSettings.x); this.response.appendInt(this.windowSettings.y); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/OpenRoomCreationWindowComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/OpenRoomCreationWindowComposer.java index 4135f752..ba7bc5f8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/OpenRoomCreationWindowComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/OpenRoomCreationWindowComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class OpenRoomCreationWindowComposer extends MessageComposer -{ +public class OpenRoomCreationWindowComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.OpenRoomCreationWindowComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java index e42d3e44..e811962b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java @@ -8,20 +8,16 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class PrivateRoomsComposer extends MessageComposer -{ +public class PrivateRoomsComposer extends MessageComposer { private final List rooms; - public PrivateRoomsComposer(List rooms) - { + public PrivateRoomsComposer(List rooms) { this.rooms = rooms; } @Override - public ServerMessage compose() - { - try - { + public ServerMessage compose() { + try { this.response.init(Outgoing.PrivateRoomsComposer); this.response.appendInt(2); @@ -45,9 +41,7 @@ public class PrivateRoomsComposer extends MessageComposer this.response.appendInt(1); this.response.appendString("E"); return this.response; - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCategoriesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCategoriesComposer.java index 5ee0ac8d..4291d38b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCategoriesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCategoriesComposer.java @@ -7,35 +7,28 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class RoomCategoriesComposer extends MessageComposer -{ +public class RoomCategoriesComposer extends MessageComposer { private final List categories; - public RoomCategoriesComposer(List categories) - { + public RoomCategoriesComposer(List categories) { this.categories = categories; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomCategoriesComposer); this.response.appendInt(this.categories.size()); - for(RoomCategory category : this.categories) - { + for (RoomCategory category : this.categories) { this.response.appendInt(category.getId()); this.response.appendString(category.getCaption()); this.response.appendBoolean(true); //Visible this.response.appendBoolean(false); //True = Disconnect? this.response.appendString(category.getCaption()); - if (category.getCaption().startsWith("${")) - { + if (category.getCaption().startsWith("${")) { this.response.appendString(""); - } - else - { + } else { this.response.appendString(category.getCaption()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCreatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCreatedComposer.java index 26151a75..f152f939 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCreatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/RoomCreatedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomCreatedComposer extends MessageComposer -{ +public class RoomCreatedComposer extends MessageComposer { private final Room room; - public RoomCreatedComposer(Room room) - { + public RoomCreatedComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomCreatedComposer); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/TagsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/TagsComposer.java index c692e286..ec875fbf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/TagsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/TagsComposer.java @@ -6,24 +6,20 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Set; -public class TagsComposer extends MessageComposer -{ +public class TagsComposer extends MessageComposer { private final Set tags; - public TagsComposer(Set tags) - { + public TagsComposer(Set tags) { this.tags = tags; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TagsComposer); this.response.appendInt(this.tags.size()); int i = 1; - for(String s : this.tags) - { + for (String s : this.tags) { this.response.appendString(s); this.response.appendInt(i); i++; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollQuestionsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollQuestionsComposer.java index ea1a01a8..b0c39a8d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollQuestionsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollQuestionsComposer.java @@ -6,26 +6,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PollQuestionsComposer extends MessageComposer -{ +public class PollQuestionsComposer extends MessageComposer { private final Poll poll; - public PollQuestionsComposer(Poll poll) - { + public PollQuestionsComposer(Poll poll) { this.poll = poll; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PollQuestionsComposer); this.response.appendInt(this.poll.id); this.response.appendString(this.poll.title); this.response.appendString(this.poll.thanksMessage); this.response.appendInt(this.poll.getQuestions().size()); - for (PollQuestion question : this.poll.getQuestions()) - { + for (PollQuestion question : this.poll.getQuestions()) { question.serialize(this.response); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollStartComposer.java index aa6352d5..5842b2e6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/PollStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/PollStartComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PollStartComposer extends MessageComposer -{ +public class PollStartComposer extends MessageComposer { private final Poll poll; - public PollStartComposer(Poll poll) - { + public PollStartComposer(Poll poll) { this.poll = poll; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PollStartComposer); this.response.appendInt(this.poll.id); this.response.appendString(this.poll.title); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswerComposer.java index 46b08b83..e352e07c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswerComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class SimplePollAnswerComposer extends MessageComposer -{ +public class SimplePollAnswerComposer extends MessageComposer { private final int userId; private final String choice; private final int no; private final int yes; - public SimplePollAnswerComposer(int userId, String choice, int no, int yes) - { + public SimplePollAnswerComposer(int userId, String choice, int no, int yes) { this.userId = userId; this.choice = choice; this.no = no; @@ -20,8 +18,7 @@ public class SimplePollAnswerComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SimplePollAnswerComposer); this.response.appendInt(this.userId); this.response.appendString(this.choice); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswersComposer.java index fdce87ea..a41a7172 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollAnswersComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class SimplePollAnswersComposer extends MessageComposer -{ +public class SimplePollAnswersComposer extends MessageComposer { private final int no; private final int yes; - public SimplePollAnswersComposer(int no, int yes) - { + public SimplePollAnswersComposer(int no, int yes) { this.no = no; this.yes = yes; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SimplePollAnswersComposer); this.response.appendInt(-1); this.response.appendInt(2); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollStartComposer.java index cb63a945..2fc95000 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/polls/infobus/SimplePollStartComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class SimplePollStartComposer extends MessageComposer -{ +public class SimplePollStartComposer extends MessageComposer { public final int duration; public final String question; - public SimplePollStartComposer(int duration, String question) - { + public SimplePollStartComposer(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 - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SimplePollStartComposer); this.response.appendString(this.question); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedComposer.java index ef96d757..3f83ab2b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestCompletedComposer.java @@ -5,27 +5,23 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class QuestCompletedComposer extends MessageComposer -{ +public class QuestCompletedComposer extends MessageComposer { private final UnknownClass unknownClass; private final boolean unknowbOolean; - public QuestCompletedComposer(UnknownClass unknownClass, boolean unknowbOolean) - { + public QuestCompletedComposer(UnknownClass unknownClass, boolean unknowbOolean) { this.unknownClass = unknownClass; this.unknowbOolean = unknowbOolean; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.QuestCompletedComposer); return this.response; } - public static class UnknownClass implements ISerialize - { + public static class UnknownClass implements ISerialize { private final int activityPointsType; private final boolean accepted; private final int id; @@ -33,8 +29,7 @@ public class QuestCompletedComposer extends MessageComposer private final int sortOrder; private final boolean easy; - public UnknownClass(int activityPointsType, boolean accepted, int id, String type, int sortOrder, 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; @@ -44,8 +39,7 @@ public class QuestCompletedComposer extends MessageComposer } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString(""); message.appendInt(0); message.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestComposer.java index e8dfbbd6..c75e990c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestComposer.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; -public class QuestComposer extends MessageComposer -{ +public class QuestComposer extends MessageComposer { private final QuestsComposer.Quest quest; - public QuestComposer(QuestsComposer.Quest quest) - { + public QuestComposer(QuestsComposer.Quest quest) { this.quest = quest; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.QuestComposer); this.response.append(this.quest); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestExpiredComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestExpiredComposer.java index 15cfd551..8bdf6fd5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestExpiredComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestExpiredComposer.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; -public class QuestExpiredComposer extends MessageComposer -{ +public class QuestExpiredComposer extends MessageComposer { private final boolean expired; - public QuestExpiredComposer(boolean expired) - { + public QuestExpiredComposer(boolean expired) { this.expired = expired; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.QuestExpiredComposer); this.response.appendBoolean(this.expired); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestionInfoComposer.java index 77a71e3f..3703c854 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestionInfoComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class QuestionInfoComposer extends MessageComposer -{ +public class QuestionInfoComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.QuestionInfoComposer); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsComposer.java index ba694df3..fd154fc3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/quests/QuestsComposer.java @@ -7,32 +7,27 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class QuestsComposer extends MessageComposer -{ +public class QuestsComposer extends MessageComposer { private final List quests; private final boolean unknownBoolean; - public QuestsComposer(List quests, boolean unknownBoolean) - { + public QuestsComposer(List quests, boolean unknownBoolean) { this.quests = quests; this.unknownBoolean = unknownBoolean; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.QuestsComposer); this.response.appendInt(this.quests.size()); - for (Quest quest : this.quests) - { + for (Quest quest : this.quests) { this.response.append(quest); } this.response.appendBoolean(this.unknownBoolean); return this.response; } - public static class Quest implements ISerialize - { + public static class Quest implements ISerialize { private final String campaignCode; private final int completedQuestsInCampaign; private final int questCountInCampaign; @@ -50,8 +45,7 @@ public class QuestsComposer 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) - { + 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; @@ -71,8 +65,7 @@ public class QuestsComposer extends MessageComposer } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString(this.campaignCode); message.appendInt(this.completedQuestsInCampaign); message.appendInt(this.questCountInCampaign); 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 6472d68e..50fccff8 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 @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BotForceOpenContextMenuComposer extends MessageComposer -{ +public class BotForceOpenContextMenuComposer extends MessageComposer { private final int botId; - public BotForceOpenContextMenuComposer(int botId) - { + public BotForceOpenContextMenuComposer(int botId) { this.botId = botId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BotForceOpenContextMenuComposer); this.response.appendInt(this.botId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotSettingsComposer.java index 8eab9301..ff53e34e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotSettingsComposer.java @@ -5,39 +5,33 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BotSettingsComposer extends MessageComposer -{ +public class BotSettingsComposer extends MessageComposer { private final Bot bot; private final int settingId; - public BotSettingsComposer(Bot bot, int settingId) - { + public BotSettingsComposer(Bot bot, int settingId) { this.bot = bot; this.settingId = settingId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BotSettingsComposer); this.response.appendInt(-this.bot.getId()); this.response.appendInt(this.settingId); - switch(this.settingId) - { - case 1: this.response.appendString(""); break; + switch (this.settingId) { + case 1: + this.response.appendString(""); + break; case 2: StringBuilder data = new StringBuilder(); - if (this.bot.hasChat()) - { - for (String s : this.bot.getChatLines()) - { + if (this.bot.hasChat()) { + for (String s : this.bot.getChatLines()) { data.append(s).append("\r"); } - } - else - { + } else { data.append(Bot.NO_CHAT_SET); } @@ -47,12 +41,18 @@ public class BotSettingsComposer extends MessageComposer data.append(";#;").append(this.bot.isChatRandom() ? "true" : "false"); this.response.appendString(data.toString()); break; - case 3: this.response.appendString(""); break; - case 4: this.response.appendString(""); break; + case 3: + this.response.appendString(""); + break; + case 4: + this.response.appendString(""); + break; case 5: this.response.appendString(this.bot.getName()); break; - case 6: this.response.appendString(""); break; + case 6: + this.response.appendString(""); + break; case 9: this.response.appendString(this.bot.getMotto()); break; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellAddUserComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellAddUserComposer.java index f4e44a08..9188f1fc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellAddUserComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/DoorbellAddUserComposer.java @@ -4,17 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class DoorbellAddUserComposer extends MessageComposer -{ +public class DoorbellAddUserComposer extends MessageComposer { private final String habbo; - public DoorbellAddUserComposer(String habbo) - { + public DoorbellAddUserComposer(String habbo) { this.habbo = habbo; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.DoorbellAddUserComposer); this.response.appendString(this.habbo); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavoriteRoomChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavoriteRoomChangedComposer.java index ea37f8b3..f0407a7d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavoriteRoomChangedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FavoriteRoomChangedComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FavoriteRoomChangedComposer extends MessageComposer -{ +public class FavoriteRoomChangedComposer extends MessageComposer { private final int roomId; private final boolean favorite; - public FavoriteRoomChangedComposer(int roomId, boolean favorite) - { + public FavoriteRoomChangedComposer(int roomId, boolean favorite) { this.roomId = roomId; this.favorite = favorite; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FavoriteRoomChangedComposer); this.response.appendInt(this.roomId); this.response.appendBoolean(this.favorite); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodCounterComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodCounterComposer.java index e0d2887b..5f32a7a6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodCounterComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloodCounterComposer.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; -public class FloodCounterComposer extends MessageComposer -{ +public class FloodCounterComposer extends MessageComposer { private final int time; - public FloodCounterComposer(int time) - { + public FloodCounterComposer(int time) { this.time = time; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FloodCounterComposer); this.response.appendInt(this.time); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/ForwardToRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/ForwardToRoomComposer.java index aae01b43..16a3f8af 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/ForwardToRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/ForwardToRoomComposer.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; -public class ForwardToRoomComposer extends MessageComposer -{ +public class ForwardToRoomComposer extends MessageComposer { private final int roomId; - public ForwardToRoomComposer(int roomId) - { + public ForwardToRoomComposer(int roomId) { this.roomId = roomId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ForwardToRoomComposer); this.response.appendInt(this.roomId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FreezeLivesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FreezeLivesComposer.java index 63729758..8801555e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FreezeLivesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FreezeLivesComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FreezeLivesComposer extends MessageComposer -{ +public class FreezeLivesComposer extends MessageComposer { private final FreezeGamePlayer gamePlayer; - public FreezeLivesComposer(FreezeGamePlayer gamePlayer) - { + public FreezeLivesComposer(FreezeGamePlayer gamePlayer) { this.gamePlayer = gamePlayer; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FreezeLivesComposer); this.response.appendInt(this.gamePlayer.getHabbo().getHabboInfo().getId()); this.response.appendInt(this.gamePlayer.getLives()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HideDoorbellComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HideDoorbellComposer.java index f5850b4b..65dd5d38 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HideDoorbellComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HideDoorbellComposer.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; -public class HideDoorbellComposer extends MessageComposer -{ +public class HideDoorbellComposer extends MessageComposer { private final String username; - public HideDoorbellComposer(String username) - { + public HideDoorbellComposer(String username) { this.username = username; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HideDoorbellComposer); this.response.appendString(this.username); return this.response; 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 fecef6c7..68106528 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 @@ -4,18 +4,15 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class KnockKnockUnknownComposer extends MessageComposer -{ +public class KnockKnockUnknownComposer extends MessageComposer { private final Habbo habbo; - public KnockKnockUnknownComposer(Habbo habbo) - { + public KnockKnockUnknownComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(478); //TODO Hardcoded header this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendInt(this.habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAccessDeniedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAccessDeniedComposer.java index a6644c25..16fab654 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAccessDeniedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAccessDeniedComposer.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; -public class RoomAccessDeniedComposer extends MessageComposer -{ +public class RoomAccessDeniedComposer extends MessageComposer { private final String habbo; - public RoomAccessDeniedComposer(String habbo) - { + public RoomAccessDeniedComposer(String habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomAccessDeniedComposer); this.response.appendString(this.habbo); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAddRightsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAddRightsListComposer.java index 03d81d1d..2220e376 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAddRightsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomAddRightsListComposer.java @@ -5,22 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomAddRightsListComposer extends MessageComposer -{ +public class RoomAddRightsListComposer extends MessageComposer { private final Room room; private final int userId; private final String userName; - public RoomAddRightsListComposer(Room room, int userId, String username) - { + public RoomAddRightsListComposer(Room room, int userId, String username) { this.room = room; this.userId = userId; this.userName = username; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomAddRightsListComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(this.userId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomBannedUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomBannedUsersComposer.java index 3b308ae2..98482671 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomBannedUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomBannedUsersComposer.java @@ -11,48 +11,40 @@ import gnu.trove.set.hash.THashSet; import java.util.NoSuchElementException; -public class RoomBannedUsersComposer extends MessageComposer -{ +public class RoomBannedUsersComposer extends MessageComposer { private final Room room; - public RoomBannedUsersComposer(Room room) - { + public RoomBannedUsersComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { int timeStamp = Emulator.getIntUnixTimestamp(); THashSet roomBans = new THashSet<>(); TIntObjectIterator iterator = this.room.getBannedHabbos().iterator(); - for(int i = this.room.getBannedHabbos().size(); i-- > 0;) - { - try - { + for (int i = this.room.getBannedHabbos().size(); i-- > 0; ) { + try { iterator.advance(); - if(iterator.value().endTimestamp > timeStamp) + if (iterator.value().endTimestamp > timeStamp) roomBans.add(iterator.value()); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } - if(roomBans.isEmpty()) + if (roomBans.isEmpty()) return null; this.response.init(Outgoing.RoomBannedUsersComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(roomBans.size()); - for(RoomBan ban : roomBans) - { + for (RoomBan ban : roomBans) { this.response.appendInt(ban.userId); this.response.appendString(ban.username); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsComposer.java index f36bf66a..c9f5effa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsComposer.java @@ -5,17 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomChatSettingsComposer extends MessageComposer -{ +public class RoomChatSettingsComposer extends MessageComposer { private final Room room; - public RoomChatSettingsComposer(Room room) - { + public RoomChatSettingsComposer(Room room) { this.room = room; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomChatSettingsComposer); this.response.appendInt(this.room.getChatMode()); this.response.appendInt(this.room.getChatWeight()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java index 59291a17..fca5fe97 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java @@ -8,15 +8,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomDataComposer extends MessageComposer -{ +public class RoomDataComposer extends MessageComposer { private final Room room; private final Habbo habbo; private final boolean publicRoom; private final boolean unknown; - public RoomDataComposer(Room room, Habbo habbo, boolean boolA, boolean boolB) - { + public RoomDataComposer(Room room, Habbo habbo, boolean boolA, boolean boolB) { this.room = room; this.habbo = habbo; this.publicRoom = boolA; @@ -24,18 +22,15 @@ public class RoomDataComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomDataComposer); this.response.appendBoolean(this.unknown); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); - if (this.room.isPublicRoom()) - { + if (this.room.isPublicRoom()) { this.response.appendInt(0); this.response.appendString(""); - } else - { + } else { this.response.appendInt(this.room.getOwnerId()); this.response.appendString(this.room.getOwnerName()); } @@ -48,63 +43,50 @@ public class RoomDataComposer extends MessageComposer this.response.appendInt(this.room.getScore()); this.response.appendInt(this.room.getCategory()); - if (!this.room.getTags().isEmpty()) - { + if (!this.room.getTags().isEmpty()) { String[] tags = this.room.getTags().split(";"); this.response.appendInt(tags.length); - for(String s : tags) - { + for (String s : tags) { this.response.appendString(s); } - } - else - { + } else { this.response.appendInt(0); } int base = 0; - if(this.room.getGuildId() > 0) - { + if (this.room.getGuildId() > 0) { base = base | 2; } - if(!this.room.isPublicRoom()) - { + if (!this.room.isPublicRoom()) { base = base | 8; } - if(this.room.isPromoted()) - { + if (this.room.isPromoted()) { base = base | 4; } - if(this.room.isAllowPets()) - { + if (this.room.isAllowPets()) { base = base | 16; } this.response.appendInt(base); - if(this.room.getGuildId() > 0) - { + if (this.room.getGuildId() > 0) { Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.room.getGuildId()); - if (g != null) - { + if (g != null) { this.response.appendInt(g.getId()); this.response.appendString(g.getName()); this.response.appendString(g.getBadge()); - } - else - { + } else { this.response.appendInt(0); this.response.appendString(""); this.response.appendString(""); } } - if(this.room.isPromoted()) - { + if (this.room.isPromoted()) { this.response.appendString(this.room.getPromotion().getTitle()); this.response.appendString(this.room.getPromotion().getDescription()); this.response.appendInt((this.room.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEditSettingsErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEditSettingsErrorComposer.java index 9f95e063..8dd880bf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEditSettingsErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEditSettingsErrorComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomEditSettingsErrorComposer extends MessageComposer -{ +public class RoomEditSettingsErrorComposer extends MessageComposer { public final static int PASSWORD_REQUIRED = 5; public final static int ROOM_NAME_MISSING = 7; public final static int ROOM_NAME_BADWORDS = 8; @@ -18,16 +17,14 @@ public class RoomEditSettingsErrorComposer extends MessageComposer private final int errorCode; private final String info; - public RoomEditSettingsErrorComposer(int roomId, int errorCode, String info) - { + public RoomEditSettingsErrorComposer(int roomId, int errorCode, String info) { this.roomId = roomId; this.errorCode = errorCode; this.info = info; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomEditSettingsErrorComposer); this.response.appendInt(this.roomId); this.response.appendInt(this.errorCode); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEnterErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEnterErrorComposer.java index 6be81198..e4e16cff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEnterErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEnterErrorComposer.java @@ -4,36 +4,32 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomEnterErrorComposer extends MessageComposer -{ - public static final int ROOM_ERROR_GUESTROOM_FULL = 1; - public static final int ROOM_ERROR_CANT_ENTER = 2; - public static final int ROOM_ERROR_QUE = 3; - public static final int ROOM_ERROR_BANNED = 4; +public class RoomEnterErrorComposer extends MessageComposer { + public static final int ROOM_ERROR_GUESTROOM_FULL = 1; + public static final int ROOM_ERROR_CANT_ENTER = 2; + public static final int ROOM_ERROR_QUE = 3; + public static final int ROOM_ERROR_BANNED = 4; - public static final String ROOM_NEEDS_VIP = "c"; - public static final String EVENT_USERS_ONLY = "e1"; - public static final String ROOM_LOCKED = "na"; - public static final String TO_MANY_SPECTATORS = "spectator_mode_full"; + public static final String ROOM_NEEDS_VIP = "c"; + public static final String EVENT_USERS_ONLY = "e1"; + public static final String ROOM_LOCKED = "na"; + public static final String TO_MANY_SPECTATORS = "spectator_mode_full"; private final int errorCode; private final String queError; - public RoomEnterErrorComposer(int errorCode) - { + public RoomEnterErrorComposer(int errorCode) { this.errorCode = errorCode; this.queError = ""; } - public RoomEnterErrorComposer(int errorCode, String queError) - { + public RoomEnterErrorComposer(int errorCode, String queError) { this.errorCode = errorCode; this.queError = queError; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomEnterErrorComposer); this.response.appendInt(this.errorCode); this.response.appendString(this.queError); 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 d408672c..77392500 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomEntryInfoComposer extends MessageComposer -{ +public class RoomEntryInfoComposer extends MessageComposer { private final Room room; - public RoomEntryInfoComposer(Room room) - { + public RoomEntryInfoComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomEntryInfoComposer); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getOwnerName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterWordsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterWordsComposer.java index 24a28ca9..167e0267 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterWordsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterWordsComposer.java @@ -5,26 +5,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomFilterWordsComposer extends MessageComposer -{ +public class RoomFilterWordsComposer extends MessageComposer { private final Room room; - public RoomFilterWordsComposer(Room room) - { + public RoomFilterWordsComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomFilterWordsComposer); - this.response.appendInt(this.room.getWordFilterWords().size()); + this.response.appendInt(this.room.getWordFilterWords().size()); - for (String string : this.room.getWordFilterWords()) - { - this.response.appendString(string); - } + for (String string : this.room.getWordFilterWords()) { + this.response.appendString(string); + } return this.response; } 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 30846f4b..eadff8b5 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomFloorThicknessUpdatedComposer extends MessageComposer -{ +public class RoomFloorThicknessUpdatedComposer extends MessageComposer { private final Room room; - public RoomFloorThicknessUpdatedComposer(Room room) - { + public RoomFloorThicknessUpdatedComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomFloorThicknessUpdatedComposer); this.response.appendBoolean(this.room.isHideWall()); //Hide walls? this.response.appendInt(this.room.getFloorSize()); //Floor Thickness diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomHeightMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomHeightMapComposer.java index 85d969fe..ca879d5e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomHeightMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomHeightMapComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomHeightMapComposer extends MessageComposer -{ +public class RoomHeightMapComposer extends MessageComposer { private final Room room; - public RoomHeightMapComposer(Room room) - { + public RoomHeightMapComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomHeightMapComposer); this.response.appendBoolean(true); this.response.appendInt(this.room.getWallHeight()); //FixedWallsHeight diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomModelComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomModelComposer.java index 059bb3c4..eb4526fe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomModelComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomModelComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomModelComposer extends MessageComposer -{ +public class RoomModelComposer extends MessageComposer { private final Room room; - public RoomModelComposer(Room room) - { + public RoomModelComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomModelComposer); this.response.appendString(this.room.getLayout().getName()); this.response.appendInt(this.room.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomMutedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomMutedComposer.java index 2d357d9c..0166cfed 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomMutedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomMutedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomMutedComposer extends MessageComposer -{ +public class RoomMutedComposer extends MessageComposer { private final Room room; - public RoomMutedComposer(Room room) - { + public RoomMutedComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomMutedComposer); this.response.appendBoolean(this.room.isMuted()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomNoRightsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomNoRightsComposer.java index 0a637462..49cd1543 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomNoRightsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomNoRightsComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomNoRightsComposer extends MessageComposer -{ +public class RoomNoRightsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomNoRightsComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOpenComposer.java index a630f541..10141d45 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOpenComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomOpenComposer extends MessageComposer -{ +public class RoomOpenComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomOpenComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOwnerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOwnerComposer.java index cc0b1f78..b1d1976e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOwnerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomOwnerComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomOwnerComposer extends MessageComposer -{ +public class RoomOwnerComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomOwnerComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaintComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaintComposer.java index 683a6557..72f7b741 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaintComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaintComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPaintComposer extends MessageComposer -{ +public class RoomPaintComposer extends MessageComposer { private final String type; private final String value; - public RoomPaintComposer(String type, String value) - { + public RoomPaintComposer(String type, String value) { this.type = type; this.value = value; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomPaintComposer); this.response.appendString(this.type); this.response.appendString(this.value); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaneComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaneComposer.java index 9da8de7d..3d0e6810 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaneComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomPaneComposer.java @@ -5,19 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPaneComposer extends MessageComposer -{ +public class RoomPaneComposer extends MessageComposer { private final Room room; private final boolean roomOwner; - public RoomPaneComposer(Room room, boolean roomOwner) - { + public RoomPaneComposer(Room room, boolean roomOwner) { this.room = room; this.roomOwner = roomOwner; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomPaneComposer); this.response.appendInt(this.room.getId()); this.response.appendBoolean(this.roomOwner); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomQueueStatusMessage.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomQueueStatusMessage.java index a5c14a5c..7257b7ad 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomQueueStatusMessage.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomQueueStatusMessage.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomQueueStatusMessage extends MessageComposer -{ +public class RoomQueueStatusMessage extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomQueueStatusMessage); this.response.appendInt(1); //Count { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java index 2edde5cd..c500b5b2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java @@ -6,25 +6,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomRelativeMapComposer extends MessageComposer -{ +public class RoomRelativeMapComposer extends MessageComposer { private final Room room; - public RoomRelativeMapComposer(Room room) - { + public RoomRelativeMapComposer(Room room) { this.room = room; } - + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomRelativeMapComposer); this.response.appendInt(this.room.getLayout().getMapSize() / this.room.getLayout().getMapSizeY()); this.response.appendInt(this.room.getLayout().getMapSize()); - for (short y = 0; y < this.room.getLayout().getMapSizeY(); y++) - { - for (short x = 0; x < this.room.getLayout().getMapSizeX(); x++) - { + for (short y = 0; y < this.room.getLayout().getMapSizeY(); y++) { + for (short x = 0; x < this.room.getLayout().getMapSizeX(); x++) { RoomTile t = this.room.getLayout().getTile(x, y); if (t != null) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRemoveRightsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRemoveRightsListComposer.java index c9dde6e3..3b4e7d4f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRemoveRightsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRemoveRightsListComposer.java @@ -5,21 +5,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomRemoveRightsListComposer extends MessageComposer -{ +public class RoomRemoveRightsListComposer extends MessageComposer { private final Room room; private final int userId; - public RoomRemoveRightsListComposer(Room room, int userId) - { + public RoomRemoveRightsListComposer(Room room, int userId) { this.room = room; this.userId = userId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomRemoveRightsListComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(this.userId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsComposer.java index 3b6d6700..f24039f8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomRightsComposer extends MessageComposer -{ +public class RoomRightsComposer extends MessageComposer { private final RoomRightLevels type; - public RoomRightsComposer(RoomRightLevels type) - { + public RoomRightsComposer(RoomRightLevels type) { this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomRightsComposer); this.response.appendInt(this.type.level); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java index 6aead2c6..531eafa0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java @@ -8,18 +8,15 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class RoomRightsListComposer extends MessageComposer -{ +public class RoomRightsListComposer extends MessageComposer { private final Room room; - public RoomRightsListComposer(Room room) - { + public RoomRightsListComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomRightsListComposer); this.response.appendInt(this.room.getId()); @@ -27,8 +24,7 @@ public class RoomRightsListComposer extends MessageComposer this.response.appendInt(rightsMap.size()); - for(Map.Entry set : rightsMap.entrySet()) - { + for (Map.Entry set : rightsMap.entrySet()) { this.response.appendInt(set.getKey()); this.response.appendString(set.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomScoreComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomScoreComposer.java index c2d7c926..c48b5197 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomScoreComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomScoreComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomScoreComposer extends MessageComposer -{ +public class RoomScoreComposer extends MessageComposer { private final int score; private final boolean canVote; - public RoomScoreComposer(int score, boolean canVote) - { + public RoomScoreComposer(int score, boolean canVote) { this.score = score; this.canVote = canVote; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomScoreComposer); this.response.appendInt(this.score); this.response.appendBoolean(this.canVote); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsComposer.java index 7fa54b3d..d0b55acf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomSettingsComposer extends MessageComposer -{ +public class RoomSettingsComposer extends MessageComposer { private final Room room; - public RoomSettingsComposer(Room room) - { + public RoomSettingsComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomSettingsComposer); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); @@ -26,19 +23,15 @@ public class RoomSettingsComposer extends MessageComposer this.response.appendInt(this.room.getUsersMax()); this.response.appendInt(this.room.getUsersMax()); - if (!this.room.getTags().isEmpty()) - { + if (!this.room.getTags().isEmpty()) { this.response.appendInt(this.room.getTags().split(";").length); - for (String tag : this.room.getTags().split(";")) - { + for (String tag : this.room.getTags().split(";")) { this.response.appendString(tag); } - } - else - { + } else { this.response.appendInt(0); } - + //this.response.appendInt(this.room.getRights().size()); this.response.appendInt(this.room.getTradeMode()); //Trade Mode this.response.appendInt(this.room.isAllowPets() ? 1 : 0); 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 1faf88f0..d1e17aea 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomSettingsSavedComposer extends MessageComposer -{ +public class RoomSettingsSavedComposer extends MessageComposer { private final Room room; - public RoomSettingsSavedComposer(Room room) - { + public RoomSettingsSavedComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomSettingsSavedComposer); this.response.appendInt(this.room.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsUpdatedComposer.java index 7f7f97a8..9dc3bd9c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsUpdatedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomSettingsUpdatedComposer extends MessageComposer -{ +public class RoomSettingsUpdatedComposer extends MessageComposer { private final Room room; - public RoomSettingsUpdatedComposer(Room room) - { + public RoomSettingsUpdatedComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomSettingsUpdatedComposer); this.response.appendInt(this.room.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomThicknessComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomThicknessComposer.java index c570d544..8225a28a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomThicknessComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomThicknessComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomThicknessComposer extends MessageComposer -{ +public class RoomThicknessComposer extends MessageComposer { private final Room room; - public RoomThicknessComposer(Room room) - { + public RoomThicknessComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomThicknessComposer); this.response.appendBoolean(this.room.isHideWall()); this.response.appendInt(this.room.getWallSize()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index 2c707a39..4f6c3b67 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -6,42 +6,34 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class UpdateStackHeightComposer extends MessageComposer -{ +public class UpdateStackHeightComposer extends MessageComposer { private int x; private int y; private double height; private THashSet updateTiles; - public UpdateStackHeightComposer(int x, int y, double height) - { + public UpdateStackHeightComposer(int x, int y, double height) { this.x = x; this.y = y; this.height = height; } - public UpdateStackHeightComposer(THashSet updateTiles) - { + public UpdateStackHeightComposer(THashSet updateTiles) { this.updateTiles = updateTiles; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateStackHeightComposer); - if(this.updateTiles != null) - { + if (this.updateTiles != null) { this.response.appendByte(this.updateTiles.size()); - for(RoomTile t : this.updateTiles) - { + for (RoomTile t : this.updateTiles) { this.response.appendByte((int) t.x); this.response.appendByte((int) t.y); this.response.appendShort(t.relativeHeight()); } - } - else - { + } else { this.response.appendByte(1); this.response.appendByte(this.x); this.response.appendByte(this.y); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddFloorItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddFloorItemComposer.java index 6f59f401..b1ca2d01 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddFloorItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddFloorItemComposer.java @@ -7,20 +7,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AddFloorItemComposer extends MessageComposer -{ +public class AddFloorItemComposer extends MessageComposer { private final HabboItem item; private final String itemOwnerName; - public AddFloorItemComposer(HabboItem item, String itemOwnerName) - { + public AddFloorItemComposer(HabboItem item, String itemOwnerName) { this.item = item; this.itemOwnerName = itemOwnerName == null ? "" : itemOwnerName; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddFloorItemComposer); this.item.serializeFloorData(this.response); this.response.appendInt(this.item instanceof InteractionGift ? ((((InteractionGift) this.item).getColorId() * 1000) + ((InteractionGift) this.item).getRibbonId()) : (this.item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) this.item).getSongId() : 1)); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddWallItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddWallItemComposer.java index 96379ff5..e026993e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddWallItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/AddWallItemComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AddWallItemComposer extends MessageComposer -{ +public class AddWallItemComposer extends MessageComposer { private final HabboItem item; private final String itemOwnerName; - public AddWallItemComposer(HabboItem item, String itemOwnerName) - { + public AddWallItemComposer(HabboItem item, String itemOwnerName) { this.item = item; this.itemOwnerName = itemOwnerName; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddWallItemComposer); this.item.serializeWallData(this.response); this.response.appendString(this.itemOwnerName); 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 3bbb543c..9b867a23 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 @@ -9,16 +9,14 @@ import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer; import gnu.trove.set.hash.THashSet; -public class FloorItemOnRollerComposer extends MessageComposer -{ +public class FloorItemOnRollerComposer extends MessageComposer { private final HabboItem item; private final HabboItem roller; private final RoomTile newLocation; private final double heightOffset; private final Room room; - public FloorItemOnRollerComposer(HabboItem item, HabboItem roller, RoomTile newLocation, double heightOffset, Room room) - { + public FloorItemOnRollerComposer(HabboItem item, HabboItem roller, RoomTile newLocation, double heightOffset, Room room) { this.item = item; this.roller = roller; this.newLocation = newLocation; @@ -27,8 +25,7 @@ public class FloorItemOnRollerComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { short oldX = this.item.getX(); short oldY = this.item.getY(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemUpdateComposer.java index 67927ace..9e611ef4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemUpdateComposer.java @@ -7,18 +7,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class FloorItemUpdateComposer extends MessageComposer -{ +public class FloorItemUpdateComposer extends MessageComposer { private final HabboItem item; - public FloorItemUpdateComposer(HabboItem item) - { + public FloorItemUpdateComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FloorItemUpdateComposer); this.item.serializeFloorData(this.response); this.response.appendInt(this.item instanceof InteractionGift ? ((((InteractionGift) this.item).getColorId() * 1000) + ((InteractionGift) this.item).getRibbonId()) : (this.item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) this.item).getSongId() : item.isUsable() ? 0 : 0)); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemExtraDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemExtraDataComposer.java index 70a8887b..8474dc57 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemExtraDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemExtraDataComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ItemExtraDataComposer extends MessageComposer -{ +public class ItemExtraDataComposer extends MessageComposer { private final HabboItem item; - public ItemExtraDataComposer(HabboItem item) - { + public ItemExtraDataComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ItemExtraDataComposer); this.response.appendString(this.item.getId() + ""); this.item.serializeExtradata(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemIntStateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemIntStateComposer.java index f39a162a..7ed2f844 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemIntStateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemIntStateComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ItemIntStateComposer extends MessageComposer -{ +public class ItemIntStateComposer extends MessageComposer { private final int id; private final int value; - public ItemIntStateComposer(int id, int value) - { + public ItemIntStateComposer(int id, int value) { this.id = id; this.value = value; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ItemStateComposer2); this.response.appendInt(this.id); this.response.appendInt(this.value); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemStateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemStateComposer.java index b72284d3..eed094b1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemStateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemStateComposer.java @@ -5,27 +5,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ItemStateComposer extends MessageComposer -{ +public class ItemStateComposer extends MessageComposer { private final HabboItem item; - public ItemStateComposer(HabboItem item) - { + public ItemStateComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ItemStateComposer); this.response.appendInt(this.item.getId()); - try - { + try { int state = Integer.valueOf(this.item.getExtradata()); this.response.appendInt(state); - } - catch (Exception e) - { + } catch (Exception e) { this.response.appendInt(0); } 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 2a7b1adc..aa5244e8 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 @@ -7,22 +7,18 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class ItemsDataUpdateComposer extends MessageComposer -{ +public class ItemsDataUpdateComposer extends MessageComposer { private final List items; - public ItemsDataUpdateComposer(List items) - { + public ItemsDataUpdateComposer(List items) { this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ItemsDataUpdateComposer); this.response.appendInt(this.items.size()); - for (HabboItem item : this.items) - { + for (HabboItem item : this.items) { item.serializeExtradata(this.response); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/MoodLightDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/MoodLightDataComposer.java index f0351352..9306b6f9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/MoodLightDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/MoodLightDataComposer.java @@ -6,26 +6,21 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; -public class MoodLightDataComposer extends MessageComposer -{ +public class MoodLightDataComposer extends MessageComposer { private final TIntObjectMap moodLightData; - public MoodLightDataComposer(TIntObjectMap moodLightData) - { + public MoodLightDataComposer(TIntObjectMap moodLightData) { this.moodLightData = moodLightData; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MoodLightDataComposer); this.response.appendInt(3); //PresetCount int index = 1; - for(RoomMoodlightData data : this.moodLightData.valueCollection()) - { - if(data.isEnabled()) - { + for (RoomMoodlightData data : this.moodLightData.valueCollection()) { + if (data.isEnabled()) { this.response.appendInt(data.getId()); index = -1; break; @@ -33,14 +28,12 @@ public class MoodLightDataComposer extends MessageComposer index++; } - if(index != -1) - { + if (index != -1) { this.response.appendInt(1); } int i = 1; - for(RoomMoodlightData data : this.moodLightData.valueCollection()) - { + for (RoomMoodlightData data : this.moodLightData.valueCollection()) { this.response.appendInt(data.getId()); //Preset ID this.response.appendInt(data.isBackgroundOnly() ? 2 : 1); //Background only ? 2 : 1 this.response.appendString(data.getColor()); //Color @@ -48,8 +41,7 @@ public class MoodLightDataComposer extends MessageComposer i++; } - for(; i <= 3; i++) - { + for (; i <= 3; i++) { this.response.appendInt(i); this.response.appendInt(1); this.response.appendString("#000000"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItDataComposer.java index 0600fdfc..f281234c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItDataComposer.java @@ -5,20 +5,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PostItDataComposer extends MessageComposer -{ +public class PostItDataComposer extends MessageComposer { private final InteractionPostIt postIt; - public PostItDataComposer(InteractionPostIt postIt) - { + public PostItDataComposer(InteractionPostIt postIt) { this.postIt = postIt; } @Override - public ServerMessage compose() - { - if(this.postIt.getExtradata().isEmpty() || this.postIt.getExtradata().length() < 6) - { + public ServerMessage compose() { + if (this.postIt.getExtradata().isEmpty() || this.postIt.getExtradata().length() < 6) { this.postIt.setExtradata("FFFF33"); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItStickyPoleOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItStickyPoleOpenComposer.java index 0bf1e758..89490e5b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItStickyPoleOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PostItStickyPoleOpenComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PostItStickyPoleOpenComposer extends MessageComposer -{ +public class PostItStickyPoleOpenComposer extends MessageComposer { private final HabboItem item; - public PostItStickyPoleOpenComposer(HabboItem item) - { + public PostItStickyPoleOpenComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PostItStickyPoleOpenComposer); this.response.appendInt(this.item == null ? -1234 : this.item.getId()); this.response.appendString(""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentItemOpenedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentItemOpenedComposer.java index 5261a482..e5df5b8d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentItemOpenedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentItemOpenedComposer.java @@ -5,22 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PresentItemOpenedComposer extends MessageComposer -{ +public class PresentItemOpenedComposer extends MessageComposer { private final HabboItem item; private final String text; private final boolean unknown; - public PresentItemOpenedComposer(HabboItem item, String text, boolean unknown) - { + public PresentItemOpenedComposer(HabboItem item, String text, boolean unknown) { this.item = item; this.text = text; this.unknown = unknown; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PresentItemOpenedComposer); this.response.appendString(this.item.getBaseItem().getType().code.toLowerCase()); this.response.appendInt(this.item.getBaseItem().getSpriteId()); 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 a14d2fb2..689a1db7 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 @@ -5,26 +5,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RemoveFloorItemComposer extends MessageComposer -{ +public class RemoveFloorItemComposer extends MessageComposer { private final HabboItem item; private final boolean noUser; - public RemoveFloorItemComposer(HabboItem item) - { + public RemoveFloorItemComposer(HabboItem item) { this.item = item; this.noUser = false; } - public RemoveFloorItemComposer(HabboItem item, boolean noUser) - { + public RemoveFloorItemComposer(HabboItem item, boolean noUser) { this.item = item; this.noUser = noUser; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveFloorItemComposer); this.response.appendString(this.item.getId() + ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveWallItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveWallItemComposer.java index dd8dc773..a5f73fa9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveWallItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveWallItemComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RemoveWallItemComposer extends MessageComposer -{ +public class RemoveWallItemComposer extends MessageComposer { private final HabboItem item; - public RemoveWallItemComposer(HabboItem item) - { + public RemoveWallItemComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveWallItemComposer); this.response.appendString(this.item.getId() + ""); this.response.appendInt(this.item.getUserId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomFloorItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomFloorItemsComposer.java index ff261941..69fd12f2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomFloorItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomFloorItemsComposer.java @@ -12,43 +12,35 @@ import gnu.trove.set.hash.THashSet; import java.util.NoSuchElementException; -public class RoomFloorItemsComposer extends MessageComposer -{ +public class RoomFloorItemsComposer extends MessageComposer { private final TIntObjectMap furniOwnerNames; private final THashSet items; - public RoomFloorItemsComposer(TIntObjectMap furniOwnerNames, THashSet items) - { + public RoomFloorItemsComposer(TIntObjectMap furniOwnerNames, THashSet items) { this.furniOwnerNames = furniOwnerNames; this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomFloorItemsComposer); TIntObjectIterator iterator = this.furniOwnerNames.iterator(); this.response.appendInt(this.furniOwnerNames.size()); - for(int i = this.furniOwnerNames.size(); i-- > 0;) - { - try - { + for (int i = this.furniOwnerNames.size(); i-- > 0; ) { + try { iterator.advance(); this.response.appendInt(iterator.key()); this.response.appendString(iterator.value()); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } this.response.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { item.serializeFloorData(this.response); this.response.appendInt(item instanceof InteractionGift ? ((((InteractionGift) item).getColorId() * 1000) + ((InteractionGift) item).getRibbonId()) : (item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) item).getSongId() : 1)); item.serializeExtradata(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomWallItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomWallItemsComposer.java index 37aa801d..f20f8a39 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomWallItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RoomWallItemsComposer.java @@ -13,40 +13,32 @@ import gnu.trove.set.hash.THashSet; import java.util.Map; import java.util.NoSuchElementException; -public class RoomWallItemsComposer extends MessageComposer -{ +public class RoomWallItemsComposer extends MessageComposer { private final Room room; - public RoomWallItemsComposer(Room room) - { + public RoomWallItemsComposer(Room room) { this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomWallItemsComposer); THashMap userNames = new THashMap<>(); TIntObjectMap furniOwnerNames = this.room.getFurniOwnerNames(); TIntObjectIterator iterator = furniOwnerNames.iterator(); - for(int i = furniOwnerNames.size(); i-- > 0;) - { - try - { + for (int i = furniOwnerNames.size(); i-- > 0; ) { + try { iterator.advance(); userNames.put(iterator.key(), iterator.value()); - } - catch (NoSuchElementException e) - { + } catch (NoSuchElementException e) { break; } } this.response.appendInt(userNames.size()); - for(Map.Entry set : userNames.entrySet()) - { + for (Map.Entry set : userNames.entrySet()) { this.response.appendInt(set.getKey()); this.response.appendString(set.getValue()); } @@ -54,8 +46,7 @@ public class RoomWallItemsComposer extends MessageComposer THashSet items = this.room.getWallItems(); this.response.appendInt(items.size()); - for(HabboItem item : items) - { + for (HabboItem item : items) { item.serializeWallData(this.response); } return this.response; 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 3347e333..85163e3f 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 @@ -5,21 +5,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UpdateStackHeightTileHeightComposer extends MessageComposer -{ +public class UpdateStackHeightTileHeightComposer extends MessageComposer { private final HabboItem item; private final int height; - public UpdateStackHeightTileHeightComposer(HabboItem item, int height) - { + public UpdateStackHeightTileHeightComposer(HabboItem item, int height) { this.item = item; this.height = height; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateStackHeightTileHeightComposer); this.response.appendInt(this.item.getId()); this.response.appendInt(this.height); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/WallItemUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/WallItemUpdateComposer.java index 78b6af3c..06378799 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/WallItemUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/WallItemUpdateComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WallItemUpdateComposer extends MessageComposer -{ +public class WallItemUpdateComposer extends MessageComposer { private final HabboItem item; - public WallItemUpdateComposer(HabboItem item) - { + public WallItemUpdateComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WallItemUpdateComposer); this.item.serializeWallData(this.response); this.response.appendString(this.item.getUserId() + ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxMySongsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxMySongsComposer.java index cfdc9959..ecb18c5b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxMySongsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxMySongsComposer.java @@ -8,24 +8,20 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class JukeBoxMySongsComposer extends MessageComposer -{ +public class JukeBoxMySongsComposer extends MessageComposer { private final List items; - public JukeBoxMySongsComposer(List items) - { + public JukeBoxMySongsComposer(List items) { this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxMySongsComposer); this.response.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { this.response.appendInt(item.getId()); this.response.appendInt(((InteractionMusicDisc) item).getSongId()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxNowPlayingMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxNowPlayingMessageComposer.java index bff31e5c..feb27aee 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxNowPlayingMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxNowPlayingMessageComposer.java @@ -5,34 +5,28 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class JukeBoxNowPlayingMessageComposer extends MessageComposer -{ +public class JukeBoxNowPlayingMessageComposer extends MessageComposer { private final SoundTrack track; private final int playListId; private final int msPlayed; - public JukeBoxNowPlayingMessageComposer(SoundTrack track, int playListId, int msPlayed) - { + public JukeBoxNowPlayingMessageComposer(SoundTrack track, int playListId, int msPlayed) { this.track = track; this.playListId = playListId; this.msPlayed = msPlayed; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxNowPlayingMessageComposer); - if(this.track != null) - { + if (this.track != null) { this.response.appendInt(this.track.getId()); this.response.appendInt(this.playListId); this.response.appendInt(this.track.getId()); this.response.appendInt(this.track.getLength()); this.response.appendInt(this.msPlayed); - } - else - { + } else { this.response.appendInt(-1); this.response.appendInt(-1); this.response.appendInt(-1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListAddSongComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListAddSongComposer.java index 6223c7c4..2b47a767 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListAddSongComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListAddSongComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class JukeBoxPlayListAddSongComposer extends MessageComposer -{ +public class JukeBoxPlayListAddSongComposer extends MessageComposer { private final SoundTrack track; - public JukeBoxPlayListAddSongComposer(SoundTrack track) - { + public JukeBoxPlayListAddSongComposer(SoundTrack track) { this.track = track; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxPlayListAddSongComposer); this.response.appendInt(this.track.getId()); this.response.appendInt(this.track.getLength() * 1000); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListComposer.java index 9bac21d5..770ebf47 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListComposer.java @@ -7,25 +7,21 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class JukeBoxPlayListComposer extends MessageComposer -{ +public class JukeBoxPlayListComposer extends MessageComposer { private final List songs; private final int totalLength; - public JukeBoxPlayListComposer(List songs, int totalLength) - { + public JukeBoxPlayListComposer(List songs, int totalLength) { this.songs = songs; this.totalLength = totalLength; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxPlayListComposer); this.response.appendInt(this.totalLength); //Dunno //TODO Total play length? this.response.appendInt(this.songs.size()); - for (InteractionMusicDisc soundTrack : this.songs) - { + for (InteractionMusicDisc soundTrack : this.songs) { this.response.appendInt(soundTrack.getId()); this.response.appendInt(soundTrack.getSongId()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListUpdatedComposer.java index fa22f708..ec12fcac 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlayListUpdatedComposer.java @@ -6,32 +6,27 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class JukeBoxPlayListUpdatedComposer extends MessageComposer -{ +public class JukeBoxPlayListUpdatedComposer extends MessageComposer { private final THashSet tracks; - public JukeBoxPlayListUpdatedComposer(THashSet tracks) - { + public JukeBoxPlayListUpdatedComposer(THashSet tracks) { this.tracks = tracks; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxPlayListUpdatedComposer); int length = 0; - for(SoundTrack track : this.tracks) - { + for (SoundTrack track : this.tracks) { length += track.getLength(); } this.response.appendInt(length * 1000); this.response.appendInt(this.tracks.size()); - for(SoundTrack track : this.tracks) - { + for (SoundTrack track : this.tracks) { this.response.appendInt(track.getId()); this.response.appendInt(track.getLength() * 1000); this.response.appendString(track.getCode()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlaylistFullComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlaylistFullComposer.java index 30196bed..2f558194 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlaylistFullComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxPlaylistFullComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class JukeBoxPlaylistFullComposer extends MessageComposer -{ +public class JukeBoxPlaylistFullComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxPlaylistFullComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackCodeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackCodeComposer.java index 2243e233..e72738d6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackCodeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackCodeComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class JukeBoxTrackCodeComposer extends MessageComposer -{ +public class JukeBoxTrackCodeComposer extends MessageComposer { private final SoundTrack track; - public JukeBoxTrackCodeComposer(SoundTrack track) - { + public JukeBoxTrackCodeComposer(SoundTrack track) { this.track = track; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxTrackCodeComposer); this.response.appendString(this.track.getCode()); this.response.appendInt(this.track.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackDataComposer.java index 293135ee..989b412f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/jukebox/JukeBoxTrackDataComposer.java @@ -7,23 +7,19 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class JukeBoxTrackDataComposer extends MessageComposer -{ +public class JukeBoxTrackDataComposer extends MessageComposer { private final List tracks; - public JukeBoxTrackDataComposer(List tracks) - { + public JukeBoxTrackDataComposer(List tracks) { this.tracks = tracks; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.JukeBoxTrackDataComposer); this.response.appendInt(this.tracks.size()); - for(SoundTrack track : this.tracks) - { + for (SoundTrack track : this.tracks) { this.response.appendInt(track.getId()); this.response.appendString(track.getCode()); this.response.appendString(track.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFinishedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFinishedComposer.java index 72eaf12b..98a1fe74 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFinishedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFinishedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class LoveLockFurniFinishedComposer extends MessageComposer -{ +public class LoveLockFurniFinishedComposer extends MessageComposer { private final InteractionLoveLock loveLock; - public LoveLockFurniFinishedComposer(InteractionLoveLock loveLock) - { + public LoveLockFurniFinishedComposer(InteractionLoveLock loveLock) { this.loveLock = loveLock; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.LoveLockFurniFinishedComposer); this.response.appendInt(this.loveLock.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFriendConfirmedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFriendConfirmedComposer.java index 0e8ea0f7..c0e2b8ae 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFriendConfirmedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniFriendConfirmedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class LoveLockFurniFriendConfirmedComposer extends MessageComposer -{ +public class LoveLockFurniFriendConfirmedComposer extends MessageComposer { private final InteractionLoveLock loveLock; - public LoveLockFurniFriendConfirmedComposer(InteractionLoveLock loveLock) - { + public LoveLockFurniFriendConfirmedComposer(InteractionLoveLock loveLock) { this.loveLock = loveLock; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.LoveLockFurniFriendConfirmedComposer); this.response.appendInt(this.loveLock.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniStartComposer.java index 9c974741..c20d72e0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/lovelock/LoveLockFurniStartComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class LoveLockFurniStartComposer extends MessageComposer -{ +public class LoveLockFurniStartComposer extends MessageComposer { private final InteractionLoveLock loveLock; - public LoveLockFurniStartComposer(InteractionLoveLock loveLock) - { + public LoveLockFurniStartComposer(InteractionLoveLock loveLock) { this.loveLock = loveLock; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.LoveLockFurniStartComposer); this.response.appendInt(this.loveLock.getId()); this.response.appendBoolean(true); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceInfoComposer.java index 4532990f..4287a9fb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceInfoComposer.java @@ -8,8 +8,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RentableSpaceInfoComposer extends MessageComposer -{ +public class RentableSpaceInfoComposer extends MessageComposer { public static final int SPACE_ALREADY_RENTED = 100; public static final int SPACE_EXTEND_NOT_RENTED = 101; public static final int SPACE_EXTEND_NOT_RENTED_BY_YOU = 102; @@ -26,24 +25,21 @@ public class RentableSpaceInfoComposer extends MessageComposer private final HabboItem item; private final int errorCode; - public RentableSpaceInfoComposer(Habbo habbo, HabboItem item) - { + public RentableSpaceInfoComposer(Habbo habbo, HabboItem item) { this.habbo = habbo; this.item = item; this.errorCode = 0; } - public RentableSpaceInfoComposer(Habbo habbo, HabboItem item, int errorCode) - { + public RentableSpaceInfoComposer(Habbo habbo, HabboItem item, int errorCode) { this.habbo = habbo; this.item = item; this.errorCode = errorCode; } @Override - public ServerMessage compose() - { - if(!(this.item instanceof InteractionRentableSpace)) + public ServerMessage compose() { + if (!(this.item instanceof InteractionRentableSpace)) return null; this.response.init(Outgoing.RentableSpaceInfoComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknown2Composer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknown2Composer.java index e66aa169..01d43170 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknown2Composer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknown2Composer.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; -public class RentableSpaceUnknown2Composer extends MessageComposer -{ +public class RentableSpaceUnknown2Composer extends MessageComposer { private final int itemId; - public RentableSpaceUnknown2Composer(int itemId) - { + public RentableSpaceUnknown2Composer(int itemId) { this.itemId = itemId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RentableSpaceUnknown2Composer); this.response.appendInt(this.itemId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknownComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknownComposer.java index 3112caa8..d8a69db3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknownComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceUnknownComposer.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; -public class RentableSpaceUnknownComposer extends MessageComposer -{ +public class RentableSpaceUnknownComposer extends MessageComposer { private final int itemId; - public RentableSpaceUnknownComposer(int itemId) - { + public RentableSpaceUnknownComposer(int itemId) { this.itemId = itemId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RentableSpaceUnknownComposer); this.response.appendInt(this.itemId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java index 79fb8063..ef92a8dd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java @@ -7,26 +7,22 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; -public class YoutubeDisplayListComposer extends MessageComposer -{ +public class YoutubeDisplayListComposer extends MessageComposer { public final int itemId; public final ArrayList items; - public YoutubeDisplayListComposer(int itemId, ArrayList items) - { + public YoutubeDisplayListComposer(int itemId, ArrayList items) { this.itemId = itemId; this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.YoutubeDisplayListComposer); this.response.appendInt(this.itemId); this.response.appendInt(this.items.size()); - for (YoutubeManager.YoutubeItem item : this.items) - { + for (YoutubeManager.YoutubeItem item : this.items) { this.response.appendString(item.video); this.response.appendString(item.title); this.response.appendString(item.description); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java index 9feec89d..be386b06 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class YoutubeVideoComposer extends MessageComposer -{ +public class YoutubeVideoComposer extends MessageComposer { public final int itemId; public final YoutubeManager.YoutubeItem item; - public YoutubeVideoComposer(int itemId, YoutubeManager.YoutubeItem item) - { + public YoutubeVideoComposer(int itemId, YoutubeManager.YoutubeItem item) { this.itemId = itemId; this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.YoutubeMessageComposer2); this.response.appendInt(this.itemId); this.response.appendString(this.item.video); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/CantScratchPetNotOldEnoughComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/CantScratchPetNotOldEnoughComposer.java index c20052a2..8d3059e9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/CantScratchPetNotOldEnoughComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/CantScratchPetNotOldEnoughComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CantScratchPetNotOldEnoughComposer extends MessageComposer -{ +public class CantScratchPetNotOldEnoughComposer extends MessageComposer { private final int currentAge; private final int requiredAge; - public CantScratchPetNotOldEnoughComposer(int currentAge, int requiredAge) - { + public CantScratchPetNotOldEnoughComposer(int currentAge, int requiredAge) { this.currentAge = currentAge; this.requiredAge = requiredAge; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CantScratchPetNotOldEnoughComposer); this.response.appendInt(this.currentAge); this.response.appendInt(this.requiredAge); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInformationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInformationComposer.java index a21f8948..cdef5e5b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInformationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetInformationComposer.java @@ -1,50 +1,44 @@ package com.eu.habbo.messages.outgoing.rooms.pets; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.pets.*; +import com.eu.habbo.habbohotel.pets.MonsterplantPet; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetManager; +import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.Room; 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; -public class PetInformationComposer extends MessageComposer -{ +public class PetInformationComposer extends MessageComposer { private final Pet pet; private final Room room; private final Habbo requestingHabbo; - public PetInformationComposer(Pet pet, Room room, Habbo requestingHabbo) - { + public PetInformationComposer(Pet pet, Room room, Habbo requestingHabbo) { this.pet = pet; this.room = room; this.requestingHabbo = requestingHabbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { double days = Math.floor((Emulator.getIntUnixTimestamp() - this.pet.getCreated()) / (3600 * 24)); this.response.init(Outgoing.PetInformationComposer); this.response.appendInt(this.pet.getId()); this.response.appendString(this.pet.getName()); - if(this.pet instanceof MonsterplantPet) - { + if (this.pet instanceof MonsterplantPet) { this.response.appendInt(((MonsterplantPet) this.pet).getGrowthStage()); //This equal this.response.appendInt(7); //... to this means breedable - } - else - { + } else { this.response.appendInt(this.pet.getLevel()); //level this.response.appendInt(20); //max level } this.response.appendInt(this.pet.getExperience()); - if (this.pet.getLevel() < PetManager.experiences.length + 1) - { + if (this.pet.getLevel() < PetManager.experiences.length + 1) { this.response.appendInt(PetManager.experiences[this.pet.getLevel() - 1]); //XP Goal - } - else - { + } else { this.response.appendInt(this.pet.getExperience()); } this.response.appendInt(this.pet.getEnergy()); @@ -71,7 +65,6 @@ public class PetInformationComposer extends MessageComposer this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isPubliclyBreedable()); //Breedable checkbox - return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpComposer.java index d8ed469b..03c44e51 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetLevelUpComposer extends MessageComposer -{ +public class PetLevelUpComposer extends MessageComposer { private final Pet pet; - public PetLevelUpComposer(Pet pet) - { + public PetLevelUpComposer(Pet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetLevelUpComposer); this.response.appendInt(this.pet.getId()); this.response.appendString(this.pet.getName()); 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 ee5f9181..72810ce9 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetLevelUpdatedComposer extends MessageComposer -{ +public class PetLevelUpdatedComposer extends MessageComposer { private final Pet pet; - public PetLevelUpdatedComposer(Pet pet) - { + public PetLevelUpdatedComposer(Pet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetLevelUpdatedComposer); this.response.appendInt(this.pet.getRoomUnit().getId()); this.response.appendInt(this.pet.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageComposer.java index 535defa5..cb1eff93 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetPackageComposer extends MessageComposer -{ +public class PetPackageComposer extends MessageComposer { private final HabboItem item; - public PetPackageComposer(HabboItem item) - { + public PetPackageComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.LeprechaunStarterBundleComposer); this.response.appendInt(this.item.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageNameValidationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageNameValidationComposer.java index abe1cfbe..a3e8e277 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageNameValidationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetPackageNameValidationComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetPackageNameValidationComposer extends MessageComposer -{ +public class PetPackageNameValidationComposer extends MessageComposer { public static final int CLOSE_WIDGET = 0; public static final int NAME_TOO_SHORT = 1; public static final int NAME_TOO_LONG = 2; @@ -16,16 +15,14 @@ public class PetPackageNameValidationComposer extends MessageComposer private final int errorCode; private final String errorString; - public PetPackageNameValidationComposer(int itemId, int errorCode, String errorString) - { + public PetPackageNameValidationComposer(int itemId, int errorCode, String errorString) { this.itemId = itemId; this.errorCode = errorCode; this.errorString = errorString; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetPackageNameValidationComposer); this.response.appendInt(this.itemId); this.response.appendInt(this.errorCode); 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 b9938e86..4c21820d 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 @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.rooms.pets; -import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -8,18 +7,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetStatusUpdateComposer extends MessageComposer -{ +public class PetStatusUpdateComposer extends MessageComposer { private final Pet pet; - public PetStatusUpdateComposer(Pet pet) - { + public PetStatusUpdateComposer(Pet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetStatusUpdateComposer); this.response.appendInt(this.pet.getRoomUnit().getId()); this.response.appendInt(this.pet instanceof RideablePet && ((RideablePet) this.pet).anyoneCanRide() ? 1 : 0); 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 8247df04..184cd32e 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 @@ -10,18 +10,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class PetTrainingPanelComposer extends MessageComposer -{ +public class PetTrainingPanelComposer extends MessageComposer { private final Pet pet; - public PetTrainingPanelComposer(Pet pet) - { + public PetTrainingPanelComposer(Pet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { List enabled = new ArrayList<>(); Collections.sort(this.pet.getPetData().getPetCommands()); @@ -29,25 +26,21 @@ public class PetTrainingPanelComposer extends MessageComposer this.response.appendInt(this.pet.getId()); this.response.appendInt(this.pet.getPetData().getPetCommands().size()); - for(PetCommand petCommand : this.pet.getPetData().getPetCommands()) - { + for (PetCommand petCommand : this.pet.getPetData().getPetCommands()) { this.response.appendInt(petCommand.id); - if(this.pet.getLevel() >= petCommand.level) - { + if (this.pet.getLevel() >= petCommand.level) { enabled.add(petCommand); } } - if (!enabled.isEmpty()) - { + if (!enabled.isEmpty()) { Collections.sort(enabled); } this.response.appendInt(enabled.size()); - for(PetCommand petCommand : enabled) - { + for (PetCommand petCommand : enabled) { this.response.appendInt(petCommand.id); } 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 9e2265f1..d8ecdf1e 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 @@ -8,24 +8,20 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TIntObjectProcedure; -public class RoomPetComposer extends MessageComposer implements TIntObjectProcedure -{ +public class RoomPetComposer extends MessageComposer implements TIntObjectProcedure { private final TIntObjectMap pets; - public RoomPetComposer(Pet pet) - { + public RoomPetComposer(Pet pet) { this.pets = new TIntObjectHashMap<>(); this.pets.put(pet.getId(), pet); } - public RoomPetComposer(TIntObjectMap pets) - { + public RoomPetComposer(TIntObjectMap pets) { this.pets = pets; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUsersComposer); this.response.appendInt(this.pets.size()); this.pets.forEachEntry(this); @@ -33,17 +29,13 @@ public class RoomPetComposer extends MessageComposer implements TIntObjectProced } @Override - public boolean execute(int a, Pet pet) - { + public boolean execute(int a, Pet pet) { this.response.appendInt(pet.getId()); this.response.appendString(pet.getName()); this.response.appendString(""); - if(pet instanceof IPetLook) - { - this.response.appendString(((IPetLook)pet).getLook()); - } - else - { + if (pet instanceof IPetLook) { + this.response.appendString(((IPetLook) pet).getLook()); + } else { 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/RoomPetExperienceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetExperienceComposer.java index 183e5b09..dab4bf05 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetExperienceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetExperienceComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPetExperienceComposer extends MessageComposer -{ +public class RoomPetExperienceComposer extends MessageComposer { private final Pet pet; private final int amount; - public RoomPetExperienceComposer(Pet pet, int amount) - { + public RoomPetExperienceComposer(Pet pet, int amount) { this.pet = pet; this.amount = amount; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomPetExperienceComposer); this.response.appendInt(this.pet.getId()); this.response.appendInt(this.pet.getRoomUnit().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetHorseFigureComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetHorseFigureComposer.java index 56922ef6..09495a3c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetHorseFigureComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetHorseFigureComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPetHorseFigureComposer extends MessageComposer -{ +public class RoomPetHorseFigureComposer extends MessageComposer { private final HorsePet pet; - public RoomPetHorseFigureComposer(HorsePet pet) - { + public RoomPetHorseFigureComposer(HorsePet pet) { this.pet = pet; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomPetHorseFigureComposer); this.response.appendInt(this.pet.getRoomUnit().getId()); this.response.appendInt(this.pet.getId()); @@ -24,8 +21,7 @@ public class RoomPetHorseFigureComposer extends MessageComposer this.response.appendInt(this.pet.getRace()); this.response.appendString(this.pet.getColor().toLowerCase()); - if(this.pet.hasSaddle()) - { + if (this.pet.hasSaddle()) { this.response.appendInt(2); this.response.appendInt(3); this.response.appendInt(4); @@ -38,9 +34,7 @@ public class RoomPetHorseFigureComposer extends MessageComposer this.response.appendInt(3); //Saddle type? this.response.appendInt(this.pet.getHairStyle()); this.response.appendInt(this.pet.getHairColor()); - } - else - { + } else { this.response.appendInt(1); this.response.appendInt(2); this.response.appendInt(2); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetRespectComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetRespectComposer.java index 3c81e1eb..0ef38a0c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetRespectComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetRespectComposer.java @@ -5,29 +5,25 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPetRespectComposer extends MessageComposer -{ +public class RoomPetRespectComposer extends MessageComposer { public final static int PET_RESPECTED = 1; public final static int PET_TREATED = 2; private final Pet pet; private final int type; - public RoomPetRespectComposer(Pet pet) - { + public RoomPetRespectComposer(Pet pet) { this.pet = pet; this.type = 1; } - public RoomPetRespectComposer(Pet pet, int type) - { + public RoomPetRespectComposer(Pet pet, int type) { this.pet = pet; this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomPetRespectComposer); this.response.appendInt(this.type); this.response.appendInt(100); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingCompleted.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingCompleted.java index 3ab0635a..8dece8c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingCompleted.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingCompleted.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetBreedingCompleted extends MessageComposer -{ +public class PetBreedingCompleted extends MessageComposer { private final int type; private final int race; - public PetBreedingCompleted(int type, int race) - { + public PetBreedingCompleted(int type, int race) { this.type = type; this.race = race; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBreedingCompleted); this.response.appendInt(this.type); this.response.appendInt(this.race); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingFailedComposer.java index d8b3afbd..556b1f8c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingFailedComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetBreedingFailedComposer extends MessageComposer -{ +public class PetBreedingFailedComposer extends MessageComposer { private final int anInt1; private final int anInt2; - public PetBreedingFailedComposer(int anInt1, int anInt2) - { + public PetBreedingFailedComposer(int anInt1, int anInt2) { this.anInt1 = anInt1; this.anInt2 = anInt2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBreedingFailedComposer); this.response.appendInt(this.anInt1); this.response.appendInt(this.anInt2); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingResultComposer.java index b38e8720..42145b6a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingResultComposer.java @@ -13,15 +13,13 @@ import org.apache.commons.math3.distribution.NormalDistribution; import java.util.ArrayList; -public class PetBreedingResultComposer extends MessageComposer -{ +public class PetBreedingResultComposer extends MessageComposer { private final int boxId; private final int petType; private final PetBreedingPet petOne; private final PetBreedingPet petTwo; - public PetBreedingResultComposer(int boxId, int petType, Pet petOne, String ownerPetOne, Pet petTwo, String ownerPetTwo) - { + public PetBreedingResultComposer(int boxId, int petType, Pet petOne, String ownerPetOne, Pet petTwo, String ownerPetTwo) { this.boxId = boxId; this.petType = petType; this.petOne = new PetBreedingPet(petOne, ownerPetOne); @@ -29,44 +27,36 @@ public class PetBreedingResultComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBreedingResultComposer); this.response.appendInt(this.boxId); this.petOne.serialize(this.response); this.petTwo.serialize(this.response); - double avgLevel = ((float)this.petOne.pet.getLevel() + this.petTwo.pet.getLevel()) / 2; + double avgLevel = ((float) this.petOne.pet.getLevel() + this.petTwo.pet.getLevel()) / 2; NormalDistribution normalDistribution = PetManager.getNormalDistributionForBreeding(avgLevel); - - - TIntObjectHashMap> rewardBreeds = Emulator.getGameEnvironment().getPetManager().getBreedingRewards(this.petType); this.response.appendInt(4); //Levels { - int percentage1 = (int)(normalDistribution.cumulativeProbability(10) * 100); - int percentage2 = (int)(normalDistribution.cumulativeProbability(15) * 100) - percentage1; - int percentage3 = (int)(normalDistribution.cumulativeProbability(18) * 100) - percentage1 - percentage2; - int percentage4 = (int)(normalDistribution.cumulativeProbability(20) * 100) - percentage1 - percentage2 - percentage3; + int percentage1 = (int) (normalDistribution.cumulativeProbability(10) * 100); + int percentage2 = (int) (normalDistribution.cumulativeProbability(15) * 100) - percentage1; + int percentage3 = (int) (normalDistribution.cumulativeProbability(18) * 100) - percentage1 - percentage2; + int percentage4 = (int) (normalDistribution.cumulativeProbability(20) * 100) - percentage1 - percentage2 - percentage3; int dPercentage = 100 - (percentage1 + percentage2 + percentage3 + percentage4); - if (dPercentage > 0) - { + if (dPercentage > 0) { percentage1 += dPercentage; - } - else - { + } else { percentage4 -= dPercentage; } this.response.appendInt(percentage4); //Percentage this.response.appendInt(rewardBreeds.get(4).size()); //Count { - for (PetBreedingReward reward : rewardBreeds.get(4)) - { + for (PetBreedingReward reward : rewardBreeds.get(4)) { this.response.appendInt(reward.breed); } } @@ -74,8 +64,7 @@ public class PetBreedingResultComposer extends MessageComposer this.response.appendInt(percentage3); //Percentage this.response.appendInt(rewardBreeds.get(3).size()); //Count { - for (PetBreedingReward reward : rewardBreeds.get(3)) - { + for (PetBreedingReward reward : rewardBreeds.get(3)) { this.response.appendInt(reward.breed); } } @@ -83,8 +72,7 @@ public class PetBreedingResultComposer extends MessageComposer this.response.appendInt(percentage2); //Percentage this.response.appendInt(rewardBreeds.get(2).size()); //Count { - for (PetBreedingReward reward : rewardBreeds.get(2)) - { + for (PetBreedingReward reward : rewardBreeds.get(2)) { this.response.appendInt(reward.breed); } } @@ -92,8 +80,7 @@ public class PetBreedingResultComposer extends MessageComposer this.response.appendInt(percentage1); //Percentage this.response.appendInt(rewardBreeds.get(1).size()); //Count { - for (PetBreedingReward reward : rewardBreeds.get(1)) - { + for (PetBreedingReward reward : rewardBreeds.get(1)) { this.response.appendInt(reward.breed); } } @@ -104,20 +91,17 @@ public class PetBreedingResultComposer extends MessageComposer return this.response; } - public class PetBreedingPet implements ISerialize - { + public class PetBreedingPet implements ISerialize { public final Pet pet; public final String ownerName; - public PetBreedingPet(Pet pet, String ownerName) - { + public PetBreedingPet(Pet pet, String ownerName) { this.pet = pet; this.ownerName = ownerName; } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendInt(this.pet.getId()); message.appendString(this.pet.getName()); message.appendInt(this.pet.getLevel()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartComposer.java index 639c946b..da164f26 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartComposer.java @@ -4,23 +4,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetBreedingStartComposer extends MessageComposer -{ +public class PetBreedingStartComposer extends MessageComposer { private final int state; private final int anInt1; private final int anInt2; - public PetBreedingStartComposer(int state, int anInt1, int anInt2) - { + public PetBreedingStartComposer(int state, int anInt1, int anInt2) { this.state = state; this.anInt1 = anInt1; this.anInt2 = anInt2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBreedingStartComposer); this.response.appendInt(this.state); this.response.appendInt(this.anInt1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartFailedComposer.java index 8971edf1..2df336c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/breeding/PetBreedingStartFailedComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class PetBreedingStartFailedComposer extends MessageComposer -{ +public class PetBreedingStartFailedComposer extends MessageComposer { public final static int NO_NESTS = 0; public final static int NO_SUITABLE_NESTS = 1; public final static int NEST_FULL = 2; @@ -16,14 +15,12 @@ public class PetBreedingStartFailedComposer extends MessageComposer private final int reason; - public PetBreedingStartFailedComposer(int reason) - { + public PetBreedingStartFailedComposer(int reason) { this.reason = reason; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PetBreedingStartFailedComposer); this.response.appendInt(this.reason); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/PromoteOwnRoomsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/PromoteOwnRoomsListComposer.java index df39da5d..45e42070 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/PromoteOwnRoomsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/PromoteOwnRoomsListComposer.java @@ -8,27 +8,22 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; import java.util.List; -public class PromoteOwnRoomsListComposer extends MessageComposer -{ +public class PromoteOwnRoomsListComposer extends MessageComposer { private final List rooms = new ArrayList<>(); - public PromoteOwnRoomsListComposer(List rooms) - { - for(Room room : rooms) - { - if(!room.isPromoted()) + public PromoteOwnRoomsListComposer(List rooms) { + for (Room room : rooms) { + if (!room.isPromoted()) this.rooms.add(room); } } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.PromoteOwnRoomsListComposer); this.response.appendBoolean(true); this.response.appendInt(this.rooms.size()); - for(Room room : this.rooms) - { + for (Room room : this.rooms) { this.response.appendInt(room.getId()); this.response.appendString(room.getName()); this.response.appendBoolean(true); //IDK what the fuck this is. diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java index 86dd3ef9..e82a8055 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java @@ -6,25 +6,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomPromotionMessageComposer extends MessageComposer -{ +public class RoomPromotionMessageComposer extends MessageComposer { private final Room room; private final RoomPromotion roomPromotion; - public RoomPromotionMessageComposer(Room room, RoomPromotion roomPromotion) - { + public RoomPromotionMessageComposer(Room room, RoomPromotion roomPromotion) { this.room = room; this.roomPromotion = roomPromotion; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomEventMessageComposer); - if (this.room == null || this.roomPromotion == null) - { + if (this.room == null || this.roomPromotion == null) { this.response.appendInt(-1); @@ -43,9 +39,7 @@ public class RoomPromotionMessageComposer extends MessageComposer this.response.appendInt(0); this.response.appendInt(0); - } - else - { + } else { this.response.appendInt(this.room.getId()); this.response.appendInt(this.room.getOwnerId()); this.response.appendString(this.room.getOwnerName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeNameUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeNameUpdatedComposer.java index a0486141..7713461f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeNameUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChangeNameUpdatedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ChangeNameUpdatedComposer extends MessageComposer -{ +public class ChangeNameUpdatedComposer extends MessageComposer { private final Habbo habbo; - public ChangeNameUpdatedComposer(Habbo habbo) - { + public ChangeNameUpdatedComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ChangeNameUpdateComposer); this.response.appendInt(0); this.response.appendString(this.habbo.getHabboInfo().getUsername()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitIdleComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitIdleComposer.java index aa703e08..3c947c5b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitIdleComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitIdleComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUnitIdleComposer extends MessageComposer -{ +public class RoomUnitIdleComposer extends MessageComposer { private final RoomUnit roomUnit; - public RoomUnitIdleComposer(RoomUnit roomUnit) - { + public RoomUnitIdleComposer(RoomUnit roomUnit) { this.roomUnit = roomUnit; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUnitIdleComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendBoolean(this.roomUnit.isIdle()); 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 7834d56d..8537ac4a 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,8 +9,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUnitOnRollerComposer extends MessageComposer -{ +public class RoomUnitOnRollerComposer extends MessageComposer { private final RoomUnit roomUnit; private final HabboItem roller; private final RoomTile oldLocation; @@ -19,8 +18,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer private final double newZ; private final Room room; - public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) - { + public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) { this.roomUnit = roomUnit; this.roller = roller; this.oldLocation = oldLocation; @@ -30,8 +28,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer this.room = room; } - public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) - { + public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) { this.roomUnit = roomUnit; this.roller = null; this.oldLocation = this.roomUnit.getCurrentLocation(); @@ -42,9 +39,8 @@ public class RoomUnitOnRollerComposer extends MessageComposer } @Override - public ServerMessage compose() - { - if(!this.room.isLoaded()) + public ServerMessage compose() { + if (!this.room.isLoaded()) return null; this.response.init(Outgoing.ObjectOnRollerComposer); @@ -59,8 +55,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer this.response.appendString(this.oldZ + ""); this.response.appendString(this.newZ + ""); - if (this.roller != null) - { + if (this.roller != null) { RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY()); Emulator.getThreading().run(() -> { @@ -71,9 +66,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true; } }, this.room.getRollerSpeed() == 0 ? 250 : 500); - } - else - { + } else { this.roomUnit.setLocation(this.newLocation); this.roomUnit.setZ(this.newZ); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java index f50d8c71..c3cde9be 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUnitUpdateUsernameComposer extends MessageComposer -{ +public class RoomUnitUpdateUsernameComposer extends MessageComposer { private RoomUnit roomUnit; private String name; - public RoomUnitUpdateUsernameComposer(RoomUnit roomUnit, String name) - { + public RoomUnitUpdateUsernameComposer(RoomUnit roomUnit, String name) { this.roomUnit = roomUnit; this.name = name; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUnitUpdateUsernameComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.roomUnit.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserActionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserActionComposer.java index df1007ad..88acc03d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserActionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserActionComposer.java @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserActionComposer extends MessageComposer -{ +public class RoomUserActionComposer extends MessageComposer { private RoomUserAction action; private RoomUnit roomUnit; - public RoomUserActionComposer(RoomUnit roomUnit, RoomUserAction action) - { + public RoomUserActionComposer(RoomUnit roomUnit, RoomUserAction action) { this.roomUnit = roomUnit; this.action = action; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserActionComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.action.getAction()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDanceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDanceComposer.java index fdc9ee61..1487658c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDanceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDanceComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserDanceComposer extends MessageComposer -{ +public class RoomUserDanceComposer extends MessageComposer { private final RoomUnit roomUnit; - public RoomUserDanceComposer(RoomUnit roomUnit) - { + public RoomUserDanceComposer(RoomUnit roomUnit) { this.roomUnit = roomUnit; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserDanceComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.roomUnit.getDanceType().getType()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDataComposer.java index 00e67c93..87b3c2f2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDataComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserDataComposer extends MessageComposer -{ +public class RoomUserDataComposer extends MessageComposer { private final Habbo habbo; - public RoomUserDataComposer(Habbo habbo) - { + public RoomUserDataComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserDataComposer); this.response.appendInt(this.habbo.getRoomUnit() == null ? -1 : this.habbo.getRoomUnit().getId()); this.response.appendString(this.habbo.getHabboInfo().getLook()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserEffectComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserEffectComposer.java index d78a98e6..fc0a5641 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserEffectComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserEffectComposer.java @@ -5,25 +5,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserEffectComposer extends MessageComposer -{ +public class RoomUserEffectComposer extends MessageComposer { private final RoomUnit roomUnit; private final int effectId; - public RoomUserEffectComposer(RoomUnit roomUnit) - { + public RoomUserEffectComposer(RoomUnit roomUnit) { this.roomUnit = roomUnit; this.effectId = -1; } - public RoomUserEffectComposer(RoomUnit roomUnit, int effectId) - { + + public RoomUserEffectComposer(RoomUnit roomUnit, int effectId) { this.roomUnit = roomUnit; this.effectId = effectId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserEffectComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.effectId == -1 ? this.roomUnit.getEffectId() : this.effectId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserHandItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserHandItemComposer.java index 92cd7f98..4a953730 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserHandItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserHandItemComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserHandItemComposer extends MessageComposer -{ +public class RoomUserHandItemComposer extends MessageComposer { private final RoomUnit roomUnit; - public RoomUserHandItemComposer(RoomUnit roomUnit) - { + public RoomUserHandItemComposer(RoomUnit roomUnit) { this.roomUnit = roomUnit; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserHandItemComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.roomUnit.getHandItem()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserIgnoredComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserIgnoredComposer.java index e07e0fac..e88a953b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserIgnoredComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserIgnoredComposer.java @@ -5,8 +5,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserIgnoredComposer extends MessageComposer -{ +public class RoomUserIgnoredComposer extends MessageComposer { public final static int IGNORED = 1; public final static int MUTED = 2; public final static int UNIGNORED = 3; @@ -14,15 +13,13 @@ public class RoomUserIgnoredComposer extends MessageComposer private final Habbo habbo; private final int state; - public RoomUserIgnoredComposer(Habbo habbo, int state) - { + public RoomUserIgnoredComposer(Habbo habbo, int state) { this.habbo = habbo; this.state = state; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserIgnoredComposer); this.response.appendInt(this.state); this.response.appendString(this.habbo.getHabboInfo().getUsername()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java index 4efe96f6..53c8b5b9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java @@ -6,26 +6,22 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserNameChangedComposer extends MessageComposer -{ +public class RoomUserNameChangedComposer extends MessageComposer { private final Habbo habbo; private final boolean includePrefix; - public RoomUserNameChangedComposer(Habbo habbo) - { + public RoomUserNameChangedComposer(Habbo habbo) { this.habbo = habbo; this.includePrefix = false; } - public RoomUserNameChangedComposer(Habbo habbo, boolean includePrefix) - { + public RoomUserNameChangedComposer(Habbo habbo, boolean includePrefix) { this.habbo = habbo; this.includePrefix = includePrefix; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserNameChangedComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); this.response.appendInt(this.habbo.getRoomUnit().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserReceivedHandItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserReceivedHandItemComposer.java index 9f295977..65a10440 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserReceivedHandItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserReceivedHandItemComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserReceivedHandItemComposer extends MessageComposer -{ +public class RoomUserReceivedHandItemComposer extends MessageComposer { private RoomUnit from; private int handItem; - public RoomUserReceivedHandItemComposer(RoomUnit from, int handItem) - { + public RoomUserReceivedHandItemComposer(RoomUnit from, int handItem) { this.from = from; this.handItem = handItem; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserReceivedHandItemComposer); this.response.appendInt(this.from.getId()); this.response.appendInt(this.handItem); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveComposer.java index 217ede81..d270b294 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserRemoveComposer extends MessageComposer -{ +public class RoomUserRemoveComposer extends MessageComposer { private final RoomUnit roomUnit; - public RoomUserRemoveComposer(RoomUnit roomUnit) - { + public RoomUserRemoveComposer(RoomUnit roomUnit) { this.roomUnit = roomUnit; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserRemoveComposer); this.response.appendString(this.roomUnit.getId() + ""); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveRightsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveRightsComposer.java index bfb890a3..c942df8d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveRightsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserRemoveRightsComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserRemoveRightsComposer extends MessageComposer -{ +public class RoomUserRemoveRightsComposer extends MessageComposer { private final Room room; private final int habboId; - public RoomUserRemoveRightsComposer(Room room, int habboId) - { + public RoomUserRemoveRightsComposer(Room room, int habboId) { this.room = room; this.habboId = habboId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserRemoveRightsComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(this.habboId); 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 55e93f47..850d4a50 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 @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserRespectComposer extends MessageComposer -{ +public class RoomUserRespectComposer extends MessageComposer { private final Habbo habbo; - public RoomUserRespectComposer(Habbo habbo) - { + public RoomUserRespectComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserRespectComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); this.response.appendInt(this.habbo.getHabboStats().respectPointsReceived); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserShoutComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserShoutComposer.java index 8c901dd0..b50a2cc8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserShoutComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserShoutComposer.java @@ -5,19 +5,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserShoutComposer extends MessageComposer -{ +public class RoomUserShoutComposer extends MessageComposer { private RoomChatMessage roomChatMessage; - public RoomUserShoutComposer(RoomChatMessage roomChatMessage) - { + public RoomUserShoutComposer(RoomChatMessage roomChatMessage) { this.roomChatMessage = roomChatMessage; } @Override - public ServerMessage compose() - { - if(this.roomChatMessage.getMessage().isEmpty()) + public ServerMessage compose() { + if (this.roomChatMessage.getMessage().isEmpty()) return null; this.response.init(Outgoing.RoomUserShoutComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java index 75c1779f..652511e8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java @@ -11,86 +11,62 @@ import gnu.trove.set.hash.THashSet; import java.util.Collection; import java.util.Map; -public class RoomUserStatusComposer extends MessageComposer -{ +public class RoomUserStatusComposer extends MessageComposer { private Collection habbos; private THashSet roomUnits; - public RoomUserStatusComposer(RoomUnit roomUnit) - { + public RoomUserStatusComposer(RoomUnit roomUnit) { this.roomUnits = new THashSet<>(); this.roomUnits.add(roomUnit); } - public RoomUserStatusComposer(THashSet roomUnits, boolean value) - { + public RoomUserStatusComposer(THashSet roomUnits, boolean value) { this.roomUnits = roomUnits; } - public RoomUserStatusComposer(Collection habbos) - { + public RoomUserStatusComposer(Collection habbos) { this.habbos = habbos; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserStatusComposer); - if(this.roomUnits != null) - { + if (this.roomUnits != null) { this.response.appendInt(this.roomUnits.size()); - for(RoomUnit roomUnit : this.roomUnits) - { + for (RoomUnit roomUnit : this.roomUnits) { this.response.appendInt(roomUnit.getId()); this.response.appendInt(roomUnit.getPreviousLocation().x); this.response.appendInt(roomUnit.getPreviousLocation().y); this.response.appendString(roomUnit.getPreviousLocationZ() + ""); - - - - - - this.response.appendInt(roomUnit.getHeadRotation().getValue()); this.response.appendInt(roomUnit.getBodyRotation().getValue()); StringBuilder status = new StringBuilder("/"); - for (Map.Entry entry : roomUnit.getStatusMap().entrySet()) - { + for (Map.Entry entry : roomUnit.getStatusMap().entrySet()) { status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); } this.response.appendString(status.toString()); roomUnit.setPreviousLocation(roomUnit.getCurrentLocation()); } - } - else { - synchronized (this.habbos) - { + } else { + synchronized (this.habbos) { this.response.appendInt(this.habbos.size()); - for (Habbo habbo : this.habbos) - { + 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.appendString(habbo.getRoomUnit().getPreviousLocationZ() + ""); - - - - - - this.response.appendInt(habbo.getRoomUnit().getHeadRotation().getValue()); this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); StringBuilder status = new StringBuilder("/"); - for (Map.Entry entry : habbo.getRoomUnit().getStatusMap().entrySet()) - { + for (Map.Entry entry : habbo.getRoomUnit().getStatusMap().entrySet()) { status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); } this.response.appendString(status.toString()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTagsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTagsComposer.java index 8a855928..5951c759 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTagsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTagsComposer.java @@ -5,24 +5,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserTagsComposer extends MessageComposer -{ +public class RoomUserTagsComposer extends MessageComposer { private final Habbo habbo; - public RoomUserTagsComposer(Habbo habbo) - { + public RoomUserTagsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserTagsComposer); this.response.appendInt(this.habbo.getRoomUnit().getId()); this.response.appendInt(this.habbo.getHabboStats().tags.length); - for(String tag : this.habbo.getHabboStats().tags) - { + for (String tag : this.habbo.getHabboStats().tags) { this.response.appendString(tag); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTalkComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTalkComposer.java index 2ef56dd9..a2bdce88 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTalkComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTalkComposer.java @@ -5,21 +5,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserTalkComposer extends MessageComposer -{ +public class RoomUserTalkComposer extends MessageComposer { private final RoomChatMessage roomChatMessage; - public RoomUserTalkComposer(RoomChatMessage roomChatMessage) - { + public RoomUserTalkComposer(RoomChatMessage roomChatMessage) { this.roomChatMessage = roomChatMessage; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserTalkComposer); - if(this.roomChatMessage.getMessage().isEmpty()) + if (this.roomChatMessage.getMessage().isEmpty()) return null; this.roomChatMessage.serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTypingComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTypingComposer.java index 800b07f0..f725735e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTypingComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserTypingComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserTypingComposer extends MessageComposer -{ +public class RoomUserTypingComposer extends MessageComposer { private final RoomUnit roomUnit; private final boolean typing; - public RoomUserTypingComposer(RoomUnit roomUnit, boolean typing) - { + public RoomUserTypingComposer(RoomUnit roomUnit, boolean typing) { this.roomUnit = roomUnit; this.typing = typing; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserTypingComposer); this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.typing ? 1 : 0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserUnbannedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserUnbannedComposer.java index 31bef813..8040e40d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserUnbannedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserUnbannedComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserUnbannedComposer extends MessageComposer -{ +public class RoomUserUnbannedComposer extends MessageComposer { private final Room room; private final int userId; - public RoomUserUnbannedComposer(Room room, int userId) - { + public RoomUserUnbannedComposer(Room room, int userId) { this.room = room; this.userId = userId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserUnbannedComposer); this.response.appendInt(this.room.getId()); this.response.appendInt(this.userId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserWhisperComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserWhisperComposer.java index 4585f392..f96e659e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserWhisperComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserWhisperComposer.java @@ -5,18 +5,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUserWhisperComposer extends MessageComposer -{ +public class RoomUserWhisperComposer extends MessageComposer { private final RoomChatMessage roomChatMessage; - public RoomUserWhisperComposer(RoomChatMessage roomChatMessage) - { + public RoomUserWhisperComposer(RoomChatMessage roomChatMessage) { this.roomChatMessage = roomChatMessage; } + @Override - public ServerMessage compose() - { - if(this.roomChatMessage.getMessage().isEmpty()) + public ServerMessage compose() { + if (this.roomChatMessage.getMessage().isEmpty()) return null; this.response.init(Outgoing.RoomUserWhisperComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersAddGuildBadgeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersAddGuildBadgeComposer.java index aec62e3d..4f95b2db 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersAddGuildBadgeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersAddGuildBadgeComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUsersAddGuildBadgeComposer extends MessageComposer -{ +public class RoomUsersAddGuildBadgeComposer extends MessageComposer { private final Guild guild; - public RoomUsersAddGuildBadgeComposer(Guild guild) - { + public RoomUsersAddGuildBadgeComposer(Guild guild) { this.guild = guild; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUsersGuildBadgesComposer); this.response.appendInt(1); this.response.appendInt(this.guild.getId()); 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 44276f01..3fbfba97 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 @@ -10,38 +10,32 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Collection; -public class RoomUsersComposer extends MessageComposer -{ +public class RoomUsersComposer extends MessageComposer { private Habbo habbo; private Collection habbos; private Bot bot; private Collection bots; - public RoomUsersComposer(Habbo habbo) - { + public RoomUsersComposer(Habbo habbo) { this.habbo = habbo; } - public RoomUsersComposer(Collection habbos) - { + public RoomUsersComposer(Collection habbos) { this.habbos = habbos; } - public RoomUsersComposer(Bot bot) - { + public RoomUsersComposer(Bot bot) { this.bot = bot; } - public RoomUsersComposer(Collection bots, boolean isBot) - { + public RoomUsersComposer(Collection bots, boolean isBot) { this.bots = bots; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUsersComposer); - if(this.habbo != null) { + if (this.habbo != null) { this.response.appendInt(1); this.response.appendInt(this.habbo.getHabboInfo().getId()); this.response.appendString(this.habbo.getHabboInfo().getUsername()); @@ -58,11 +52,10 @@ public class RoomUsersComposer extends MessageComposer this.response.appendInt(this.habbo.getHabboStats().guild != 0 ? 1 : -1); String name = ""; - if(this.habbo.getHabboStats().guild != 0) - { + if (this.habbo.getHabboStats().guild != 0) { Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.habbo.getHabboStats().guild); - if(g != null) + if (g != null) name = g.getName(); } this.response.appendString(name); @@ -70,14 +63,10 @@ public class RoomUsersComposer extends MessageComposer this.response.appendString(""); this.response.appendInt(this.habbo.getHabboStats().getAchievementScore()); this.response.appendBoolean(true); - } - else if(this.habbos != null) - { + } else if (this.habbos != null) { this.response.appendInt(this.habbos.size()); - for (Habbo habbo : this.habbos) - { - if (habbo != null) - { + for (Habbo habbo : this.habbos) { + if (habbo != null) { this.response.appendInt(habbo.getHabboInfo().getId()); this.response.appendString(habbo.getHabboInfo().getUsername()); this.response.appendString(habbo.getHabboInfo().getMotto()); @@ -92,8 +81,7 @@ public class RoomUsersComposer extends MessageComposer this.response.appendInt(habbo.getHabboStats().guild != 0 ? habbo.getHabboStats().guild : -1); this.response.appendInt(habbo.getHabboStats().guild != 0 ? habbo.getHabboStats().guild : -1); String name = ""; - if (habbo.getHabboStats().guild != 0) - { + if (habbo.getHabboStats().guild != 0) { Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().guild); if (g != null) @@ -105,9 +93,7 @@ public class RoomUsersComposer extends MessageComposer this.response.appendBoolean(true); } } - } - else if(this.bot != null) - { + } else if (this.bot != null) { this.response.appendInt(1); this.response.appendInt(0 - this.bot.getId()); this.response.appendString(this.bot.getName()); @@ -133,12 +119,9 @@ public class RoomUsersComposer extends MessageComposer this.response.appendShort(7); this.response.appendShort(8); this.response.appendShort(9); - } - else if(this.bots != null) - { + } else if (this.bots != null) { this.response.appendInt(this.bots.size()); - for(Bot bot : this.bots) - { + for (Bot bot : this.bots) { this.response.appendInt(0 - bot.getId()); this.response.appendString(bot.getName()); this.response.appendString(bot.getMotto()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersGuildBadgesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersGuildBadgesComposer.java index e743864a..b8e2e46f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersGuildBadgesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersGuildBadgesComposer.java @@ -6,26 +6,21 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectObjectProcedure; -public class RoomUsersGuildBadgesComposer extends MessageComposer -{ +public class RoomUsersGuildBadgesComposer extends MessageComposer { private final THashMap guildBadges; - public RoomUsersGuildBadgesComposer(THashMap guildBadges) - { + public RoomUsersGuildBadgesComposer(THashMap guildBadges) { this.guildBadges = guildBadges; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUsersGuildBadgesComposer); this.response.appendInt(this.guildBadges.size()); - this.guildBadges.forEachEntry(new TObjectObjectProcedure() - { + this.guildBadges.forEachEntry(new TObjectObjectProcedure() { @Override - public boolean execute(Integer guildId, String badge) - { + public boolean execute(Integer guildId, String badge) { RoomUsersGuildBadgesComposer.this.response.appendInt(guildId); RoomUsersGuildBadgesComposer.this.response.appendString(badge); return true; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/OtherTradingDisabledComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/OtherTradingDisabledComposer.java index 508fc4b8..956edcde 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/OtherTradingDisabledComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/OtherTradingDisabledComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class OtherTradingDisabledComposer extends MessageComposer -{ +public class OtherTradingDisabledComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.OtherTradingDisabledComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeAcceptedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeAcceptedComposer.java index d95fc779..c453cc16 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeAcceptedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeAcceptedComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeAcceptedComposer extends MessageComposer -{ +public class TradeAcceptedComposer extends MessageComposer { private final RoomTradeUser tradeUser; - public TradeAcceptedComposer(RoomTradeUser tradeUser) - { + public TradeAcceptedComposer(RoomTradeUser tradeUser) { this.tradeUser = tradeUser; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeAcceptedComposer); this.response.appendInt(this.tradeUser.getUserId()); this.response.appendInt(this.tradeUser.getAccepted()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCloseWindowComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCloseWindowComposer.java index f527f110..6f0b87fe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCloseWindowComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCloseWindowComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeCloseWindowComposer extends MessageComposer -{ +public class TradeCloseWindowComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeCloseWindowComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeClosedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeClosedComposer.java index baf133b0..fb729e50 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeClosedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeClosedComposer.java @@ -4,23 +4,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeClosedComposer extends MessageComposer -{ +public class TradeClosedComposer extends MessageComposer { public static final int USER_CANCEL_TRADE = 0; public static final int ITEMS_NOT_FOUND = 1; private final int userId; private final int errorCode; - public TradeClosedComposer(int userId, int errorCode) - { + public TradeClosedComposer(int userId, int errorCode) { this.userId = userId; this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeStoppedComposer); this.response.appendInt(this.userId); this.response.appendInt(this.errorCode); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCompleteComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCompleteComposer.java index 442dcf90..c59cf2e9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCompleteComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeCompleteComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeCompleteComposer extends MessageComposer -{ +public class TradeCompleteComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownTradeComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartComposer.java index 9a92f0bf..3329122c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartComposer.java @@ -6,28 +6,24 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeStartComposer extends MessageComposer -{ +public class TradeStartComposer extends MessageComposer { private final RoomTrade roomTrade; private final int state; - public TradeStartComposer(RoomTrade roomTrade) - { + public TradeStartComposer(RoomTrade roomTrade) { this.roomTrade = roomTrade; this.state = 1; } - public TradeStartComposer(RoomTrade roomTrade, int state) - { + public TradeStartComposer(RoomTrade roomTrade, int state) { this.roomTrade = roomTrade; this.state = state; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeStartComposer); - for(RoomTradeUser tradeUser : this.roomTrade.getRoomTradeUsers()) - { + for (RoomTradeUser tradeUser : this.roomTrade.getRoomTradeUsers()) { this.response.appendInt(tradeUser.getHabbo().getHabboInfo().getId()); this.response.appendInt(this.state); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartFailComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartFailComposer.java index ac9126e3..663f925b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartFailComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeStartFailComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeStartFailComposer extends MessageComposer -{ +public class TradeStartFailComposer extends MessageComposer { public static final int HOTEL_TRADING_NOT_ALLOWED = 1; public static final int YOU_TRADING_OFF = 2; public static final int TARGET_TRADING_NOT_ALLOWED = 4; @@ -16,20 +15,17 @@ public class TradeStartFailComposer extends MessageComposer private final String username; private final int code; - public TradeStartFailComposer(int code) - { + public TradeStartFailComposer(int code) { this.code = code; this.username = ""; } - public TradeStartFailComposer(int code, String username) - { + public TradeStartFailComposer(int code, String username) { this.code = code; this.username = username; } - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeStartFailComposer); this.response.appendInt(this.code); this.response.appendString(this.username); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java index dab49822..07e0556f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java @@ -8,26 +8,21 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradeUpdateComposer extends MessageComposer -{ +public class TradeUpdateComposer extends MessageComposer { private final RoomTrade roomTrade; - public TradeUpdateComposer(RoomTrade roomTrade) - { + public TradeUpdateComposer(RoomTrade roomTrade) { this.roomTrade = roomTrade; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradeUpdateComposer); - for(RoomTradeUser roomTradeUser : this.roomTrade.getRoomTradeUsers()) - { + for (RoomTradeUser roomTradeUser : this.roomTrade.getRoomTradeUsers()) { this.response.appendInt(roomTradeUser.getUserId()); this.response.appendInt(roomTradeUser.getItems().size()); - for(HabboItem item : roomTradeUser.getItems()) - { + for (HabboItem item : roomTradeUser.getItems()) { this.response.appendInt(item.getId()); this.response.appendString(item.getBaseItem().getType().code); this.response.appendInt(item.getId()); @@ -39,7 +34,7 @@ public class TradeUpdateComposer extends MessageComposer this.response.appendInt(0); this.response.appendInt(0); - if(item.getBaseItem().getType() == FurnitureType.FLOOR) + if (item.getBaseItem().getType() == FurnitureType.FLOOR) this.response.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingWaitingConfirmComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingWaitingConfirmComposer.java index 600da305..a165fe89 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingWaitingConfirmComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingWaitingConfirmComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TradingWaitingConfirmComposer extends MessageComposer -{ +public class TradingWaitingConfirmComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TradingWaitingConfirmComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/YouTradingDisabledComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/YouTradingDisabledComposer.java index 8892c63d..a2da47c0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/YouTradingDisabledComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/YouTradingDisabledComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class YouTradingDisabledComposer extends MessageComposer -{ +public class YouTradingDisabledComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.YouTradingDisabledComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/BuildersClubExpiredComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/BuildersClubExpiredComposer.java index 02131d90..98de05c4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/BuildersClubExpiredComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/BuildersClubExpiredComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class BuildersClubExpiredComposer extends MessageComposer -{ +public class BuildersClubExpiredComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.BuildersClubExpiredComposer); this.response.appendInt(Integer.MAX_VALUE); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CloseWebPageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CloseWebPageComposer.java index e57dcbf4..59b0f56d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/CloseWebPageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/CloseWebPageComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class CloseWebPageComposer extends MessageComposer -{ +public class CloseWebPageComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CloseWebPageComposer); //Empty body return this.response; 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 4b68df05..98231ad9 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 @@ -6,39 +6,34 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class CompetitionEntrySubmitResultComposer extends MessageComposer -{ +public class CompetitionEntrySubmitResultComposer extends MessageComposer { private final int unknownInt1; private final String unknownString1; private final int result; 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; + 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 - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.CompetitionEntrySubmitResultComposer); this.response.appendInt(this.unknownInt1); this.response.appendString(this.unknownString1); this.response.appendInt(this.result); this.response.appendInt(this.unknownStringList1.size()); - for (String s : this.unknownStringList1) - { + for (String s : this.unknownStringList1) { this.response.appendString(s); } this.response.appendInt(this.unknownStringList2.size()); - for (String s : this.unknownStringList2) - { + for (String s : this.unknownStringList2) { this.response.appendString(s); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedForwardToRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedForwardToRoomComposer.java index 919b47a9..fd54fe97 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedForwardToRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ConvertedForwardToRoomComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ConvertedForwardToRoomComposer extends MessageComposer -{ +public class ConvertedForwardToRoomComposer extends MessageComposer { private final String unknownString1; private final int unknownInt1; - public ConvertedForwardToRoomComposer(String unknownString1, int unknownInt1) - { + public ConvertedForwardToRoomComposer(String unknownString1, int unknownInt1) { this.unknownString1 = unknownString1; this.unknownInt1 = unknownInt1; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ConvertedForwardToRoomComposer); this.response.appendString(this.unknownString1); this.response.appendInt(this.unknownInt1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupFrameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupFrameComposer.java index 3d3898ec..ea1b85e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupFrameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/EpicPopupFrameComposer.java @@ -4,19 +4,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class EpicPopupFrameComposer extends MessageComposer -{ +public class EpicPopupFrameComposer extends MessageComposer { public static final String LIBRARY_URL = "${image.library.url}"; private final String assetURI; - public EpicPopupFrameComposer(String assetURI) - { + public EpicPopupFrameComposer(String assetURI) { this.assetURI = assetURI; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.EpicPopupFrameComposer); this.response.appendString(this.assetURI); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ErrorLoginComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ErrorLoginComposer.java index 9f842721..e43e3508 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ErrorLoginComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ErrorLoginComposer.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; -public class ErrorLoginComposer extends MessageComposer -{ +public class ErrorLoginComposer extends MessageComposer { private final int errorCode; - public ErrorLoginComposer(int errorCode) - { + public ErrorLoginComposer(int errorCode) { this.errorCode = errorCode; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ErrorLoginComposer); this.response.appendInt(this.errorCode); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendClubMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendClubMessageComposer.java index f5eee455..3e3a2bc2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendClubMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ExtendClubMessageComposer.java @@ -9,8 +9,7 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Calendar; -public class ExtendClubMessageComposer extends MessageComposer -{ +public class ExtendClubMessageComposer extends MessageComposer { private final Habbo habbo; private final CatalogItem item; private final int unknownInt1; @@ -18,8 +17,7 @@ public class ExtendClubMessageComposer extends MessageComposer private final int unknownInt3; private final int unknownInt4; - public ExtendClubMessageComposer(Habbo habbo, CatalogItem item, int unknownInt1, int unknownInt2, int unknownInt3, int unknownInt4) - { + public ExtendClubMessageComposer(Habbo habbo, CatalogItem item, int unknownInt1, int unknownInt2, int unknownInt3, int unknownInt4) { this.habbo = habbo; this.item = item; this.unknownInt1 = unknownInt1; @@ -29,8 +27,7 @@ public class ExtendClubMessageComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ExtendClubMessageComposer); this.response.appendInt(this.item.getId()); this.response.appendString(this.item.getName()); @@ -44,28 +41,23 @@ public class ExtendClubMessageComposer extends MessageComposer long seconds = 0; - if(data[3].toLowerCase().startsWith("day")) - { + if (data[3].toLowerCase().startsWith("day")) { seconds = 86400 * Integer.valueOf(data[2]); - } - else if(data[3].toLowerCase().startsWith("month")) - { + } else if (data[3].toLowerCase().startsWith("month")) { seconds = 86400 * 31 * Integer.valueOf(data[2]); - } - else if(data[3].toLowerCase().startsWith("year")) - { + } else if (data[3].toLowerCase().startsWith("year")) { seconds = 86400 * 31 * 12 * Integer.valueOf(data[2]); } long secondsTotal = seconds; - int totalYears = (int)Math.floor((int)seconds / 86400 * 31 * 12); + int totalYears = (int) Math.floor((int) seconds / 86400 * 31 * 12); seconds -= totalYears * 86400 * 31 * 12; - int totalMonths = (int)Math.floor((int)seconds / 86400 * 31); + int totalMonths = (int) Math.floor((int) seconds / 86400 * 31); seconds -= totalMonths * 86400 * 31; - int totalDays = (int)Math.floor((int)seconds / 86400); + int totalDays = (int) Math.floor((int) seconds / 86400); seconds -= totalDays * 86400; this.response.appendInt((int) secondsTotal / 86400 / 31); @@ -75,8 +67,7 @@ public class ExtendClubMessageComposer extends MessageComposer int endTimestamp = this.habbo.getHabboStats().getClubExpireTimestamp(); - if (endTimestamp < Emulator.getIntUnixTimestamp()) - { + if (endTimestamp < Emulator.getIntUnixTimestamp()) { endTimestamp = Emulator.getIntUnixTimestamp(); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboMallComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboMallComposer.java index 063ab5b5..58c3475f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboMallComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/HabboMallComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class HabboMallComposer extends MessageComposer -{ +public class HabboMallComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.HabboMallComposer); //Empty body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/IgnoredUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/IgnoredUsersComposer.java index b3edba09..e9c92582 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/IgnoredUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/IgnoredUsersComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class IgnoredUsersComposer extends MessageComposer -{ +public class IgnoredUsersComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.IgnoredUsersComposer); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MessengerErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MessengerErrorComposer.java index b59c123c..03a4b53b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MessengerErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MessengerErrorComposer.java @@ -6,22 +6,18 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class MessengerErrorComposer extends MessageComposer -{ +public class MessengerErrorComposer extends MessageComposer { private final Map errors; - public MessengerErrorComposer(Map errors) - { + public MessengerErrorComposer(Map errors) { this.errors = errors; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MessengerErrorComposer); this.response.appendInt(this.errors.size()); - for (Map.Entry entry : this.errors.entrySet()) - { + for (Map.Entry entry : this.errors.entrySet()) { this.response.appendInt(entry.getKey()); this.response.appendInt(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MinimailNewMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MinimailNewMessageComposer.java index b22018fb..65fd048c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MinimailNewMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MinimailNewMessageComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MinimailNewMessageComposer extends MessageComposer -{ +public class MinimailNewMessageComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MinimailNewMessageComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolComposerOne.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolComposerOne.java index 3e142858..28794f60 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolComposerOne.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolComposerOne.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolComposerOne extends MessageComposer -{ +public class ModToolComposerOne extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolComposerOne); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolSanctionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolSanctionDataComposer.java index ae4a54b9..819ee421 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolSanctionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/ModToolSanctionDataComposer.java @@ -5,22 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class ModToolSanctionDataComposer extends MessageComposer -{ +public class ModToolSanctionDataComposer extends MessageComposer { private final int unknownInt1; private final int accountId; private final CFHSanction sanction; - public ModToolSanctionDataComposer(int unknownInt1, int accountId, CFHSanction sanction) - { + public ModToolSanctionDataComposer(int unknownInt1, int accountId, CFHSanction sanction) { this.unknownInt1 = unknownInt1; this.accountId = accountId; this.sanction = sanction; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ModToolSanctionDataComposer); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.accountId); @@ -28,8 +25,7 @@ public class ModToolSanctionDataComposer extends MessageComposer return this.response; } - public static class CFHSanction implements ISerialize - { + public static class CFHSanction implements ISerialize { private final String name; private final int length; private final int unknownInt1; @@ -37,8 +33,7 @@ public class ModToolSanctionDataComposer extends MessageComposer private final String tradelockInfo; private final String machineBanInfo; - public CFHSanction(String name, int length, int unknownInt1, boolean avatarOnly, String tradelockInfo, 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; @@ -48,8 +43,7 @@ public class ModToolSanctionDataComposer extends MessageComposer } @Override - public void serialize(ServerMessage message) - { + public void serialize(ServerMessage message) { message.appendString(this.name); message.appendInt(this.length); message.appendInt(this.unknownInt1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MostUselessErrorAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MostUselessErrorAlertComposer.java index b93a0d30..e58e1e54 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MostUselessErrorAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MostUselessErrorAlertComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MostUselessErrorAlertComposer extends MessageComposer -{ +public class MostUselessErrorAlertComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MostUselessErrorAlertComposer); //EMpty Body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MysteryPrizeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MysteryPrizeComposer.java index 05bd71d9..61f96b3b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/MysteryPrizeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/MysteryPrizeComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class MysteryPrizeComposer extends MessageComposer -{ +public class MysteryPrizeComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(427); this.response.appendString("s"); this.response.appendInt(230); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RemoveRoomEventComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RemoveRoomEventComposer.java index 7409066c..543e14bb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RemoveRoomEventComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RemoveRoomEventComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RemoveRoomEventComposer extends MessageComposer -{ +public class RemoveRoomEventComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RemoveRoomEventComposer); //Empty Body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RentableItemBuyOutPriceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RentableItemBuyOutPriceComposer.java index 8c3fdf9f..4c1b46e8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RentableItemBuyOutPriceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RentableItemBuyOutPriceComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RentableItemBuyOutPriceComposer extends MessageComposer -{ +public class RentableItemBuyOutPriceComposer extends MessageComposer { private final boolean unknownBoolean1; private final String unknownString1; private final boolean unknownBoolean2; @@ -13,8 +12,7 @@ public class RentableItemBuyOutPriceComposer extends MessageComposer private final int points; private final int pointsType; - public RentableItemBuyOutPriceComposer(boolean unknownBoolean1, String unknownString1, boolean unknownBoolean2, int credits, int points, int pointsType) - { + public RentableItemBuyOutPriceComposer(boolean unknownBoolean1, String unknownString1, boolean unknownBoolean2, int credits, int points, int pointsType) { this.unknownBoolean1 = unknownBoolean1; this.unknownString1 = unknownString1; this.unknownBoolean2 = unknownBoolean2; @@ -24,8 +22,7 @@ public class RentableItemBuyOutPriceComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RentableItemBuyOutPriceComposer); this.response.appendBoolean(this.unknownBoolean1); this.response.appendString(this.unknownString1); 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 b56bbe22..dcdb3d4c 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 @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomAdErrorComposer extends MessageComposer -{ +public class RoomAdErrorComposer extends MessageComposer { private final int errorCode; private final String unknownString; - public RoomAdErrorComposer(int errorCode, String unknownString) - { + public RoomAdErrorComposer(int errorCode, String unknownString) { this.errorCode = errorCode; this.unknownString = unknownString; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomAdErrorComposer); this.response.appendInt(this.errorCode); this.response.appendString(this.unknownString); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomCategoryUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomCategoryUpdateMessageComposer.java index b905fe37..5355b89d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomCategoryUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomCategoryUpdateMessageComposer.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; -public class RoomCategoryUpdateMessageComposer extends MessageComposer -{ +public class RoomCategoryUpdateMessageComposer extends MessageComposer { private final int unknownInt1; - public RoomCategoryUpdateMessageComposer(int unknownInt1) - { + public RoomCategoryUpdateMessageComposer(int unknownInt1) { this.unknownInt1 = unknownInt1; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomCategoryUpdateMessageComposer); this.response.appendInt(this.unknownInt1); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessagesPostedCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessagesPostedCountComposer.java index 241867c1..20870863 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessagesPostedCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessagesPostedCountComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomMessagesPostedCountComposer extends MessageComposer -{ +public class RoomMessagesPostedCountComposer extends MessageComposer { private final Room room; private final int count; - public RoomMessagesPostedCountComposer(Room room, int count) - { + public RoomMessagesPostedCountComposer(Room room, int count) { this.room = room; this.count = count; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomMessagesPostedCountComposer); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUnknown3Composer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUnknown3Composer.java index 91c4f8b4..f4720d4b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUnknown3Composer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomUnknown3Composer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class RoomUnknown3Composer extends MessageComposer -{ +public class RoomUnknown3Composer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUnknown3Composer); //Empty body return this.response; 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 4889a0c9..73124907 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 @@ -6,28 +6,24 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class RoomUserQuestionAnsweredComposer extends MessageComposer -{ +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) - { + public RoomUserQuestionAnsweredComposer(int userId, String value, Map unknownMap) { this.userId = userId; this.value = value; this.unknownMap = unknownMap; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.RoomUserQuestionAnsweredComposer); this.response.appendInt(this.userId); this.response.appendString(this.value); this.response.appendInt(this.unknownMap.size()); - for (Map.Entry entry : this.unknownMap.entrySet()) - { + for (Map.Entry entry : this.unknownMap.entrySet()) { this.response.appendString(entry.getKey()); this.response.appendInt(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsAddUserComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsAddUserComposer.java index e17cebd4..2e606ddc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsAddUserComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsAddUserComposer.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsAddUserComposer extends MessageComposer -{ +public class SnowWarsAddUserComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(1880); this.response.appendInt(3); this.response.appendString("Derpface"); 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 8da108d1..c920fe29 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 @@ -3,18 +3,16 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsCompose1 extends MessageComposer -{ +public class SnowWarsCompose1 extends MessageComposer { private final int header; - public SnowWarsCompose1(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 - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(this.header); this.response.appendInt(1); this.response.appendString("SnowStorm level " + 9); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsFullGameStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsFullGameStatusComposer.java index 6cacafe9..d5736aff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsFullGameStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsFullGameStatusComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsFullGameStatusComposer extends MessageComposer -{ +public class SnowWarsFullGameStatusComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(0); this.response.appendInt(0); //Unused this.response.appendInt(0); @@ -16,22 +14,22 @@ public class SnowWarsFullGameStatusComposer extends MessageComposer //SnowWarGameObjectData this.response.appendInt(1); //Count //{ - this.response.appendInt(3); //type - this.response.appendInt(1); //id? + this.response.appendInt(3); //type + this.response.appendInt(1); //id? - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable - this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable + this.response.appendInt(1); //variable - //1: -> 11 variables. - //4: -> 8 variables. - //3: -> 7 variables. - //5: -> 19 variables. - //2: -> 9 variables. + //1: -> 11 variables. + //4: -> 8 variables. + //3: -> 7 variables. + //5: -> 19 variables. + //2: -> 9 variables. //} return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGameStartedErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGameStartedErrorComposer.java index f84f58ec..3eab79fe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGameStartedErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGameStartedErrorComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsGameStartedErrorComposer extends MessageComposer -{ +public class SnowWarsGameStartedErrorComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2860); this.response.appendInt(1); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGenericErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGenericErrorComposer.java index 2c17f4ca..b2b1f57d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGenericErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsGenericErrorComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsGenericErrorComposer extends MessageComposer -{ +public class SnowWarsGenericErrorComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3702); this.response.appendInt(1); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsInitGameArena.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsInitGameArena.java index ad1762a0..a72bafa1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsInitGameArena.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsInitGameArena.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsInitGameArena extends MessageComposer -{ +public class SnowWarsInitGameArena extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3924); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsJoinErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsJoinErrorComposer.java index cc94f2a6..7fb55df3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsJoinErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsJoinErrorComposer.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; -public class SnowWarsJoinErrorComposer extends MessageComposer -{ +public class SnowWarsJoinErrorComposer extends MessageComposer { public static final int ERROR_HAS_ACTIVE_INSTANCE = 6; public static final int ERROR_NO_FREE_GAMES_LEFT = 8; public static final int ERROR_DUPLICATE_MACHINE_ID = 2; @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(1437); this.response.appendInt(2); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLevelDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLevelDataComposer.java index 6ce5f17b..d8c5896f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLevelDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLevelDataComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsLevelDataComposer extends MessageComposer -{ +public class SnowWarsLevelDataComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3874); this.response.appendInt(0); this.response.appendInt(10); //MapID 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 489afd0d..fc7f7b6d 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 @@ -3,21 +3,19 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsLoadingArenaComposer extends MessageComposer -{ +public class SnowWarsLoadingArenaComposer extends MessageComposer { private final int count; - public SnowWarsLoadingArenaComposer(int count) - { + public SnowWarsLoadingArenaComposer(int count) { this.count = count; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3850); this.response.appendInt(this.count); //GameID? this.response.appendInt(0); //Count - //this.response.appendInt(1); //ItemID to dispose? + //this.response.appendInt(1); //ItemID to dispose? return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLongDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLongDataComposer.java index 1cec5cdb..f9b48707 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLongDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsLongDataComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsLongDataComposer extends MessageComposer -{ +public class SnowWarsLongDataComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2823); this.response.appendInt(1); this.response.appendString("SnowStorm level " + 10); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnGameEnding.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnGameEnding.java index b44c14b9..520d2128 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnGameEnding.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnGameEnding.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsOnGameEnding extends MessageComposer -{ +public class SnowWarsOnGameEnding extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(1893); this.response.appendInt(0); //idk @@ -18,31 +16,31 @@ public class SnowWarsOnGameEnding extends MessageComposer this.response.appendInt(1); //Count //{ - //Game2TeamScoreData - this.response.appendInt(1); //Team ID? - this.response.appendInt(100); //Score + //Game2TeamScoreData + this.response.appendInt(1); //Team ID? + this.response.appendInt(100); //Score - this.response.appendInt(1); //Count - //{ - //Game2TeamPlayerData - this.response.appendString("Admin"); //username - this.response.appendInt(1); //UserID - this.response.appendString("ca-1807-64.lg-275-78.hd-3093-1.hr-802-42.ch-3110-65-62.fa-1211-62"); //Look - this.response.appendString("m"); //GENDER - this.response.appendInt(1337); //Score + this.response.appendInt(1); //Count + //{ + //Game2TeamPlayerData + this.response.appendString("Admin"); //username + this.response.appendInt(1); //UserID + this.response.appendString("ca-1807-64.lg-275-78.hd-3093-1.hr-802-42.ch-3110-65-62.fa-1211-62"); //Look + this.response.appendString("m"); //GENDER + this.response.appendInt(1337); //Score - //Game2PlayerStatsData - this.response.appendInt(1337); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); - //} + //Game2PlayerStatsData + this.response.appendInt(1337); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + this.response.appendInt(0); + //} //} //Game2SnowWarGameStats diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageEnding.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageEnding.java index 8caa4639..70e9df71 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageEnding.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageEnding.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsOnStageEnding extends MessageComposer -{ +public class SnowWarsOnStageEnding extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(1140); this.response.appendInt(1); //idk return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageRunningComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageRunningComposer.java index 7dedc8eb..d1a916da 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageRunningComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageRunningComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsOnStageRunningComposer extends MessageComposer -{ +public class SnowWarsOnStageRunningComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3832); this.response.appendInt(120); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageStartComposer.java index 8c3d1cbb..0ad456af 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsOnStageStartComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsOnStageStartComposer extends MessageComposer -{ +public class SnowWarsOnStageStartComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(889); this.response.appendInt(0); this.response.appendString("snowwar_arena_0"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPlayNowWindowComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPlayNowWindowComposer.java index 4c321396..e7eb8931 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPlayNowWindowComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPlayNowWindowComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsPlayNowWindowComposer extends MessageComposer -{ +public class SnowWarsPlayNowWindowComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2276); this.response.appendInt(0); //status this.response.appendInt(100); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPreviousRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPreviousRoomComposer.java index f3ec791f..77dcc7a3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPreviousRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsPreviousRoomComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsPreviousRoomComposer extends MessageComposer -{ +public class SnowWarsPreviousRoomComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(1381); this.response.appendInt(1); //room Id return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuePositionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuePositionComposer.java index 5fcc77bd..0bc871b4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuePositionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuePositionComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsQuePositionComposer extends MessageComposer -{ +public class SnowWarsQuePositionComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2077); this.response.appendInt(1); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuickJoinComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuickJoinComposer.java index ebe19ea7..cb7502d2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuickJoinComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsQuickJoinComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsQuickJoinComposer extends MessageComposer -{ +public class SnowWarsQuickJoinComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(913); this.response.appendInt(1); this.response.appendString("SnowStorm level " + 9); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsRemoveUserComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsRemoveUserComposer.java index 93c85a81..a7d986a6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsRemoveUserComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsRemoveUserComposer.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsRemoveUserComposer extends MessageComposer -{ +public class SnowWarsRemoveUserComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2502); this.response.appendInt(3); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsResetTimerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsResetTimerComposer.java index 40fd1ce3..83a4e241 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsResetTimerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsResetTimerComposer.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsResetTimerComposer extends MessageComposer -{ +public class SnowWarsResetTimerComposer extends MessageComposer { //SnowStageRunning? @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(294); this.response.appendInt(100); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsStartLobbyCounter.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsStartLobbyCounter.java index ae266a2c..c33d5702 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsStartLobbyCounter.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsStartLobbyCounter.java @@ -3,12 +3,10 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsStartLobbyCounter extends MessageComposer -{ +public class SnowWarsStartLobbyCounter extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3757); this.response.appendInt(5); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUnknownComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUnknownComposer.java index c50bbbcc..fd331a8c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUnknownComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUnknownComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsUnknownComposer extends MessageComposer -{ +public class SnowWarsUnknownComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2869); this.response.appendString("snowwar"); this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserChatComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserChatComposer.java index b6fdfa58..c5987bab 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserChatComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserChatComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsUserChatComposer extends MessageComposer -{ +public class SnowWarsUserChatComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(2049); this.response.appendInt(1); //UserID this.response.appendString("Message"); 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 575e4778..ca819281 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 @@ -3,29 +3,24 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsUserEnteredArenaComposer extends MessageComposer -{ +public class SnowWarsUserEnteredArenaComposer extends MessageComposer { private final int type; - public SnowWarsUserEnteredArenaComposer(int type) - { - this.type =type; + public SnowWarsUserEnteredArenaComposer(int type) { + this.type = type; } + @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3425); - if(this.type == 1) - { + if (this.type == 1) { this.response.appendInt(1); //userId this.response.appendString("Admin"); this.response.appendString("ca-1807-64.lg-275-78.hd-3093-1.hr-802-42.ch-3110-65-62.fa-1211-62"); this.response.appendString("m"); this.response.appendInt(1); //team - } - else - { + } else { this.response.appendInt(0); //userId this.response.appendString("Droppy"); this.response.appendString("ca-1807-64.lg-275-78.hd-3093-1.hr-802-42.ch-3110-65-62.fa-1211-62"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserExitArenaComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserExitArenaComposer.java index 640afcf7..7522a245 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserExitArenaComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/SnowWarsUserExitArenaComposer.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.outgoing.unknown; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -public class SnowWarsUserExitArenaComposer extends MessageComposer -{ +public class SnowWarsUserExitArenaComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(3811); this.response.appendInt(1); //userId this.response.appendInt(1); //IDK ? TEAM? diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailFailedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailFailedComposer.java index 94b30605..d2960135 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailFailedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailFailedComposer.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; -public class TalentTrackEmailFailedComposer extends MessageComposer -{ +public class TalentTrackEmailFailedComposer extends MessageComposer { private final int result; - public TalentTrackEmailFailedComposer(int result) - { + public TalentTrackEmailFailedComposer(int result) { this.result = result; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TalentTrackEmailFailedComposer); this.response.appendInt(this.result); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailVerifiedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailVerifiedComposer.java index ef1cf551..87f4250d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailVerifiedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/TalentTrackEmailVerifiedComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class TalentTrackEmailVerifiedComposer extends MessageComposer -{ +public class TalentTrackEmailVerifiedComposer extends MessageComposer { private final String email; private final boolean unknownB1; private final boolean unknownB2; - public TalentTrackEmailVerifiedComposer(String email, boolean unknownB1, boolean unknownB2) - { + public TalentTrackEmailVerifiedComposer(String email, boolean unknownB1, boolean unknownB2) { this.email = email; this.unknownB1 = unknownB1; this.unknownB2 = unknownB2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.TalentTrackEmailVerifiedComposer); this.response.appendString(this.email); this.response.appendBoolean(this.unknownB1); 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 eb21ca1d..c5613934 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 @@ -4,18 +4,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownAdManagerComposer extends MessageComposer -{ +public class UnknownAdManagerComposer extends MessageComposer { private final boolean unknownBoolean; - public UnknownAdManagerComposer(boolean unknownBoolean) - { + public UnknownAdManagerComposer(boolean unknownBoolean) { this.unknownBoolean = unknownBoolean; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownAdManagerComposer); this.response.appendBoolean(this.unknownBoolean); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAvatarEditorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAvatarEditorComposer.java index 3a668dcf..0a5afef1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAvatarEditorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownAvatarEditorComposer.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; -public class UnknownAvatarEditorComposer extends MessageComposer -{ +public class UnknownAvatarEditorComposer extends MessageComposer { private final int type; - public UnknownAvatarEditorComposer(int type) - { + public UnknownAvatarEditorComposer(int type) { this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownAvatarEditorComposer); this.response.appendInt(this.type); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCatalogPageOfferComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCatalogPageOfferComposer.java index 79396b95..ef67851b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCatalogPageOfferComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCatalogPageOfferComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownCatalogPageOfferComposer extends MessageComposer -{ +public class UnknownCatalogPageOfferComposer extends MessageComposer { private final int pageId; private final CatalogItem catalogItem; - public UnknownCatalogPageOfferComposer(int pageId, CatalogItem catalogItem) - { + public UnknownCatalogPageOfferComposer(int pageId, CatalogItem catalogItem) { this.pageId = pageId; this.catalogItem = catalogItem; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownCatalogPageOfferComposer); this.response.appendInt(this.pageId); this.catalogItem.serialize(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCompetitionComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCompetitionComposer.java index 10f3c9dd..6c567402 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCompetitionComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownCompetitionComposer.java @@ -4,15 +4,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownCompetitionComposer extends MessageComposer -{ +public class UnknownCompetitionComposer extends MessageComposer { private final int unknownInt1; private final String unknownString1; private final int unknownInt2; private final int unknownInt3; - public UnknownCompetitionComposer(int unknownInt1, String unknownString1, int unknownInt2, int unknownInt3) - { + public UnknownCompetitionComposer(int unknownInt1, String unknownString1, int unknownInt2, int unknownInt3) { this.unknownInt1 = unknownInt1; this.unknownString1 = unknownString1; this.unknownInt2 = unknownInt2; @@ -20,8 +18,7 @@ public class UnknownCompetitionComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownCompetitionComposer); this.response.appendInt(this.unknownInt1); this.response.appendString(this.unknownString1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer4.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer4.java index bee208a2..b097234b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer4.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer4.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownComposer4 extends MessageComposer -{ +public class UnknownComposer4 extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.IsFirstLoginOfDayComposer); this.response.appendBoolean(false); //Think something related to promo. Not sure though. return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java index 036cc32c..600b280d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownComposer5 extends MessageComposer -{ +public class UnknownComposer5 extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownComposer5); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer8.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer8.java index 328a5513..5fd770ce 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer8.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer8.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownComposer8 extends MessageComposer -{ +public class UnknownComposer8 extends MessageComposer { private final int unknownInt1; private final int userId; private final int unknownInt2; - public UnknownComposer8(int unknownInt1, int userId, int unknownInt2) - { + public UnknownComposer8(int unknownInt1, int userId, int unknownInt2) { this.unknownInt1 = unknownInt1; this.userId = userId; this.unknownInt2 = unknownInt2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownComposer8); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.userId); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownFurniModelComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownFurniModelComposer.java index a4195b97..1f48b509 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownFurniModelComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownFurniModelComposer.java @@ -5,20 +5,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownFurniModelComposer extends MessageComposer -{ +public class UnknownFurniModelComposer extends MessageComposer { private final HabboItem item; private final int unknownInt; - public UnknownFurniModelComposer(HabboItem item, int unknownInt) - { + public UnknownFurniModelComposer(HabboItem item, int unknownInt) { this.item = item; this.unknownInt = unknownInt; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownFurniModelComposer); this.response.appendInt(this.item.getId()); this.response.appendInt(this.unknownInt); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuild2Composer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuild2Composer.java index 455bd368..f754d562 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuild2Composer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuild2Composer.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; -public class UnknownGuild2Composer extends MessageComposer -{ +public class UnknownGuild2Composer extends MessageComposer { private final int guildId; - public UnknownGuild2Composer(int guildId) - { + public UnknownGuild2Composer(int guildId) { this.guildId = guildId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownGuild2Composer); this.response.appendInt(this.guildId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuildComposer3.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuildComposer3.java index 1b824eb1..92ed45aa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuildComposer3.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownGuildComposer3.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; -public class UnknownGuildComposer3 extends MessageComposer -{ +public class UnknownGuildComposer3 extends MessageComposer { private final int userId; - public UnknownGuildComposer3(int userId) - { + public UnknownGuildComposer3(int userId) { this.userId = userId; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownGuildComposer3); this.response.appendInt(this.userId); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHabboWayQuizComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHabboWayQuizComposer.java index c2d81c6e..69e80c39 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHabboWayQuizComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHabboWayQuizComposer.java @@ -6,25 +6,21 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class UnknownHabboWayQuizComposer extends MessageComposer -{ +public class UnknownHabboWayQuizComposer extends MessageComposer { private final String unknownString; private final List unknownIntegerList; - public UnknownHabboWayQuizComposer(String unknownString, List unknownIntegerList) - { + public UnknownHabboWayQuizComposer(String unknownString, List unknownIntegerList) { this.unknownString = unknownString; this.unknownIntegerList = unknownIntegerList; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownHabboWayQuizComposer); this.response.appendString(this.unknownString); this.response.appendInt(this.unknownIntegerList.size()); - for (Integer i : this.unknownIntegerList) - { + for (Integer i : this.unknownIntegerList) { this.response.appendInt(i); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHelperComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHelperComposer.java index 34da5633..60cd0fff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHelperComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHelperComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownHelperComposer extends MessageComposer -{ +public class UnknownHelperComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownHelperComposer); //Empty body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHintComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHintComposer.java index a96b372c..fd3683cb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHintComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownHintComposer.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; -public class UnknownHintComposer extends MessageComposer -{ +public class UnknownHintComposer extends MessageComposer { private final String key; - public UnknownHintComposer(String key) - { + public UnknownHintComposer(String key) { this.key = key; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownHintComposer); this.response.appendString(this.key); return this.response; 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 9f14c296..36205b53 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 @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownMessengerErrorComposer extends MessageComposer -{ +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) - { + public UnknownMessengerErrorComposer(int errorCode, int userId, String message) { this.errorCode = errorCode; this.userId = userId; this.message = message; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownMessengerErrorComposer); this.response.appendInt(this.errorCode); this.response.appendInt(this.userId); 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 c5534afa..972d64d7 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 @@ -6,25 +6,21 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class UnknownPollQuestionComposer extends MessageComposer -{ +public class UnknownPollQuestionComposer extends MessageComposer { private final int unknownInt; private final Map unknownMap; - public UnknownPollQuestionComposer(int unknownInt, Map unknownMap) - { + public UnknownPollQuestionComposer(int unknownInt, Map unknownMap) { this.unknownInt = unknownInt; this.unknownMap = unknownMap; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.SimplePollAnswersComposer); this.response.appendInt(this.unknownInt); this.response.appendInt(this.unknownMap.size()); - for (Map.Entry entry : this.unknownMap.entrySet()) - { + for (Map.Entry entry : this.unknownMap.entrySet()) { this.response.appendString(entry.getKey()); this.response.appendInt(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomDesktopComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomDesktopComposer.java index 5ae4efb6..db5221e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomDesktopComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomDesktopComposer.java @@ -6,25 +6,21 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class UnknownRoomDesktopComposer extends MessageComposer -{ +public class UnknownRoomDesktopComposer extends MessageComposer { private final int unknownInt1; private final Map unknownMap; - public UnknownRoomDesktopComposer(int unknownInt1, Map unknownMap) - { + public UnknownRoomDesktopComposer(int unknownInt1, Map unknownMap) { this.unknownInt1 = unknownInt1; this.unknownMap = unknownMap; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownRoomDesktopComposer); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.unknownMap.size()); - for (Map.Entry entry : this.unknownMap.entrySet()) - { + for (Map.Entry entry : this.unknownMap.entrySet()) { this.response.appendInt(entry.getKey()); this.response.appendString(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomViewerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomViewerComposer.java index f2a97145..54446677 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomViewerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownRoomViewerComposer.java @@ -6,22 +6,18 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class UnknownRoomViewerComposer extends MessageComposer -{ +public class UnknownRoomViewerComposer extends MessageComposer { private final Map unknownMap; - public UnknownRoomViewerComposer(Map unknownMap) - { + public UnknownRoomViewerComposer(Map unknownMap) { this.unknownMap = unknownMap; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownRoomViewerComposer); this.response.appendInt(this.unknownMap.size()); - for (Map.Entry entry : this.unknownMap.entrySet()) - { + for (Map.Entry entry : this.unknownMap.entrySet()) { this.response.appendInt(entry.getKey()); this.response.appendString(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownStatusComposer.java index 23ae51a4..d4c0f902 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownStatusComposer.java @@ -4,21 +4,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownStatusComposer extends MessageComposer -{ +public class UnknownStatusComposer extends MessageComposer { public final int STATUS_ZERO = 0; - public final int STATUS_ONE = 1; + public final int STATUS_ONE = 1; private final int status; - public UnknownStatusComposer(int status) - { + public UnknownStatusComposer(int status) { this.status = status; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownStatusComposer); this.response.appendInt(this.status); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownTradeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownTradeComposer.java index e500eef0..8d1a1ca9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownTradeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownTradeComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownTradeComposer extends MessageComposer -{ +public class UnknownTradeComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownTradeComposer); //Empty Body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnkownPetPackageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnkownPetPackageComposer.java index d0782707..e33142e3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnkownPetPackageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnkownPetPackageComposer.java @@ -6,22 +6,18 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Map; -public class UnkownPetPackageComposer extends MessageComposer -{ +public class UnkownPetPackageComposer extends MessageComposer { private final Map unknownMap; - public UnkownPetPackageComposer(Map unknownMap) - { + public UnkownPetPackageComposer(Map unknownMap) { this.unknownMap = unknownMap; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnkownPetPackageComposer); this.response.appendInt(this.unknownMap.size()); - for (Map.Entry entry : this.unknownMap.entrySet()) - { + for (Map.Entry entry : this.unknownMap.entrySet()) { this.response.appendString(entry.getKey()); this.response.appendString(entry.getValue()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationComposer.java index 85619b34..c679545d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UserClassificationComposer.java @@ -7,22 +7,18 @@ import org.apache.commons.math3.util.Pair; import java.util.List; -public class UserClassificationComposer extends MessageComposer -{ +public class UserClassificationComposer extends MessageComposer { private final List>> info; - public UserClassificationComposer(List>> info) - { + public UserClassificationComposer(List>> info) { this.info = info; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserClassificationComposer); this.response.appendInt(this.info.size()); - for (Pair> set : this.info) - { + for (Pair> set : this.info) { this.response.appendInt(set.getKey()); this.response.appendString(set.getValue().getKey()); this.response.appendString(set.getValue().getValue()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/VipTutorialsStartComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/VipTutorialsStartComposer.java index 748712d7..e9a8b86b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/VipTutorialsStartComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/VipTutorialsStartComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class VipTutorialsStartComposer extends MessageComposer -{ +public class VipTutorialsStartComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.VipTutorialsStartComposer); //Empty Body return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WatchAndEarnRewardComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WatchAndEarnRewardComposer.java index eb97ef1d..17eb79e2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WatchAndEarnRewardComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WatchAndEarnRewardComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WatchAndEarnRewardComposer extends MessageComposer -{ +public class WatchAndEarnRewardComposer extends MessageComposer { private final Item item; - public WatchAndEarnRewardComposer(Item item) - { + public WatchAndEarnRewardComposer(Item item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WatchAndEarnRewardComposer); this.response.appendString(this.item.getType().code); this.response.appendInt(this.item.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftComposer.java index 6a65472b..6e41e4cb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftComposer.java @@ -4,16 +4,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WelcomeGiftComposer extends MessageComposer -{ +public class WelcomeGiftComposer extends MessageComposer { private final String email; private final boolean unknownB1; private final boolean unknownB2; private final int furniId; private final boolean unknownB3; - public WelcomeGiftComposer(String email, boolean unknownB1, boolean unknownB2, int furniId, boolean unknownB3) - { + public WelcomeGiftComposer(String email, boolean unknownB1, boolean unknownB2, int furniId, boolean unknownB3) { this.email = email; this.unknownB1 = unknownB1; this.unknownB2 = unknownB2; @@ -22,8 +20,7 @@ public class WelcomeGiftComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WelcomeGiftComposer); this.response.appendString(this.email); this.response.appendBoolean(this.unknownB1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftErrorComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftErrorComposer.java index b2b54422..3f94d436 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftErrorComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/WelcomeGiftErrorComposer.java @@ -4,23 +4,20 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WelcomeGiftErrorComposer extends MessageComposer -{ - public final static int EMAIL_INVALID = 0; +public class WelcomeGiftErrorComposer extends MessageComposer { + public final static int EMAIL_INVALID = 0; public final static int EMAIL_LENGTH_EXCEEDED = 1; - public final static int EMAIL_IN_USE = 3; - public final static int EMAIL_LIMIT_CHANGE = 4; + public final static int EMAIL_IN_USE = 3; + public final static int EMAIL_LIMIT_CHANGE = 4; private final int error; - public WelcomeGiftErrorComposer(int error) - { + public WelcomeGiftErrorComposer(int error) { this.error = error; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WelcomeGiftErrorComposer); this.response.appendInt(this.error); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/AddUserBadgeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/AddUserBadgeComposer.java index effa1033..ac7a38bd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/AddUserBadgeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/AddUserBadgeComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class AddUserBadgeComposer extends MessageComposer -{ +public class AddUserBadgeComposer extends MessageComposer { private final HabboBadge badge; - public AddUserBadgeComposer(HabboBadge badge) - { + public AddUserBadgeComposer(HabboBadge badge) { this.badge = badge; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.AddUserBadgeComposer); this.response.appendInt(this.badge.getId()); this.response.appendString(this.badge.getCode()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ChangeNameCheckResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ChangeNameCheckResultComposer.java index 99c5395b..bc2089de 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ChangeNameCheckResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ChangeNameCheckResultComposer.java @@ -6,8 +6,7 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; -public class ChangeNameCheckResultComposer extends MessageComposer -{ +public class ChangeNameCheckResultComposer extends MessageComposer { public static final int AVAILABLE = 0; public static final int TOO_SHORT = 2; public static final int TOO_LONG = 3; @@ -19,22 +18,19 @@ public class ChangeNameCheckResultComposer extends MessageComposer private final String name; private final List suggestions; - public ChangeNameCheckResultComposer(int status, String name, List suggestions) - { + public ChangeNameCheckResultComposer(int status, String name, List suggestions) { this.status = status; this.name = name; this.suggestions = suggestions; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UnknownComposer_2698); this.response.appendInt(this.status); this.response.appendString(this.name); this.response.appendInt(this.suggestions.size()); - for (String suggestion : this.suggestions) - { + for (String suggestion : this.suggestions) { this.response.appendString(suggestion); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftReceivedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftReceivedComposer.java index d2bedd8c..cfb5e4d9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftReceivedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftReceivedComposer.java @@ -6,24 +6,20 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -public class ClubGiftReceivedComposer extends MessageComposer -{ +public class ClubGiftReceivedComposer extends MessageComposer { //:test 735 s:t i:1 s:s i:230 s:throne i:1 b:1 i:1 i:10; private final THashSet items; - public ClubGiftReceivedComposer(THashSet items) - { + public ClubGiftReceivedComposer(THashSet items) { this.items = items; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.ClubGiftReceivedComposer); this.response.appendInt(this.items.size()); - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { this.response.appendString(item.getBaseItem().getType().code); this.response.appendInt(item.getBaseItem().getId()); this.response.appendString(item.getBaseItem().getName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/FavoriteRoomsCountComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/FavoriteRoomsCountComposer.java index fdaa584f..57f7a586 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/FavoriteRoomsCountComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/FavoriteRoomsCountComposer.java @@ -7,26 +7,21 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.procedure.TIntProcedure; -public class FavoriteRoomsCountComposer extends MessageComposer -{ +public class FavoriteRoomsCountComposer extends MessageComposer { private final Habbo habbo; - public FavoriteRoomsCountComposer(Habbo habbo) - { + public FavoriteRoomsCountComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FavoriteRoomsCountComposer); this.response.appendInt(Emulator.getConfig().getInt("hotel.rooms.max.favorite")); this.response.appendInt(this.habbo.getHabboStats().getFavoriteRooms().size()); - this.habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() - { + this.habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() { @Override - public boolean execute(int value) - { + public boolean execute(int value) { FavoriteRoomsCountComposer.this.response.appendInt(value); return true; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java index 4fb33c4e..de1d10b0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class MeMenuSettingsComposer extends MessageComposer -{ +public class MeMenuSettingsComposer extends MessageComposer { private final Habbo habbo; - public MeMenuSettingsComposer(Habbo habbo) - { + public MeMenuSettingsComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MeMenuSettingsComposer); this.response.appendInt(this.habbo.getHabboStats().volumeSystem); this.response.appendInt(this.habbo.getHabboStats().volumeFurni); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/MutedWhisperComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/MutedWhisperComposer.java index 8d08a9df..05cf873a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/MutedWhisperComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/MutedWhisperComposer.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; -public class MutedWhisperComposer extends MessageComposer -{ +public class MutedWhisperComposer extends MessageComposer { private final int seconds; - public MutedWhisperComposer(int seconds) - { + public MutedWhisperComposer(int seconds) { this.seconds = seconds; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.MutedWhisperComposer); this.response.appendInt(this.seconds); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java index 5d516532..cd4dab5a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java @@ -14,15 +14,13 @@ import java.util.List; import java.util.Map; import java.util.Random; -public class ProfileFriendsComposer extends MessageComposer -{ +public class ProfileFriendsComposer extends MessageComposer { private final List lovers = new ArrayList<>(); private final List friends = new ArrayList<>(); private final List haters = new ArrayList<>(); private final int userId; - public ProfileFriendsComposer(THashMap> map, int userId) - { + public ProfileFriendsComposer(THashMap> map, int userId) { this.lovers.addAll(map.get(1)); this.friends.addAll(map.get(2)); this.haters.addAll(map.get(3)); @@ -30,12 +28,9 @@ public class ProfileFriendsComposer extends MessageComposer this.userId = userId; } - public ProfileFriendsComposer(Habbo habbo) - { - try - { - for (Map.Entry map : habbo.getMessenger().getFriends().entrySet()) - { + public ProfileFriendsComposer(Habbo habbo) { + try { + for (Map.Entry map : habbo.getMessenger().getFriends().entrySet()) { if (map.getValue().getRelation() == 0) continue; @@ -51,9 +46,7 @@ public class ProfileFriendsComposer extends MessageComposer break; } } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } @@ -61,22 +54,20 @@ public class ProfileFriendsComposer extends MessageComposer } @Override - public ServerMessage compose() - { - try - { + public ServerMessage compose() { + try { this.response.init(Outgoing.ProfileFriendsComposer); this.response.appendInt(this.userId); int total = 0; - if(!this.lovers.isEmpty()) + if (!this.lovers.isEmpty()) total++; - if(!this.friends.isEmpty()) + if (!this.friends.isEmpty()) total++; - if(!this.haters.isEmpty()) + if (!this.haters.isEmpty()) total++; this.response.appendInt(total); @@ -109,9 +100,7 @@ public class ProfileFriendsComposer extends MessageComposer this.response.appendString(this.haters.get(hatersIndex).getUsername()); this.response.appendString(this.haters.get(hatersIndex).getLook()); } - } - catch(Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UpdateUserLookComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UpdateUserLookComposer.java index 4875ddbb..5b536e02 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UpdateUserLookComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UpdateUserLookComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UpdateUserLookComposer extends MessageComposer -{ +public class UpdateUserLookComposer extends MessageComposer { private final Habbo habbo; - public UpdateUserLookComposer(Habbo habbo) - { + public UpdateUserLookComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UpdateUserLookComposer); this.response.appendString(this.habbo.getHabboInfo().getLook()); this.response.appendString(this.habbo.getHabboInfo().getGender().name()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserAchievementScoreComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserAchievementScoreComposer.java index 5aafcb4b..8f7f7766 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserAchievementScoreComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserAchievementScoreComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserAchievementScoreComposer extends MessageComposer -{ +public class UserAchievementScoreComposer extends MessageComposer { private final Habbo habbo; - public UserAchievementScoreComposer(Habbo habbo) - { + public UserAchievementScoreComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserAchievementScoreComposer); this.response.appendInt(this.habbo.getHabboStats().getAchievementScore()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserBCLimitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserBCLimitsComposer.java index 060760ba..30e1b895 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserBCLimitsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserBCLimitsComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserBCLimitsComposer extends MessageComposer -{ +public class UserBCLimitsComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserBCLimitsComposer); this.response.appendInt(0); this.response.appendInt(500); 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 ae53d05d..e4e5d2ca 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 @@ -7,27 +7,22 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; -public class UserBadgesComposer extends MessageComposer -{ +public class UserBadgesComposer extends MessageComposer { private final ArrayList badges; private final int habbo; - public UserBadgesComposer(ArrayList badges, int habbo) - { + public UserBadgesComposer(ArrayList badges, int habbo) { this.badges = badges; this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserBadgesComposer); this.response.appendInt(this.habbo); - synchronized (this.badges) - { + synchronized (this.badges) { this.response.appendInt(this.badges.size()); - for (HabboBadge badge : this.badges) - { + for (HabboBadge badge : this.badges) { this.response.appendInt(badge.getSlot()); this.response.appendString(badge.getCode()); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCitizinShipComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCitizinShipComposer.java index 8c05ddd8..b2f33c9b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCitizinShipComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCitizinShipComposer.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; -public class UserCitizinShipComposer extends MessageComposer -{ +public class UserCitizinShipComposer extends MessageComposer { private final String name; - public UserCitizinShipComposer(String name) - { + public UserCitizinShipComposer(String name) { this.name = name; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserCitizinShipComposer); this.response.appendString(this.name); this.response.appendInt(4); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserClothesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserClothesComposer.java index 329bfba3..bc6ef47f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserClothesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserClothesComposer.java @@ -10,24 +10,18 @@ import gnu.trove.procedure.TIntProcedure; import java.util.ArrayList; -public class UserClothesComposer extends MessageComposer -{ +public class UserClothesComposer extends MessageComposer { private final ArrayList idList = new ArrayList<>(); private final ArrayList nameList = new ArrayList<>(); - public UserClothesComposer(Habbo habbo) - { - habbo.getInventory().getWardrobeComponent().getClothing().forEach(new TIntProcedure() - { + public UserClothesComposer(Habbo habbo) { + habbo.getInventory().getWardrobeComponent().getClothing().forEach(new TIntProcedure() { @Override - public boolean execute(int value) - { + public boolean execute(int value) { ClothItem item = Emulator.getGameEnvironment().getCatalogManager().clothing.get(value); - if (item != null) - { - for (Integer j : item.setId) - { + if (item != null) { + for (Integer j : item.setId) { UserClothesComposer.this.idList.add(j); } @@ -40,8 +34,7 @@ public class UserClothesComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserClothesComposer); this.response.appendInt(this.idList.size()); this.idList.forEach(this.response::appendInt); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserClubComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserClubComposer.java index dbfc1848..eeb0724f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserClubComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserClubComposer.java @@ -6,18 +6,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserClubComposer extends MessageComposer -{ +public class UserClubComposer extends MessageComposer { private final Habbo habbo; - public UserClubComposer(Habbo habbo) - { + public UserClubComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserClubComposer); this.response.appendString("club_habbo"); @@ -25,8 +22,7 @@ public class UserClubComposer extends MessageComposer int endTimestamp = this.habbo.getHabboStats().getClubExpireTimestamp(); int now = Emulator.getIntUnixTimestamp(); - if(endTimestamp >= now) - { + if (endTimestamp >= now) { int days = ((endTimestamp - Emulator.getIntUnixTimestamp()) / 86400); @@ -37,8 +33,7 @@ public class UserClubComposer extends MessageComposer int months = 0; - if(days > 31) - { + if (days > 31) { months = (int) Math.floor(days / 31); days = days - (months * 31); } @@ -47,9 +42,7 @@ public class UserClubComposer extends MessageComposer this.response.appendInt(1); this.response.appendInt(months); this.response.appendInt(years); - } - else - { + } else { this.response.appendInt(0); this.response.appendInt(7); this.response.appendInt(0); @@ -62,12 +55,9 @@ public class UserClubComposer extends MessageComposer long remaining = (endTimestamp - Emulator.getIntUnixTimestamp()) * 1000; - if (remaining > Integer.MAX_VALUE || remaining <= 0) - { + if (remaining > Integer.MAX_VALUE || remaining <= 0) { this.response.appendInt(Integer.MAX_VALUE); - } - else - { + } else { this.response.appendInt((int) remaining); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCreditsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCreditsComposer.java index 143877a9..5041b8ea 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCreditsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCreditsComposer.java @@ -5,8 +5,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserCreditsComposer extends MessageComposer -{ +public class UserCreditsComposer extends MessageComposer { private final Habbo habbo; public UserCreditsComposer(Habbo habbo) { @@ -14,8 +13,7 @@ public class UserCreditsComposer extends MessageComposer } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserCreditsComposer); this.response.appendString(this.habbo.getHabboInfo().getCredits() + ".0"); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java index a3fc81a5..c91a83fe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java @@ -6,29 +6,23 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserCurrencyComposer extends MessageComposer -{ +public class UserCurrencyComposer extends MessageComposer { private final Habbo habbo; - public UserCurrencyComposer(Habbo habbo) - { + public UserCurrencyComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserCurrencyComposer); String[] pointsTypes = Emulator.getConfig().getValue("seasonal.types").split(";"); this.response.appendInt(pointsTypes.length); - for(String s : pointsTypes) - { + for (String s : pointsTypes) { int type; - try - { + try { type = Integer.valueOf(s); - } - catch (Exception e){ + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserDataComposer.java index e96a3b10..5d5ed7e2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserDataComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserDataComposer extends MessageComposer -{ +public class UserDataComposer extends MessageComposer { private final Habbo habbo; - - public UserDataComposer(Habbo habbo) - { + + public UserDataComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserDataComposer); this.response.appendInt(this.habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java index e14ee6a8..ad324081 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserHomeRoomComposer extends MessageComposer -{ +public class UserHomeRoomComposer extends MessageComposer { private final int homeRoom; private final int newRoom; - public UserHomeRoomComposer(int homeRoom, int newRoom) - { + public UserHomeRoomComposer(int homeRoom, int newRoom) { this.homeRoom = homeRoom; this.newRoom = newRoom; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserHomeRoomComposer); this.response.appendInt(this.homeRoom); this.response.appendInt(this.newRoom); 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 b2f553f1..508ad241 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,18 +6,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserPerksComposer extends MessageComposer -{ +public class UserPerksComposer extends MessageComposer { private final Habbo habbo; - public UserPerksComposer(Habbo habbo) - { + public UserPerksComposer(Habbo habbo) { this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserPerksComposer); this.response.appendInt(15); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPermissionsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPermissionsComposer.java index 91311f69..9dc9cb0b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPermissionsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPermissionsComposer.java @@ -5,21 +5,18 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserPermissionsComposer extends MessageComposer -{ +public class UserPermissionsComposer extends MessageComposer { private final int clubLevel; private final Habbo habbo; - public UserPermissionsComposer(Habbo habbo) - { + public UserPermissionsComposer(Habbo habbo) { this.clubLevel = habbo.getHabboStats().hasActiveClub() ? 2 : 0; this.habbo = habbo; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserPermissionsComposer); this.response.appendInt(this.clubLevel); this.response.appendInt(this.habbo.getHabboInfo().getRank().getLevel()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPointsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPointsComposer.java index 369539dd..6a158ad2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPointsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPointsComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserPointsComposer extends MessageComposer -{ +public class UserPointsComposer extends MessageComposer { private final int currentAmount; private final int amountAdded; private final int type; - public UserPointsComposer(int currentAmount, int amountAdded, int type) - { + public UserPointsComposer(int currentAmount, int amountAdded, int type) { this.currentAmount = currentAmount; this.amountAdded = amountAdded; this.type = type; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserPointsComposer); this.response.appendInt(this.currentAmount); this.response.appendInt(this.amountAdded); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java index 17e7fd87..6a9cdf33 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java @@ -19,29 +19,25 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -public class UserProfileComposer extends MessageComposer -{ +public class UserProfileComposer extends MessageComposer { private final HabboInfo habboInfo; private Habbo habbo; private GameClient viewer; - public UserProfileComposer(HabboInfo habboInfo, GameClient viewer) - { + public UserProfileComposer(HabboInfo habboInfo, GameClient viewer) { this.habboInfo = habboInfo; this.viewer = viewer; } - public UserProfileComposer(Habbo habbo, GameClient viewer) - { + public UserProfileComposer(Habbo habbo, GameClient viewer) { this.habbo = habbo; this.habboInfo = habbo.getHabboInfo(); this.viewer = viewer; } @Override - public ServerMessage compose() - { - if(this.habboInfo == null) + public ServerMessage compose() { + if (this.habboInfo == null) return null; this.response.init(Outgoing.UserProfileComposer); @@ -53,25 +49,17 @@ public class UserProfileComposer extends MessageComposer this.response.appendString(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date(this.habboInfo.getAccountCreated() * 1000L))); int achievementScore = 0; - if (this.habbo != null) - { + if (this.habbo != null) { achievementScore = this.habbo.getHabboStats().getAchievementScore(); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT achievement_score FROM users_settings WHERE user_id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT achievement_score FROM users_settings WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.habboInfo.getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { achievementScore = set.getInt("achievement_score"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -82,40 +70,31 @@ public class UserProfileComposer extends MessageComposer this.response.appendBoolean(this.habboInfo.isOnline()); List guilds = new ArrayList<>(); - if(this.habbo != null) - { + if (this.habbo != null) { List toRemove = new ArrayList<>(); - for (int index = this.habbo.getHabboStats().guilds.size(); index > 0; index--) - { + for (int index = this.habbo.getHabboStats().guilds.size(); index > 0; index--) { int i = this.habbo.getHabboStats().guilds.get(index - 1); if (i == 0) continue; Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(i); - if (guild != null) - { + if (guild != null) { guilds.add(guild); - } - else - { + } else { toRemove.add(i); } } - for (int i : toRemove) - { + for (int i : toRemove) { this.habbo.getHabboStats().removeGuild(i); } - } - else - { + } else { guilds = Emulator.getGameEnvironment().getGuildManager().getGuilds(this.habboInfo.getId()); } this.response.appendInt(guilds.size()); - for(Guild guild : guilds) - { + for (Guild guild : guilds) { this.response.appendInt(guild.getId()); this.response.appendString(guild.getName()); this.response.appendString(guild.getBadge()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserWardrobeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserWardrobeComposer.java index 96fadd1b..562a2f09 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserWardrobeComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserWardrobeComposer.java @@ -5,23 +5,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UserWardrobeComposer extends MessageComposer -{ +public class UserWardrobeComposer extends MessageComposer { private final WardrobeComponent wardrobeComponent; - public UserWardrobeComposer(WardrobeComponent wardrobeComponent) - { + public UserWardrobeComposer(WardrobeComponent wardrobeComponent) { this.wardrobeComponent = wardrobeComponent; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.UserWardrobeComposer); this.response.appendInt(1); this.response.appendInt(this.wardrobeComponent.getLooks().size()); - for(WardrobeComponent.WardrobeItem wardrobeItem : this.wardrobeComponent.getLooks().values()) - { + for (WardrobeComponent.WardrobeItem wardrobeItem : this.wardrobeComponent.getLooks().values()) { this.response.appendInt(wardrobeItem.getSlotId()); this.response.appendString(wardrobeItem.getLook()); this.response.appendString(wardrobeItem.getGender().name().toUpperCase()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobileNumberComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobileNumberComposer.java index 62e180a0..73b6983d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobileNumberComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobileNumberComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class VerifyMobileNumberComposer extends MessageComposer -{ +public class VerifyMobileNumberComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.VerifyMobileNumberComposer); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneCodeWindowComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneCodeWindowComposer.java index 21a4f9dd..80561efc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneCodeWindowComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneCodeWindowComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class VerifyMobilePhoneCodeWindowComposer extends MessageComposer -{ +public class VerifyMobilePhoneCodeWindowComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; - public VerifyMobilePhoneCodeWindowComposer(int unknownInt1, int unknownInt2) - { + public VerifyMobilePhoneCodeWindowComposer(int unknownInt1, int unknownInt2) { this.unknownInt1 = unknownInt1; this.unknownInt2 = unknownInt2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.VerifyMobilePhoneCodeWindowComposer); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.unknownInt2); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneDoneComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneDoneComposer.java index 01e21988..136a97ba 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneDoneComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneDoneComposer.java @@ -4,20 +4,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class VerifyMobilePhoneDoneComposer extends MessageComposer -{ +public class VerifyMobilePhoneDoneComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; - public VerifyMobilePhoneDoneComposer(int unknownInt1, int unknownInt2) - { + public VerifyMobilePhoneDoneComposer(int unknownInt1, int unknownInt2) { this.unknownInt1 = unknownInt1; this.unknownInt2 = unknownInt2; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.VerifyMobilePhoneDoneComposer); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.unknownInt2); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneWindowComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneWindowComposer.java index d6cb5efb..85a31b5f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneWindowComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/verification/VerifyMobilePhoneWindowComposer.java @@ -4,22 +4,19 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class VerifyMobilePhoneWindowComposer extends MessageComposer -{ +public class VerifyMobilePhoneWindowComposer extends MessageComposer { private final int unknownInt1; private final int unknownInt2; private final int unknownInt3; - public VerifyMobilePhoneWindowComposer(int unknownInt1, int unknownInt2, int unknownInt3) - { + public VerifyMobilePhoneWindowComposer(int unknownInt1, int unknownInt2, int unknownInt3) { this.unknownInt1 = unknownInt1; this.unknownInt2 = unknownInt2; this.unknownInt3 = unknownInt3; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.VerifyMobilePhoneWindowComposer); this.response.appendInt(this.unknownInt1); this.response.appendInt(this.unknownInt2); 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 ea64d63c..71de8019 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 @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredConditionDataComposer extends MessageComposer -{ +public class WiredConditionDataComposer extends MessageComposer { private final InteractionWiredCondition condition; private final Room room; - public WiredConditionDataComposer(InteractionWiredCondition condition, Room room) - { + public WiredConditionDataComposer(InteractionWiredCondition condition, Room room) { this.condition = condition; this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredConditionDataComposer); this.condition.serializeWiredData(this.response, this.room); this.condition.needsUpdate(true); 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 de2f53b4..abd1923d 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 @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredEffectDataComposer extends MessageComposer -{ +public class WiredEffectDataComposer extends MessageComposer { private final InteractionWiredEffect effect; private final Room room; - public WiredEffectDataComposer(InteractionWiredEffect effect, Room room) - { + public WiredEffectDataComposer(InteractionWiredEffect effect, Room room) { this.effect = effect; this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredEffectDataComposer); this.effect.serializeWiredData(this.response, this.room); this.effect.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredOpenComposer.java index 4699d9ed..ea89b564 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredOpenComposer.java @@ -5,18 +5,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredOpenComposer extends MessageComposer -{ +public class WiredOpenComposer extends MessageComposer { private final HabboItem item; - public WiredOpenComposer(HabboItem item) - { + public WiredOpenComposer(HabboItem item) { this.item = item; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredOpenComposer); this.response.appendInt(this.item.getId()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardAlertComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardAlertComposer.java index b559eb04..24f8965b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardAlertComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredRewardAlertComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredRewardAlertComposer extends MessageComposer -{ +public class WiredRewardAlertComposer extends MessageComposer { public static final int LIMITED_NO_MORE_AVAILABLE = 0; public static final int REWARD_ALREADY_RECEIVED = 1; public static final int REWARD_ALREADY_RECEIVED_THIS_TODAY = 2; @@ -18,14 +17,12 @@ public class WiredRewardAlertComposer extends MessageComposer private final int code; - public WiredRewardAlertComposer(int code) - { + public WiredRewardAlertComposer(int code) { this.code = code; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredRewardAlertComposer); this.response.appendInt(this.code); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredSavedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredSavedComposer.java index 50b6ccda..bfd12f61 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredSavedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredSavedComposer.java @@ -4,11 +4,9 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredSavedComposer extends MessageComposer -{ +public class WiredSavedComposer extends MessageComposer { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredSavedComposer); return this.response; } 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 a75ac13d..abdb269f 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 @@ -6,20 +6,17 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class WiredTriggerDataComposer extends MessageComposer -{ +public class WiredTriggerDataComposer extends MessageComposer { private final InteractionWiredTrigger trigger; private final Room room; - public WiredTriggerDataComposer(InteractionWiredTrigger trigger, Room room) - { + public WiredTriggerDataComposer(InteractionWiredTrigger trigger, Room room) { this.trigger = trigger; this.room = room; } @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.WiredTriggerDataComposer); this.trigger.serializeWiredData(this.response, this.room); this.trigger.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/rcon/AlertUser.java b/src/main/java/com/eu/habbo/messages/rcon/AlertUser.java index 3910c204..b5a23427 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/AlertUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/AlertUser.java @@ -2,32 +2,26 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.google.gson.Gson; -public class AlertUser extends RCONMessage -{ +public class AlertUser extends RCONMessage { - public AlertUser() - { + public AlertUser() { super(JSONAlertUser.class); } @Override - public void handle(Gson gson, JSONAlertUser object) - { + public void handle(Gson gson, JSONAlertUser object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if(habbo != null) - { + if (habbo != null) { habbo.alert(object.message); } this.status = RCONMessage.HABBO_NOT_FOUND; } - static class JSONAlertUser - { + static class JSONAlertUser { int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java index 1038ddad..262b60be 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java @@ -4,20 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.google.gson.Gson; -public class ChangeRoomOwner extends RCONMessage -{ - public ChangeRoomOwner() - { +public class ChangeRoomOwner extends RCONMessage { + public ChangeRoomOwner() { super(JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(json.room_id); - if (room != null) - { + if (room != null) { room.setOwnerId(json.user_id); room.setOwnerName(json.username); room.setNeedsUpdate(true); @@ -26,8 +22,7 @@ public class ChangeRoomOwner extends RCONMessage } } - static class JSON - { + static class JSON { public int room_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/CreateModToolTicket.java b/src/main/java/com/eu/habbo/messages/rcon/CreateModToolTicket.java index 1d0c5813..aa9a033b 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/CreateModToolTicket.java +++ b/src/main/java/com/eu/habbo/messages/rcon/CreateModToolTicket.java @@ -5,23 +5,19 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.habbohotel.modtool.ModToolTicketType; import com.google.gson.Gson; -public class CreateModToolTicket extends RCONMessage -{ - public CreateModToolTicket() - { +public class CreateModToolTicket extends RCONMessage { + public CreateModToolTicket() { super(JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { ModToolIssue issue = new ModToolIssue(json.sender_id, json.sender_username, json.reported_id, json.reported_username, json.reported_room_id, json.message, ModToolTicketType.NORMAL); Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); } - static class JSON - { + static class JSON { public int sender_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/DisconnectUser.java b/src/main/java/com/eu/habbo/messages/rcon/DisconnectUser.java index fef7a673..8b768ac0 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/DisconnectUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/DisconnectUser.java @@ -4,35 +4,26 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -public class DisconnectUser extends RCONMessage -{ +public class DisconnectUser extends RCONMessage { - public DisconnectUser() - { + public DisconnectUser() { super(DisconnectUserJSON.class); } @Override - public void handle(Gson gson, DisconnectUserJSON json) - { + public void handle(Gson gson, DisconnectUserJSON json) { Habbo target; - if (json.user_id >= 0) - { + if (json.user_id >= 0) { target = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - } - else if (!json.username.isEmpty()) - { + } else if (!json.username.isEmpty()) { target = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.username); - } - else - { + } else { this.status = RCONMessage.HABBO_NOT_FOUND; return; } - if(target == null) - { + if (target == null) { this.status = RCONMessage.STATUS_ERROR; this.message = Emulator.getTexts().getValue("commands.error.cmd_disconnect.user_offline"); return; @@ -42,8 +33,7 @@ public class DisconnectUser extends RCONMessage -{ +public class ExecuteCommand extends RCONMessage { - public ExecuteCommand() - { + public ExecuteCommand() { super(JSONExecuteCommand.class); } @Override - public void handle(Gson gson, JSONExecuteCommand json) - { - try - { + public void handle(Gson gson, JSONExecuteCommand json) { + try { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(json.user_id); - if (habbo == null) - { + if (habbo == null) { this.status = HABBO_NOT_FOUND; return; } CommandHandler.handleCommand(habbo.getClient(), json.command); - } - catch (Exception e) - { + } catch (Exception e) { this.status = STATUS_ERROR; Emulator.getLogging().logErrorLine(e); } } - static class JSONExecuteCommand - { + static class JSONExecuteCommand { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java b/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java index 8464840f..b6f18b6a 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java @@ -6,35 +6,27 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.google.gson.Gson; -public class ForwardUser extends RCONMessage -{ +public class ForwardUser extends RCONMessage { - public ForwardUser() - { + public ForwardUser() { super(ForwardUserJSON.class); } @Override - public void handle(Gson gson, ForwardUserJSON object) - { + public void handle(Gson gson, ForwardUserJSON object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if(habbo != null) - { + if (habbo != null) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(object.room_id); - if(room != null) - { - if (habbo.getHabboInfo().getCurrentRoom() != null) - { + if (room != null) { + if (habbo.getHabboInfo().getCurrentRoom() != null) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, habbo.getHabboInfo().getCurrentRoom()); } habbo.getClient().sendResponse(new ForwardToRoomComposer(object.room_id)); Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, object.room_id, "", true); - } - else - { + } else { this.status = RCONMessage.ROOM_NOT_FOUND; } } @@ -42,8 +34,7 @@ public class ForwardUser extends RCONMessage this.status = RCONMessage.HABBO_NOT_FOUND; } - static class ForwardUserJSON - { + static class ForwardUserJSON { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java b/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java index 34f8601e..3b2f35c5 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java +++ b/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java @@ -11,40 +11,29 @@ import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.friends.FriendRequestComposer; import com.google.gson.Gson; -public class FriendRequest extends RCONMessage -{ - public FriendRequest() - { +public class FriendRequest extends RCONMessage { + public FriendRequest() { super(FriendRequest.JSON.class); } @Override - public void handle(Gson gson, JSON json) - { - if (!Messenger.friendRequested(json.user_id, json.target_id)) - { + public void handle(Gson gson, JSON json) { + if (!Messenger.friendRequested(json.user_id, json.target_id)) { Messenger.makeFriendRequest(json.user_id, json.target_id); Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.target_id); - if (target != null) - { + if (target != null) { Habbo from = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (from != null) - { + if (from != null) { target.getClient().sendResponse(new FriendRequestComposer(from)); - } - else - { + } else { final HabboInfo info = HabboManager.getOfflineHabboInfo(json.user_id); - if (info != null) - { - target.getClient().sendResponse(new MessageComposer() - { + if (info != null) { + target.getClient().sendResponse(new MessageComposer() { @Override - public ServerMessage compose() - { + public ServerMessage compose() { this.response.init(Outgoing.FriendRequestComposer); this.response.appendInt(info.getId()); this.response.appendString(info.getUsername()); @@ -58,8 +47,7 @@ public class FriendRequest extends RCONMessage } } - static class JSON - { + static class JSON { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java b/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java index cb7c7f06..c56473e7 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java @@ -8,25 +8,20 @@ import com.google.gson.Gson; import java.sql.*; -public class GiveBadge extends RCONMessage -{ +public class GiveBadge extends RCONMessage { - public GiveBadge() - { + public GiveBadge() { super(GiveBadgeJSON.class); } @Override - public void handle(Gson gson, GiveBadgeJSON json) - { - if (json.user_id == -1) - { + public void handle(Gson gson, GiveBadgeJSON json) { + if (json.user_id == -1) { this.status = RCONMessage.HABBO_NOT_FOUND; return; } - - if (json.badge.isEmpty()) - { + + if (json.badge.isEmpty()) { this.status = RCONMessage.SYSTEM_ERROR; return; } @@ -34,14 +29,11 @@ public class GiveBadge extends RCONMessage Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); String username = json.user_id + ""; - if(habbo != null) - { + if (habbo != null) { username = habbo.getHabboInfo().getUsername(); - for (String badgeCode : json.badge.split(";")) - { - if (habbo.getInventory().getBadgesComponent().hasBadge(badgeCode)) - { + for (String badgeCode : json.badge.split(";")) { + if (habbo.getInventory().getBadgesComponent().hasBadge(badgeCode)) { this.status = RCONMessage.STATUS_ERROR; this.message += Emulator.getTexts().getValue("commands.error.cmd_badge.already_owned").replace("%user%", username).replace("%badge%", badgeCode) + "\r"; continue; @@ -56,32 +48,23 @@ public class GiveBadge extends RCONMessage this.message = Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", username).replace("%badge%", badgeCode); } - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - for (String badgeCode : json.badge.split(";")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + for (String badgeCode : json.badge.split(";")) { boolean found; - try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.id = ? AND badge_code = ? LIMIT 1")) - { + try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.id = ? AND badge_code = ? LIMIT 1")) { statement.setInt(1, json.user_id); statement.setString(2, badgeCode); - try (ResultSet set = statement.executeQuery()) - { + try (ResultSet set = statement.executeQuery()) { found = set.next(); } } - if (found) - { + if (found) { this.status = RCONMessage.STATUS_ERROR; this.message += Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", username).replace("%badge%", badgeCode) + "\r"; - } else - { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges VALUES (null, (SELECT id FROM users WHERE users.id = ? LIMIT 1), 0, ?)", Statement.RETURN_GENERATED_KEYS)) - { + } else { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges VALUES (null, (SELECT id FROM users WHERE users.id = ? LIMIT 1), 0, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, json.user_id); statement.setString(2, badgeCode); statement.execute(); @@ -90,9 +73,7 @@ public class GiveBadge extends RCONMessage this.message = Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", username).replace("%badge%", badgeCode); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); this.status = RCONMessage.STATUS_ERROR; this.message = e.getMessage(); @@ -100,8 +81,7 @@ public class GiveBadge extends RCONMessage } } - static class GiveBadgeJSON - { + static class GiveBadgeJSON { public int user_id = -1; 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 ebbdfa18..2bebfc21 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java @@ -8,43 +8,33 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class GiveCredits extends RCONMessage -{ +public class GiveCredits extends RCONMessage { - public GiveCredits() - { + public GiveCredits() { super(JSONGiveCredits.class); } @Override - public void handle(Gson gson, JSONGiveCredits object) - { + public void handle(Gson gson, JSONGiveCredits object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.giveCredits(object.credits); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) { statement.setInt(1, object.credits); statement.setInt(2, object.user_id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + Emulator.getLogging().logSQLException(e); } this.message = "offline"; } } - static class JSONGiveCredits - { + static class JSONGiveCredits { public int user_id; 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 354b56ae..9c291db1 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java @@ -8,43 +8,33 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class GivePixels extends RCONMessage -{ +public class GivePixels extends RCONMessage { - public GivePixels() - { + public GivePixels() { super(JSONGivePixels.class); } @Override - public void handle(Gson gson, JSONGivePixels object) - { + public void handle(Gson gson, JSONGivePixels object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if(habbo != null) - { + if (habbo != null) { habbo.givePixels(object.pixels); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_currency SET users_currency.amount = users_currency.amount + ? WHERE users_currency.user_id = ? AND users_currency.type = 0")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_currency SET users_currency.amount = users_currency.amount + ? WHERE users_currency.user_id = ? AND users_currency.type = 0")) { statement.setInt(1, object.pixels); statement.setInt(2, object.user_id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + Emulator.getLogging().logSQLException(e); } this.message = "offline"; } } - static class JSONGivePixels - { + static class JSONGivePixels { public int user_id; 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 469543a2..870f5677 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java @@ -8,45 +8,35 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class GivePoints extends RCONMessage -{ +public class GivePoints extends RCONMessage { - public GivePoints() - { + public GivePoints() { super(JSONGivePoints.class); } @Override - public void handle(Gson gson, JSONGivePoints object) - { + public void handle(Gson gson, JSONGivePoints object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.givePoints(object.type, object.points); - } - else - { - 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 = amount + ?")) - { + } else { + 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 = amount + ?")) { statement.setInt(1, object.user_id); statement.setInt(2, object.type); statement.setInt(3, object.points); statement.setInt(4, object.points); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + Emulator.getLogging().logSQLException(e); } this.message = "offline"; } } - static class JSONGivePoints - { + static class JSONGivePoints { public int user_id; 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 b3ecf343..d10fc328 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -8,37 +8,28 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class GiveRespect extends RCONMessage -{ +public class GiveRespect extends RCONMessage { - public GiveRespect() - { + public GiveRespect() { super(JSONGiveRespect.class); } @Override - public void handle(Gson gson, JSONGiveRespect object) - { + public void handle(Gson gson, JSONGiveRespect object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().respectPointsReceived += object.respect_received; habbo.getHabboStats().respectPointsGiven += object.respect_given; habbo.getHabboStats().respectPointsToGive += object.daily_respects; - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_give + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_give + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, object.respect_received); statement.setInt(2, object.respect_given); statement.setInt(3, object.daily_respects); statement.setInt(4, object.user_id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; Emulator.getLogging().logSQLException(e); } @@ -47,8 +38,7 @@ public class GiveRespect extends RCONMessage } } - static class JSONGiveRespect - { + static class JSONGiveRespect { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java b/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java index 5ac8b03a..70989239 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java @@ -9,33 +9,25 @@ import com.google.gson.Gson; import java.util.Map; -public class HotelAlert extends RCONMessage -{ +public class HotelAlert extends RCONMessage { - public HotelAlert() - { + public HotelAlert() { super(JSONHotelAlert.class); } @Override - public void handle(Gson gson, JSONHotelAlert object) - { + public void handle(Gson gson, JSONHotelAlert object) { ServerMessage serverMessage; - if (object.url.isEmpty()) - { + if (object.url.isEmpty()) { serverMessage = new GenericAlertComposer(object.message).compose(); - } - else - { + } else { serverMessage = new StaffAlertWithLinkComposer(object.message, object.url).compose(); } - if (serverMessage != null) - { - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + if (serverMessage != null) { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if(habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().blockStaffAlerts) continue; habbo.getClient().sendResponse(serverMessage); @@ -43,8 +35,7 @@ public class HotelAlert extends RCONMessage } } - static class JSONHotelAlert - { + static class JSONHotelAlert { public String message; 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 4158166e..e8f4d4d6 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/IgnoreUser.java @@ -8,33 +8,24 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class IgnoreUser extends RCONMessage -{ - public IgnoreUser() - { +public class IgnoreUser extends RCONMessage { + public IgnoreUser() { super(JSONIgnoreUser.class); } @Override - public void handle(Gson gson, JSONIgnoreUser object) - { + public void handle(Gson gson, JSONIgnoreUser object) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().ignoreUser(object.target_id); - } - else - { + } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) - { + PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) { statement.setInt(1, object.user_id); statement.setInt(2, object.target_id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } @@ -42,8 +33,7 @@ public class IgnoreUser extends RCONMessage } } - static class JSONIgnoreUser - { + static class JSONIgnoreUser { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/ImageAlertUser.java b/src/main/java/com/eu/habbo/messages/rcon/ImageAlertUser.java index 4cb9d571..12afed25 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ImageAlertUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ImageAlertUser.java @@ -6,61 +6,50 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.google.gson.Gson; import gnu.trove.map.hash.THashMap; -public class ImageAlertUser extends RCONMessage -{ - public ImageAlertUser() - { +public class ImageAlertUser extends RCONMessage { + public ImageAlertUser() { super(ImageAlertUser.JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo == null) - { + if (habbo == null) { this.status = HABBO_NOT_FOUND; return; } THashMap keys = new THashMap<>(); - if (!json.message.isEmpty()) - { + if (!json.message.isEmpty()) { keys.put("message", json.message); } - if (!json.url.isEmpty()) - { + if (!json.url.isEmpty()) { keys.put("linkUrl", json.url); } - if (!json.url_message.isEmpty()) - { + if (!json.url_message.isEmpty()) { keys.put("linkTitle", json.url_message); } - if (!json.title.isEmpty()) - { + if (!json.title.isEmpty()) { keys.put("title", json.title); } - if (!json.display_type.isEmpty()) - { + if (!json.display_type.isEmpty()) { keys.put("display", json.display_type); } - if (!json.image.isEmpty()) - { + if (!json.image.isEmpty()) { keys.put("image", json.image); } habbo.getClient().sendResponse(new BubbleAlertComposer(json.bubble_key, keys)); } - static class JSON - { + static class JSON { public int user_id; 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 d21637a4..a2166745 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java @@ -9,61 +9,50 @@ import gnu.trove.map.hash.THashMap; import java.util.Map; -public class ImageHotelAlert extends RCONMessage -{ - public ImageHotelAlert() - { +public class ImageHotelAlert extends RCONMessage { + public ImageHotelAlert() { super(ImageHotelAlert.JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { THashMap keys = new THashMap<>(); - if (!json.message.isEmpty()) - { + if (!json.message.isEmpty()) { keys.put("message", json.message); } - if (!json.url.isEmpty()) - { + if (!json.url.isEmpty()) { keys.put("linkUrl", json.url); } - if (!json.url_message.isEmpty()) - { + if (!json.url_message.isEmpty()) { keys.put("linkTitle", json.url_message); } - if (!json.title.isEmpty()) - { + if (!json.title.isEmpty()) { keys.put("title", json.title); } - if (!json.display_type.isEmpty()) - { + if (!json.display_type.isEmpty()) { keys.put("display", json.display_type); } - if (!json.image.isEmpty()) - { + if (!json.image.isEmpty()) { keys.put("image", json.image); } ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose(); - for(Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); - if(habbo.getHabboStats().blockStaffAlerts) + if (habbo.getHabboStats().blockStaffAlerts) continue; habbo.getClient().sendResponse(message); } } - static class JSON - { + static class JSON { public String bubble_key = ""; diff --git a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java index 728917cf..a83da553 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java @@ -8,49 +8,35 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class MuteUser extends RCONMessage -{ - public MuteUser() - { +public class MuteUser extends RCONMessage { + public MuteUser() { super(MuteUser.JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { - if (json.duration == 0) - { + if (habbo != null) { + if (json.duration == 0) { habbo.unMute(); - } - else - { + } else { habbo.mute(json.duration); } - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET mute_end_timestamp = ? WHERE user_id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET mute_end_timestamp = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, Emulator.getIntUnixTimestamp() + json.duration); statement.setInt(2, json.user_id); - if (statement.executeUpdate() == 0) - { + if (statement.executeUpdate() == 0) { this.status = HABBO_NOT_FOUND; } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - static class JSON - { + static class JSON { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/ProgressAchievement.java b/src/main/java/com/eu/habbo/messages/rcon/ProgressAchievement.java index 02c4aaeb..69cc6d54 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ProgressAchievement.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ProgressAchievement.java @@ -6,39 +6,29 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -public class ProgressAchievement extends RCONMessage -{ +public class ProgressAchievement extends RCONMessage { - public ProgressAchievement() - { + public ProgressAchievement() { super(ProgressAchievementJSON.class); } @Override - public void handle(Gson gson, ProgressAchievementJSON json) - { + public void handle(Gson gson, ProgressAchievementJSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { + if (habbo != null) { Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(json.achievement_id); - if (achievement != null) - { + if (achievement != null) { AchievementManager.progressAchievement(habbo, achievement, json.progress); - } - else - { + } else { this.status = RCONMessage.STATUS_ERROR; } - } - else - { + } else { this.status = RCONMessage.HABBO_NOT_FOUND; } } - static class ProgressAchievementJSON - { + static class ProgressAchievementJSON { public int user_id; 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 314a3c55..8650144e 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java +++ b/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java @@ -4,8 +4,7 @@ import com.google.gson.*; import java.lang.reflect.Type; -public abstract class RCONMessage -{ +public abstract class RCONMessage { public final static int STATUS_OK = 0; @@ -23,22 +22,17 @@ public abstract class RCONMessage public final Class type; - - public RCONMessage(Class type) - { - this.type = type; - } - - - public abstract void handle(Gson gson, T json); - public int status = STATUS_OK; public String message = ""; - public static class RCONMessageSerializer implements JsonSerializer - { - public JsonElement serialize(final RCONMessage rconMessage, final Type type, final JsonSerializationContext context) - { + public RCONMessage(Class type) { + this.type = type; + } + + public abstract void handle(Gson gson, T json); + + public static class RCONMessageSerializer implements JsonSerializer { + public JsonElement serialize(final RCONMessage rconMessage, final Type type, final JsonSerializationContext context) { JsonObject result = new JsonObject(); result.add("status", new JsonPrimitive(rconMessage.status)); result.add("message", new JsonPrimitive(rconMessage.message)); 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 2e04ff8f..0af46298 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -12,34 +12,28 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class SendGift extends RCONMessage -{ +public class SendGift extends RCONMessage { - public SendGift() - { + public SendGift() { super(SendGiftJSON.class); } @Override - public void handle(Gson gson, SendGiftJSON json) - { - if (json.user_id < 0) - { + public void handle(Gson gson, SendGiftJSON json) { + if (json.user_id < 0) { this.status = RCONMessage.STATUS_ERROR; this.message = Emulator.getTexts().getValue("commands.error.cmd_gift.user_not_found").replace("%username%", json.user_id + ""); return; } - if(json.itemid < 0) - { + if (json.itemid < 0) { this.status = RCONMessage.STATUS_ERROR; this.message = Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"); return; } Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(json.itemid); - if(baseItem == null) - { + if (baseItem == null) { this.status = RCONMessage.STATUS_ERROR; this.message = Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", json.itemid + ""); return; @@ -52,55 +46,44 @@ public class SendGift extends RCONMessage userFound = habbo != null; String username = ""; - if (!userFound) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) - { + if (!userFound) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) { statement.setInt(1, json.user_id); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { username = set.getString("username"); userFound = true; } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } - else - { + } else { username = habbo.getHabboInfo().getUsername(); } - if (!userFound) - { + if (!userFound) { this.status = RCONMessage.STATUS_ERROR; this.message = Emulator.getTexts().getValue("commands.error.cmd_gift.user_not_found").replace("%username%", username); return; } HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); - Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer)Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); + Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t"+ json.message +"\t0\t0"; + extraData += "\t0\t0\t0\t" + json.message + "\t0\t0"; Emulator.getGameEnvironment().getItemManager().createGift(username, giftItem, extraData, 0, 0); this.message = Emulator.getTexts().getValue("commands.succes.cmd_gift").replace("%username%", username).replace("%itemname%", item.getBaseItem().getName()); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new InventoryRefreshComposer()); } } - static class SendGiftJSON - { + static class SendGiftJSON { public int user_id = -1; diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java b/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java index 6b7487b7..25b276ac 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java @@ -8,33 +8,24 @@ import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; import com.google.gson.Gson; -public class SendRoomBundle extends RCONMessage -{ - public SendRoomBundle() - { +public class SendRoomBundle extends RCONMessage { + public SendRoomBundle() { super(JSON.class); } @Override - public void handle(Gson gson, JSON json) - { - if (json.catalog_page > 0 && json.user_id > 0) - { + public void handle(Gson gson, JSON json) { + if (json.catalog_page > 0 && json.user_id > 0) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(json.catalog_page); - if ((page instanceof RoomBundleLayout)) - { - if (habbo != null) - { + if ((page instanceof RoomBundleLayout)) { + if (habbo != null) { ((RoomBundleLayout) page).buyRoom(habbo); - } - else - { + } else { HabboInfo info = HabboManager.getOfflineHabboInfo(json.user_id); - if (info != null) - { + if (info != null) { ((RoomBundleLayout) page).buyRoom(null, json.user_id, info.getUsername()); } } @@ -42,8 +33,7 @@ public class SendRoomBundle extends RCONMessage } } - static class JSON - { + static class JSON { public int user_id; 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 8f8cfe4c..ae8f4d66 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -9,43 +9,32 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class SetMotto extends RCONMessage -{ - public SetMotto() - { +public class SetMotto extends RCONMessage { + public SetMotto() { super(SetMottoJSON.class); } @Override - public void handle(Gson gson, SetMottoJSON json) - { + public void handle(Gson gson, SetMottoJSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboInfo().setMotto(json.motto); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ? WHERE id = ? LIMIT 1")) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ? WHERE id = ? LIMIT 1")) { statement.setString(1, json.motto); statement.setInt(2, json.user_id); statement.execute(); } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logErrorLine(e); } } } - static class SetMottoJSON - { + static class SetMottoJSON { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/SetRank.java b/src/main/java/com/eu/habbo/messages/rcon/SetRank.java index d0213eb8..639f9674 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetRank.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetRank.java @@ -4,23 +4,17 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -public class SetRank extends RCONMessage -{ +public class SetRank extends RCONMessage { - public SetRank() - { + public SetRank() { super(JSONSetRank.class); } @Override - public void handle(Gson gson, JSONSetRank object) - { - try - { + public void handle(Gson gson, JSONSetRank object) { + try { Emulator.getGameEnvironment().getHabboManager().setRank(object.user_id, object.rank); - } - catch (Exception e) - { + } catch (Exception e) { this.status = RCONMessage.SYSTEM_ERROR; this.message = "invalid rank"; return; @@ -30,14 +24,12 @@ public class SetRank extends RCONMessage Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); - if(habbo != null) - { + if (habbo != null) { this.message = "updated online user"; } } - static class JSONSetRank - { + static class JSONSetRank { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/StaffAlert.java b/src/main/java/com/eu/habbo/messages/rcon/StaffAlert.java index cd677a8f..d4948278 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/StaffAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/StaffAlert.java @@ -3,21 +3,17 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.google.gson.Gson; -public class StaffAlert extends RCONMessage -{ - public StaffAlert() - { +public class StaffAlert extends RCONMessage { + public StaffAlert() { super(JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { Emulator.getGameEnvironment().getHabboManager().staffAlert(json.message); } - static class JSON - { + static class JSON { public String message; } diff --git a/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java b/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java index 49aae373..f72e5036 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java @@ -5,59 +5,49 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.google.gson.Gson; -public class StalkUser extends RCONMessage -{ - public StalkUser() - { +public class StalkUser extends RCONMessage { + public StalkUser() { super(StalkUserJSON.class); } @Override - public void handle(Gson gson, StalkUserJSON json) - { + public void handle(Gson gson, StalkUserJSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { + if (habbo != null) { Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.follow_id); - if(target == null) - { + if (target == null) { this.message = Emulator.getTexts().getValue("commands.error.cmd_stalk.not_found").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; } - if(target.getHabboInfo().getCurrentRoom() == null) - { + if (target.getHabboInfo().getCurrentRoom() == null) { this.message = Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; } - if(target.getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) - { + if (target.getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) { this.message = Emulator.getTexts().getValue("commands.generic.cmd_stalk.self").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; } - if(target.getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) - { + if (target.getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { this.message = Emulator.getTexts().getValue("commands.generic.cmd_stalk.same_room").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; } - if (this.status == 0) - { + if (this.status == 0) { habbo.getClient().sendResponse(new ForwardToRoomComposer(target.getHabboInfo().getCurrentRoom().getId())); } } } - static class StalkUserJSON - { + static class StalkUserJSON { public int user_id; 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 c2f241d5..1f190cca 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/TalkUser.java @@ -5,40 +5,38 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -public class TalkUser extends RCONMessage -{ - public TalkUser() - { +public class TalkUser extends RCONMessage { + public TalkUser() { super(JSON.class); } @Override - public void handle(Gson gson, JSON json) - { + public void handle(Gson gson, JSON json) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { + 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; + 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: this.status = STATUS_ERROR; this.message = "Talk type: " + json.type + " not found! Use talk, whisper or shout!"; } - } - else - { + } else { this.status = HABBO_NOT_FOUND; this.message = "offline"; } } - static class JSON - { + static class JSON { public String type; diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateCatalog.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateCatalog.java index e2c63061..7fc897c9 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateCatalog.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateCatalog.java @@ -5,17 +5,14 @@ import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; import com.google.gson.Gson; -public class UpdateCatalog extends RCONMessage -{ +public class UpdateCatalog extends RCONMessage { - public UpdateCatalog() - { + public UpdateCatalog() { super(JSONUpdateCatalog.class); } @Override - public void handle(Gson gson, JSONUpdateCatalog json) - { + public void handle(Gson gson, JSONUpdateCatalog json) { Emulator.getGameEnvironment().getCatalogManager().initialize(); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new CatalogUpdatedComposer()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new CatalogModeComposer(0)); @@ -26,7 +23,6 @@ public class UpdateCatalog extends RCONMessage Emulator.getGameEnvironment().getCraftingManager().reload(); } - static class JSONUpdateCatalog - { + static class JSONUpdateCatalog { } } \ No newline at end of file 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 e96e9fc4..0a8859fe 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -5,83 +5,67 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.MeMenuSettingsComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; -import com.eu.habbo.util.figure.FigureUtil; import com.google.gson.Gson; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class UpdateUser extends RCONMessage -{ +public class UpdateUser extends RCONMessage { - public UpdateUser() - { + public UpdateUser() { super(UpdateUser.JSON.class); } @Override - public void handle(Gson gson, JSON json) - { - if (json.user_id > 0) - { + public void handle(Gson gson, JSON json) { + if (json.user_id > 0) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); - if (habbo != null) - { + if (habbo != null) { habbo.getHabboStats().addAchievementScore(json.achievement_score); - if (json.block_following != -1) - { + if (json.block_following != -1) { habbo.getHabboStats().blockFollowing = json.block_following == 1; } - if (json.block_friendrequests != -1) - { + if (json.block_friendrequests != -1) { habbo.getHabboStats().blockFriendRequests = json.block_friendrequests == 1; } - if (json.block_roominvites != -1) - { + if (json.block_roominvites != -1) { habbo.getHabboStats().blockRoomInvites = json.block_roominvites == 1; } - if (json.old_chat != -1) - { + if (json.old_chat != -1) { habbo.getHabboStats().preferOldChat = json.old_chat == 1; } - if (json.block_camera_follow != -1) - { + if (json.block_camera_follow != -1) { habbo.getHabboStats().blockCameraFollow = json.block_camera_follow == 1; } - if (!json.look.isEmpty()) - { + if (!json.look.isEmpty()) { habbo.getHabboInfo().setLook(json.look); - if(habbo.getClient() != null) { + if (habbo.getClient() != null) { habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo).compose()); } - if (habbo.getHabboInfo().getCurrentRoom() != null) - { + if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); } } habbo.getHabboStats().run(); habbo.getClient().sendResponse(new MeMenuSettingsComposer(habbo)); - } - else - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) - { + } else { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = achievement_score + ? " + - (json.block_following != -1 ? ", block_following = ?" : "") + + (json.block_following != -1 ? ", block_following = ?" : "") + (json.block_friendrequests != -1 ? ", block_friendrequests = ?" : "") + - (json.block_roominvites != -1 ? ", block_roominvites = ?" : "") + - (json.old_chat != -1 ? ", old_chat = ?" : "") + - (json.block_camera_follow != -1 ? ", block_camera_follow = ?" : "") + + (json.block_roominvites != -1 ? ", block_roominvites = ?" : "") + + (json.old_chat != -1 ? ", old_chat = ?" : "") + + (json.block_camera_follow != -1 ? ", block_camera_follow = ?" : "") + " WHERE user_id = ? LIMIT 1")) { @@ -89,28 +73,23 @@ public class UpdateUser extends RCONMessage statement.setInt(index, json.achievement_score); index++; - if (json.block_following != -1) - { + if (json.block_following != -1) { statement.setString(index, json.block_following == 1 ? "1" : "0"); index++; } - if (json.block_friendrequests != -1) - { + if (json.block_friendrequests != -1) { statement.setString(index, json.block_friendrequests == 1 ? "1" : "0"); index++; } - if (json.block_roominvites != -1) - { + if (json.block_roominvites != -1) { statement.setString(index, json.block_roominvites == 1 ? "1" : "0"); index++; } - if (json.old_chat != -1) - { + if (json.old_chat != -1) { statement.setString(index, json.old_chat == 1 ? "1" : "0"); index++; } - if (json.block_camera_follow != -1) - { + if (json.block_camera_follow != -1) { statement.setString(index, json.block_camera_follow == 1 ? "1" : "0"); index++; } @@ -118,26 +97,21 @@ public class UpdateUser extends RCONMessage statement.execute(); } - if (!json.look.isEmpty()) - { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users SET look = ? WHERE id = ? LIMIT 1")) - { + if (!json.look.isEmpty()) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users SET look = ? WHERE id = ? LIMIT 1")) { statement.setString(1, json.look); statement.setInt(2, json.user_id); statement.execute(); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } } - static class JSON - { + static class JSON { public int user_id; diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateWordfilter.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateWordfilter.java index 7d32b462..d1b48081 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateWordfilter.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateWordfilter.java @@ -3,21 +3,17 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.google.gson.Gson; -public class UpdateWordfilter extends RCONMessage -{ +public class UpdateWordfilter extends RCONMessage { - public UpdateWordfilter() - { + public UpdateWordfilter() { super(WordFilterJSON.class); } @Override - public void handle(Gson gson, WordFilterJSON object) - { + public void handle(Gson gson, WordFilterJSON object) { Emulator.getGameEnvironment().getWordFilter().reload(); } - static class WordFilterJSON - { + static class WordFilterJSON { } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/networking/Server.java b/src/main/java/com/eu/habbo/networking/Server.java index f14ac657..76b45b61 100644 --- a/src/main/java/com/eu/habbo/networking/Server.java +++ b/src/main/java/com/eu/habbo/networking/Server.java @@ -12,18 +12,15 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import java.util.concurrent.TimeUnit; -public abstract class Server -{ +public abstract class Server { + protected final ServerBootstrap serverBootstrap; + protected final EventLoopGroup bossGroup; + protected final EventLoopGroup workerGroup; private final String name; private final String host; private final int port; - protected final ServerBootstrap serverBootstrap; - protected final EventLoopGroup bossGroup; - protected final EventLoopGroup workerGroup; - - 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) throws Exception { this.name = name; this.host = host; this.port = port; @@ -33,8 +30,7 @@ public abstract class Server this.serverBootstrap = new ServerBootstrap(); } - public void initializePipeline() - { + public void initializePipeline() { this.serverBootstrap.group(this.bossGroup, this.workerGroup); this.serverBootstrap.channel(NioServerSocketChannel.class); this.serverBootstrap.childOption(ChannelOption.TCP_NODELAY, true); @@ -45,61 +41,48 @@ public abstract class Server this.serverBootstrap.childOption(ChannelOption.ALLOCATOR, new UnpooledByteBufAllocator(false)); } - public void connect() - { + public void connect() { ChannelFuture channelFuture = this.serverBootstrap.bind(this.host, this.port); - while (!channelFuture.isDone()) - {} + while (!channelFuture.isDone()) { + } - if (!channelFuture.isSuccess()) - { + if (!channelFuture.isSuccess()) { Emulator.getLogging().logShutdownLine("Failed to connect to the host (" + this.host + ":" + this.port + ")@" + this.name); System.exit(0); - } - else - { + } else { Emulator.getLogging().logStart("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); } } - public void stop() - { + public void stop() { Emulator.getLogging().logShutdownLine("Stopping " + this.name); - try - { + try { this.workerGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); this.bossGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Exception during " + this.name + " shutdown... HARD STOP"); } Emulator.getLogging().logShutdownLine("GameServer Stopped!"); } - public ServerBootstrap getServerBootstrap() - { + public ServerBootstrap getServerBootstrap() { return this.serverBootstrap; } - public EventLoopGroup getBossGroup() - { + public EventLoopGroup getBossGroup() { return this.bossGroup; } - public EventLoopGroup getWorkerGroup() - { + public EventLoopGroup getWorkerGroup() { return this.workerGroup; } - public String getHost() - { + public String getHost() { return this.host; } - public int getPort() - { + 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 7b40498b..7bcba9ba 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java @@ -9,30 +9,25 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; -public class CameraClient -{ +public class CameraClient { private static final String host = "google.com"; private static final int port = 1232; public static ChannelFuture channelFuture; - private static Channel channel; public static boolean isLoggedIn = false; public static boolean attemptReconnect = true; - + private static Channel channel; private final Bootstrap bootstrap = new Bootstrap(); - public CameraClient() - { + public CameraClient() { EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); this.bootstrap.group(eventLoopGroup); this.bootstrap.channel(NioSocketChannel.class); this.bootstrap.option(ChannelOption.TCP_NODELAY, true); this.bootstrap.option(ChannelOption.SO_KEEPALIVE, false); - this.bootstrap.handler(new ChannelInitializer() - { + this.bootstrap.handler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception - { + public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new CameraDecoder()); ch.pipeline().addLast(new CameraHandler()); } @@ -43,23 +38,18 @@ public class CameraClient this.bootstrap.option(ChannelOption.ALLOCATOR, new UnpooledByteBufAllocator(false)); } - public void connect() - { + public void connect() { CameraClient.channelFuture = this.bootstrap.connect(host, port); - while (!CameraClient.channelFuture.isDone()) - { + while (!CameraClient.channelFuture.isDone()) { } - if (CameraClient.channelFuture.isSuccess()) - { + if (CameraClient.channelFuture.isSuccess()) { CameraClient.attemptReconnect = false; CameraClient.channel = channelFuture.channel(); System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Connected to the Camera Server. Attempting to login..."); this.sendMessage(new CameraLoginComposer()); - } - else - { + } else { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to connect to the Camera Server. Server unreachable."); CameraClient.channel = null; CameraClient.channelFuture.channel().close(); @@ -68,17 +58,12 @@ public class CameraClient } } - public void disconnect() - { - if (channelFuture != null) - { - try - { + public void disconnect() { + if (channelFuture != null) { + try { channelFuture.channel().close().sync(); channelFuture = null; - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } @@ -89,19 +74,14 @@ public class CameraClient System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Disconnected from the camera server."); } - public void sendMessage(CameraOutgoingMessage outgoingMessage) - { - try - { - if (isLoggedIn || outgoingMessage instanceof CameraLoginComposer) - { + public void sendMessage(CameraOutgoingMessage outgoingMessage) { + try { + if (isLoggedIn || outgoingMessage instanceof CameraLoginComposer) { outgoingMessage.compose(channel); channel.write(outgoingMessage.get().copy(), channel.voidPromise()); channel.flush(); } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraDecoder.java b/src/main/java/com/eu/habbo/networking/camera/CameraDecoder.java index 879118e6..7d095616 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraDecoder.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraDecoder.java @@ -6,14 +6,11 @@ import io.netty.handler.codec.ByteToMessageDecoder; import java.util.List; -class CameraDecoder extends ByteToMessageDecoder -{ +class CameraDecoder extends ByteToMessageDecoder { @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List objects) - { + protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List objects) { int readerIndex = byteBuf.readerIndex(); - if(byteBuf.readableBytes() < 6) - { + if (byteBuf.readableBytes() < 6) { byteBuf.readerIndex(readerIndex); return; } @@ -21,8 +18,7 @@ class CameraDecoder extends ByteToMessageDecoder int length = byteBuf.readInt(); byteBuf.readerIndex(readerIndex); - if(byteBuf.readableBytes() < (length)) - { + if (byteBuf.readableBytes() < (length)) { byteBuf.readerIndex(readerIndex); return; } 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 fcd5326c..6d8abb2d 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraHandler.java @@ -5,13 +5,10 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -public class CameraHandler extends ChannelInboundHandlerAdapter -{ +public class CameraHandler extends ChannelInboundHandlerAdapter { @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) - { - try - { + public void channelRead(ChannelHandlerContext ctx, Object msg) { + try { ByteBuf message = (ByteBuf) msg; ((ByteBuf) msg).readerIndex(0); int length = message.readInt(); @@ -20,47 +17,34 @@ public class CameraHandler extends ChannelInboundHandlerAdapter short header = b.readShort(); - try - { + try { CameraPacketHandler.instance().handle(ctx.channel(), header, b); - } - catch (Exception e) - { + } catch (Exception e) { - } - finally - { - try - { + } finally { + try { b.release(); + } catch (Exception e) { } - catch (Exception e) - {} - try - { + try { ((ByteBuf) msg).release(); + } catch (Exception e) { } - catch (Exception e) - {} } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception - { + public void channelInactive(ChannelHandlerContext ctx) throws Exception { CameraClient.attemptReconnect = true; } @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) - { + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { cause.printStackTrace(); } } \ No newline at end of file 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 af910345..4625a2ba 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraIncomingMessage.java @@ -5,75 +5,57 @@ import io.netty.channel.Channel; import java.nio.charset.Charset; -public abstract class CameraIncomingMessage extends CameraMessage -{ - public CameraIncomingMessage(Short header, ByteBuf body) - { +public abstract class CameraIncomingMessage extends CameraMessage { + public CameraIncomingMessage(Short header, ByteBuf body) { super(header); this.buffer.writerIndex(0).writeBytes(body); } - public int readShort() - { + public int readShort() { return this.buffer.readShort(); } - public Integer readInt() - { - try - { + public Integer readInt() { + try { return this.buffer.readInt(); - } - catch (Exception e) - { + } catch (Exception e) { } return 0; } - public boolean readBoolean() - { - try - { + public boolean readBoolean() { + try { return this.buffer.readByte() == 1; - } - catch (Exception e) - { + } catch (Exception e) { } return false; } - - public String readString() - { - try - { + public String readString() { + try { int length = this.readInt(); byte[] data = new byte[length]; this.buffer.readBytes(data); return new String(data); - } - catch (Exception e) - { + } catch (Exception e) { return ""; } } - public String getMessageBody() - { + public String getMessageBody() { String consoleText = this.buffer.toString(Charset.defaultCharset()); for (int i = -1; i < 31; i++) { - consoleText = consoleText.replace(Character.toString((char)i), "[" + i + "]"); + consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); } return consoleText; } - public int bytesAvailable() - { + public int bytesAvailable() { return this.buffer.readableBytes(); } 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 f477d560..fbcceb17 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraMessage.java @@ -3,19 +3,16 @@ package com.eu.habbo.networking.camera; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -public class CameraMessage -{ +public class CameraMessage { protected final short header; protected final ByteBuf buffer; - public CameraMessage(short header) - { + public CameraMessage(short header) { this.header = header; this.buffer = Unpooled.buffer(); } - public short getHeader() - { + 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 cc4e1585..a1b3f083 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraOutgoingMessage.java @@ -7,152 +7,102 @@ import io.netty.channel.Channel; import java.io.IOException; import java.nio.charset.Charset; -public abstract class CameraOutgoingMessage extends CameraMessage -{ +public abstract class CameraOutgoingMessage extends CameraMessage { private final ByteBufOutputStream stream; - public CameraOutgoingMessage(short header) - { + public CameraOutgoingMessage(short header) { super(header); this.stream = new ByteBufOutputStream(this.buffer); - try - { + try { this.stream.writeInt(0); this.stream.writeShort(header); - } - catch (Exception e) - { + } catch (Exception e) { } } - public void appendRawBytes(byte[] bytes) - { - try - { + public void appendRawBytes(byte[] bytes) { + try { this.stream.write(bytes); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendString(String obj) - { - try - { + public void appendString(String obj) { + try { byte[] data = obj.getBytes(); this.stream.writeInt(data.length); this.stream.write(data); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendChar(int obj) - { - try - { + public void appendChar(int obj) { + try { this.stream.writeChar(obj); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendChars(Object obj) - { - try - { + public void appendChars(Object obj) { + try { this.stream.writeChars(obj.toString()); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendInt32(Integer obj) - { - try - { + public void appendInt32(Integer obj) { + try { this.stream.writeInt(obj); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendInt32(Byte obj) - { - try - { + public void appendInt32(Byte obj) { + try { this.stream.writeInt((int) obj); - } - catch (IOException e) - { + } catch (IOException e) { } } - public void appendInt32(Boolean obj) - { - try - { + public void appendInt32(Boolean obj) { + try { this.stream.writeInt(obj ? 1 : 0); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendShort(int obj) - { - try - { + public void appendShort(int obj) { + try { this.stream.writeShort((short) obj); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendByte(Integer b) - { - try - { + public void appendByte(Integer b) { + try { this.stream.writeByte(b); - } - catch(IOException e) - { + } catch (IOException e) { } } - public void appendBoolean(Boolean obj) - { - try - { + public void appendBoolean(Boolean obj) { + try { this.stream.writeBoolean(obj); - } - catch(IOException e) - { + } catch (IOException e) { } } - public CameraOutgoingMessage appendResponse(CameraOutgoingMessage obj) - { - try - { + public CameraOutgoingMessage appendResponse(CameraOutgoingMessage obj) { + try { this.stream.write(obj.get().array()); - } - catch(IOException e) - { + } catch (IOException e) { } return this; } - public String getBodyString() - { + public String getBodyString() { ByteBuf buffer = this.stream.buffer().duplicate(); buffer.setInt(0, buffer.writerIndex() - 4); @@ -160,7 +110,7 @@ public abstract class CameraOutgoingMessage extends CameraMessage String consoleText = buffer.toString(Charset.forName("UTF-8")); for (int i = 0; i < 14; i++) { - consoleText = consoleText.replace(Character.toString((char)i), "[" + i + "]"); + consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); } buffer.discardSomeReadBytes(); @@ -168,8 +118,7 @@ public abstract class CameraOutgoingMessage extends CameraMessage return consoleText; } - public ByteBuf get() - { + public ByteBuf get() { this.buffer.setInt(0, this.buffer.writerIndex() - 4); return this.buffer.copy(); 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 986ea6cf..72dc7c1a 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java @@ -7,23 +7,11 @@ import io.netty.channel.Channel; import java.util.HashMap; -public class CameraPacketHandler -{ +public class CameraPacketHandler { + private static CameraPacketHandler INSTANCE; private final HashMap> packetDefinitions; - private static CameraPacketHandler INSTANCE; - public static CameraPacketHandler instance() - { - if (INSTANCE == null) - { - INSTANCE = new CameraPacketHandler(); - } - - return INSTANCE; - } - - public CameraPacketHandler() - { + public CameraPacketHandler() { this.packetDefinitions = new HashMap<>(); this.packetDefinitions.put((short) 1, CameraLoginStatusEvent.class); @@ -33,20 +21,23 @@ public class CameraPacketHandler this.packetDefinitions.put((short) 5, CameraAuthenticationTicketEvent.class); } - public void handle(Channel channel, short i, ByteBuf ii) - { + public static CameraPacketHandler instance() { + if (INSTANCE == null) { + INSTANCE = new CameraPacketHandler(); + } + + return INSTANCE; + } + + public void handle(Channel channel, short i, ByteBuf ii) { Class declaredClass = this.packetDefinitions.get(i); - if(declaredClass != null) - { - try - { + if (declaredClass != null) { + try { CameraIncomingMessage message = declaredClass.getDeclaredConstructor(new Class[]{Short.class, ByteBuf.class}).newInstance(i, ii); message.handle(channel); message.buffer.release(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/CameraOutgoingHeaders.java b/src/main/java/com/eu/habbo/networking/camera/messages/CameraOutgoingHeaders.java index f8b08810..e9892031 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/CameraOutgoingHeaders.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/CameraOutgoingHeaders.java @@ -1,7 +1,6 @@ package com.eu.habbo.networking.camera.messages; -public class CameraOutgoingHeaders -{ +public class CameraOutgoingHeaders { public final static short LoginComposer = 1; public final static short RenderImageComposer = 2; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraAuthenticationTicketEvent.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraAuthenticationTicketEvent.java index e2b0a18f..08f10147 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraAuthenticationTicketEvent.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraAuthenticationTicketEvent.java @@ -5,20 +5,16 @@ import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -public class CameraAuthenticationTicketEvent extends CameraIncomingMessage -{ - public CameraAuthenticationTicketEvent(Short header, ByteBuf body) - { +public class CameraAuthenticationTicketEvent extends CameraIncomingMessage { + public CameraAuthenticationTicketEvent(Short header, ByteBuf body) { super(header, body); } @Override - public void handle(Channel client) throws Exception - { + public void handle(Channel client) throws Exception { String ticket = this.readString(); - if (ticket.startsWith("FASTFOOD")) - { + if (ticket.startsWith("FASTFOOD")) { BaseJumpLoadGameComposer.FASTFOOD_KEY = ticket; } } 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 24a480ec..467e9014 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 @@ -6,8 +6,7 @@ import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -public class CameraLoginStatusEvent extends CameraIncomingMessage -{ +public class CameraLoginStatusEvent extends CameraIncomingMessage { public final static int LOGIN_OK = 0; public final static int LOGIN_ERROR = 1; public final static int NO_ACCOUNT = 2; @@ -16,38 +15,25 @@ public class CameraLoginStatusEvent extends CameraIncomingMessage public final static int OLD_BUILD = 5; public final static int NO_CAMERA_SUBSCRIPTION = 6; - public CameraLoginStatusEvent(Short header, ByteBuf body) - { + public CameraLoginStatusEvent(Short header, ByteBuf body) { super(header, body); } @Override - public void handle(Channel client) throws Exception - { + public void handle(Channel client) throws Exception { int status = this.readInt(); - if (status == LOGIN_ERROR) - { + if (status == LOGIN_ERROR) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to login to Camera Server: Incorrect Details"); - } - else if (status == NO_ACCOUNT) - { + } else if (status == NO_ACCOUNT) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to login to Camera Server: No Account Found. Register for free on the Arcturus Forums! Visit http://arcturus.pw/"); - } - else if (status == BANNED) - { + } else if (status == BANNED) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Sorry but you seem to be banned from the Arcturus forums and therefor cant use the Camera Server :'("); - } - else if (status == ALREADY_LOGGED_IN) - { + } else if (status == ALREADY_LOGGED_IN) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] You seem to be already connected to the Camera Server"); - } - else if (status == OLD_BUILD) - { + } else if (status == OLD_BUILD) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] This version of Arcturus Emulator is no longer supported by the Camera Server. Upgrade your emulator."); - } - else if (status == NO_CAMERA_SUBSCRIPTION) - { + } else if (status == NO_CAMERA_SUBSCRIPTION) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] You don't have a Camera Subscription and therefor cannot use the camera!"); System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Please consider making a donation to keep this project going. The emulator can be used free of charge!"); System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); @@ -57,13 +43,10 @@ public class CameraLoginStatusEvent extends CameraIncomingMessage System.out.println("\t\t\t\t Please Consider getting a subscription. Regards: The General"); } - if (status == LOGIN_OK) - { + if (status == LOGIN_OK) { CameraClient.isLoggedIn = true; System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Succesfully connected to the Arcturus Camera Server!"); - } - else - { + } else { CameraClient.attemptReconnect = false; } } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraResultURLEvent.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraResultURLEvent.java index 1948e8a0..61e0f012 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraResultURLEvent.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraResultURLEvent.java @@ -4,30 +4,25 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.camera.CameraURLComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -public class CameraResultURLEvent extends CameraIncomingMessage -{ +public class CameraResultURLEvent extends CameraIncomingMessage { public final static int STATUS_OK = 0; public final static int STATUS_ERROR = 1; - public CameraResultURLEvent(Short header, ByteBuf body) - { + public CameraResultURLEvent(Short header, ByteBuf body) { super(header, body); } @Override - public void handle(Channel client) throws Exception - { + public void handle(Channel client) throws Exception { int userId = this.readInt(); int status = this.readInt(); String URL = this.readString(); - if (!Emulator.getConfig().getBoolean("camera.use.https", true)) - { + if (!Emulator.getConfig().getBoolean("camera.use.https", true)) { URL = URL.replace("https://", "http://"); } @@ -36,10 +31,8 @@ public class CameraResultURLEvent extends CameraIncomingMessage Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (status == STATUS_ERROR) - { - if (habbo != null) - { + if (status == STATUS_ERROR) { + if (habbo != null) { habbo.getHabboInfo().setPhotoTimestamp(0); habbo.getHabboInfo().setPhotoJSON(""); habbo.getHabboInfo().setPhotoURL(""); @@ -49,12 +42,9 @@ public class CameraResultURLEvent extends CameraIncomingMessage } } - if (status == STATUS_OK) - { - if (habbo != null) - { - if (timestamp == habbo.getHabboInfo().getPhotoTimestamp()) - { + if (status == STATUS_OK) { + if (habbo != null) { + if (timestamp == habbo.getHabboInfo().getPhotoTimestamp()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"), 1); habbo.getClient().sendResponse(new CameraURLComposer(URL)); habbo.getHabboInfo().setPhotoJSON(habbo.getHabboInfo().getPhotoJSON().replace("%room_id%", roomId + "").replace("%url%", URL)); diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraRoomThumbnailGeneratedEvent.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraRoomThumbnailGeneratedEvent.java index caa69b04..96783a2d 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraRoomThumbnailGeneratedEvent.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraRoomThumbnailGeneratedEvent.java @@ -7,22 +7,18 @@ import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -public class CameraRoomThumbnailGeneratedEvent extends CameraIncomingMessage -{ - public CameraRoomThumbnailGeneratedEvent(Short header, ByteBuf body) - { +public class CameraRoomThumbnailGeneratedEvent extends CameraIncomingMessage { + public CameraRoomThumbnailGeneratedEvent(Short header, ByteBuf body) { super(header, body); } @Override - public void handle(Channel client) throws Exception - { + public void handle(Channel client) throws Exception { int userId = this.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) - { + if (habbo != null) { habbo.getClient().sendResponse(new CameraRoomThumbnailSavedComposer()); } } 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 170fea01..d0d0504c 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 @@ -7,35 +7,26 @@ import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -public class CameraUpdateNotification extends CameraIncomingMessage -{ - public CameraUpdateNotification(Short header, ByteBuf body) - { +public class CameraUpdateNotification extends CameraIncomingMessage { + public CameraUpdateNotification(Short header, ByteBuf body) { super(header, body); } @Override - public void handle(Channel client) throws Exception - { + public void handle(Channel client) throws Exception { boolean alert = this.readBoolean(); String message = this.readString(); int type = this.readInt(); - if (type == 0) - { + if (type == 0) { System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] " + message); - } - else if (type == 1) - { + } else if (type == 1) { System.out.println("[" + Logging.ANSI_YELLOW + "CAMERA" + Logging.ANSI_RESET + "] " + message); - } - else if (type == 2) - { + } else if (type == 2) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] " + message); } - if (alert) - { + if (alert) { Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new GenericAlertComposer(message).compose()); } } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraLoginComposer.java b/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraLoginComposer.java index 6101c5d9..f8b97a0f 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraLoginComposer.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraLoginComposer.java @@ -5,16 +5,13 @@ import com.eu.habbo.networking.camera.CameraOutgoingMessage; import com.eu.habbo.networking.camera.messages.CameraOutgoingHeaders; import io.netty.channel.Channel; -public class CameraLoginComposer extends CameraOutgoingMessage -{ - public CameraLoginComposer() - { +public class CameraLoginComposer extends CameraOutgoingMessage { + public CameraLoginComposer() { super(CameraOutgoingHeaders.LoginComposer); } @Override - public void compose(Channel channel) - { + public void compose(Channel channel) { this.appendString(Emulator.getConfig().getValue("username").trim()); this.appendString(Emulator.getConfig().getValue("password").trim()); this.appendString(Emulator.version); diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraRenderImageComposer.java b/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraRenderImageComposer.java index e5eb64c8..07c10871 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraRenderImageComposer.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/outgoing/CameraRenderImageComposer.java @@ -5,17 +5,15 @@ import com.eu.habbo.networking.camera.CameraOutgoingMessage; import com.eu.habbo.networking.camera.messages.CameraOutgoingHeaders; import io.netty.channel.Channel; -public class CameraRenderImageComposer extends CameraOutgoingMessage -{ - final int userId; +public class CameraRenderImageComposer extends CameraOutgoingMessage { public final int timestamp; + final int userId; final int backgroundColor; final int width; final int height; final String JSON; - public CameraRenderImageComposer(int userId, int backgroundColor, int width, int height, String json) - { + public CameraRenderImageComposer(int userId, int backgroundColor, int width, int height, String json) { super(CameraOutgoingHeaders.RenderImageComposer); this.userId = userId; @@ -27,8 +25,7 @@ public class CameraRenderImageComposer extends CameraOutgoingMessage } @Override - public void compose(Channel channel) - { + public void compose(Channel channel) { this.appendInt32(this.userId); this.appendInt32(this.timestamp); this.appendInt32(this.backgroundColor); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/GameByteDecoder.java b/src/main/java/com/eu/habbo/networking/gameserver/GameByteDecoder.java index cafaaf54..d6f096d2 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameByteDecoder.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameByteDecoder.java @@ -9,16 +9,13 @@ import io.netty.util.CharsetUtil; import java.util.List; -public class GameByteDecoder extends ByteToMessageDecoder -{ +public class GameByteDecoder extends ByteToMessageDecoder { @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) - { + protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { in.markReaderIndex(); //4 bytes length + 2 bytes header - if (in.readableBytes() < 6) - { + if (in.readableBytes() < 6) { in.resetReaderIndex(); return; } @@ -30,8 +27,7 @@ public class GameByteDecoder extends ByteToMessageDecoder //} - if (length == 1014001516) - { + if (length == 1014001516) { in.resetReaderIndex(); //in.readBytes(in.readableBytes()); @@ -46,8 +42,7 @@ public class GameByteDecoder extends ByteToMessageDecoder return; } - if (in.readableBytes() < length || length < 0) - { + if (in.readableBytes() < length || length < 0) { in.resetReaderIndex(); return; } diff --git a/src/main/java/com/eu/habbo/networking/gameserver/GameMessageHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/GameMessageHandler.java index eef09b5d..94b598b6 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameMessageHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameMessageHandler.java @@ -1,7 +1,6 @@ package com.eu.habbo.networking.gameserver; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.threading.runnables.ChannelReadHandler; import io.netty.channel.ChannelHandler; @@ -11,58 +10,45 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import java.io.IOException; @ChannelHandler.Sharable -public class GameMessageHandler extends ChannelInboundHandlerAdapter -{ +public class GameMessageHandler extends ChannelInboundHandlerAdapter { @Override - public void channelRegistered(ChannelHandlerContext ctx) - { - if (!Emulator.getGameServer().getGameClientManager().addClient(ctx)) - { + public void channelRegistered(ChannelHandlerContext ctx) { + if (!Emulator.getGameServer().getGameClientManager().addClient(ctx)) { ctx.channel().close(); } } @Override - public void channelUnregistered(ChannelHandlerContext ctx) - { + public void channelUnregistered(ChannelHandlerContext ctx) { ctx.channel().close(); } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception - { - try - { + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + try { ChannelReadHandler handler = new ChannelReadHandler(ctx, msg); - if (PacketManager.MULTI_THREADED_PACKET_HANDLING) - { + if (PacketManager.MULTI_THREADED_PACKET_HANDLING) { Emulator.getThreading().run(handler); return; } handler.run(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception - { + public void channelInactive(ChannelHandlerContext ctx) throws Exception { ctx.channel().close(); } @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) - { - if (cause instanceof Exception) - { - if (!(cause instanceof IOException)) - { - // cause.printStackTrace(Logging.getErrorsRuntimeWriter()); + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + if (cause instanceof Exception) { + if (!(cause instanceof IOException)) { + // cause.printStackTrace(Logging.getErrorsRuntimeWriter()); } } 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 2586f29b..e782887a 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java @@ -8,28 +8,23 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; import io.netty.handler.logging.LoggingHandler; -public class GameServer extends Server -{ +public class GameServer extends Server { private final PacketManager packetManager; private final GameClientManager gameClientManager; - public GameServer(String host, int port) throws Exception - { + public GameServer(String host, int port) throws Exception { super("Game Server", host, port, Emulator.getConfig().getInt("io.bossgroup.threads"), Emulator.getConfig().getInt("io.workergroup.threads")); this.packetManager = new PacketManager(); this.gameClientManager = new GameClientManager(); } @Override - public void initializePipeline() - { + public void initializePipeline() { super.initializePipeline(); - this.serverBootstrap.childHandler(new ChannelInitializer() - { + this.serverBootstrap.childHandler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception - { + public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("logger", new LoggingHandler()); ch.pipeline().addLast("bytesDecoder", new GameByteDecoder()); ch.pipeline().addLast(new GameMessageHandler()); @@ -37,13 +32,11 @@ public class GameServer extends Server }); } - public PacketManager getPacketManager() - { + public PacketManager getPacketManager() { return this.packetManager; } - public GameClientManager getGameClientManager() - { + public GameClientManager getGameClientManager() { return this.gameClientManager; } } 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 0fdc0329..a17c100e 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java @@ -15,16 +15,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class RCONServer extends Server -{ +public class RCONServer extends Server { + private final THashMap> messages; + private final GsonBuilder gsonBuilder; List allowedAdresses = new ArrayList<>(); - private final THashMap> messages; - - private final GsonBuilder gsonBuilder; - - public RCONServer(String host, int port) throws Exception - { + public RCONServer(String host, int port) throws Exception { super("RCON Server", host, port, 1, 2); this.messages = new THashMap<>(); @@ -32,98 +28,85 @@ public class RCONServer extends Server this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.registerTypeAdapter(RCONMessage.class, new RCONMessage.RCONMessageSerializer()); - this.addRCONMessage("alertuser", AlertUser.class); - this.addRCONMessage("disconnect", DisconnectUser.class); - this.addRCONMessage("forwarduser", ForwardUser.class); - this.addRCONMessage("givebadge", GiveBadge.class); - this.addRCONMessage("givecredits", GiveCredits.class); - this.addRCONMessage("givepixels", GivePixels.class); - this.addRCONMessage("givepoints", GivePoints.class); - this.addRCONMessage("hotelalert", HotelAlert.class); - this.addRCONMessage("sendgift", SendGift.class); - this.addRCONMessage("sendroombundle", SendRoomBundle.class); - this.addRCONMessage("setrank", SetRank.class); - this.addRCONMessage("updatewordfilter", UpdateWordfilter.class); - this.addRCONMessage("updatecatalog", UpdateCatalog.class); - this.addRCONMessage("executecommand", ExecuteCommand.class); - this.addRCONMessage("progressachievement", ProgressAchievement.class); - this.addRCONMessage("updateuser", UpdateUser.class); - this.addRCONMessage("friendrequest", FriendRequest.class); - this.addRCONMessage("imagehotelalert", ImageHotelAlert.class); - this.addRCONMessage("imagealertuser", ImageAlertUser.class); - this.addRCONMessage("stalkuser", StalkUser.class); - this.addRCONMessage("staffalert", StaffAlert.class); - this.addRCONMessage("modticket", CreateModToolTicket.class); - this.addRCONMessage("talkuser", TalkUser.class); - this.addRCONMessage("changeroomowner", ChangeRoomOwner.class); - this.addRCONMessage("muteuser", MuteUser.class); - this.addRCONMessage("giverespect", GiveRespect.class); - this.addRCONMessage("ignoreuser", IgnoreUser.class); - this.addRCONMessage("setmotto", SetMotto.class); + this.addRCONMessage("alertuser", AlertUser.class); + this.addRCONMessage("disconnect", DisconnectUser.class); + this.addRCONMessage("forwarduser", ForwardUser.class); + this.addRCONMessage("givebadge", GiveBadge.class); + this.addRCONMessage("givecredits", GiveCredits.class); + this.addRCONMessage("givepixels", GivePixels.class); + this.addRCONMessage("givepoints", GivePoints.class); + this.addRCONMessage("hotelalert", HotelAlert.class); + this.addRCONMessage("sendgift", SendGift.class); + this.addRCONMessage("sendroombundle", SendRoomBundle.class); + this.addRCONMessage("setrank", SetRank.class); + this.addRCONMessage("updatewordfilter", UpdateWordfilter.class); + this.addRCONMessage("updatecatalog", UpdateCatalog.class); + this.addRCONMessage("executecommand", ExecuteCommand.class); + this.addRCONMessage("progressachievement", ProgressAchievement.class); + this.addRCONMessage("updateuser", UpdateUser.class); + this.addRCONMessage("friendrequest", FriendRequest.class); + this.addRCONMessage("imagehotelalert", ImageHotelAlert.class); + this.addRCONMessage("imagealertuser", ImageAlertUser.class); + this.addRCONMessage("stalkuser", StalkUser.class); + this.addRCONMessage("staffalert", StaffAlert.class); + this.addRCONMessage("modticket", CreateModToolTicket.class); + this.addRCONMessage("talkuser", TalkUser.class); + this.addRCONMessage("changeroomowner", ChangeRoomOwner.class); + this.addRCONMessage("muteuser", MuteUser.class); + this.addRCONMessage("giverespect", GiveRespect.class); + this.addRCONMessage("ignoreuser", IgnoreUser.class); + this.addRCONMessage("setmotto", SetMotto.class); Collections.addAll(this.allowedAdresses, Emulator.getConfig().getValue("rcon.allowed", "127.0.0.1").split(";")); } @Override - public void initializePipeline() - { + public void initializePipeline() { super.initializePipeline(); - this.serverBootstrap.childHandler(new ChannelInitializer() - { + this.serverBootstrap.childHandler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception - { + public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new RCONServerHandler()); } }); } - public void addRCONMessage(String key, Class clazz) - { + public void addRCONMessage(String key, Class clazz) { this.messages.put(key, clazz); } - public String handle(ChannelHandlerContext ctx, String key, String body) throws Exception - { + public String handle(ChannelHandlerContext ctx, String key, String body) throws Exception { Class message = this.messages.get(key.replace("_", "").toLowerCase()); String result; - if(message != null) - { - try - { + if (message != null) { + try { RCONMessage rcon = message.getDeclaredConstructor().newInstance(); Gson gson = this.gsonBuilder.create(); rcon.handle(gson, gson.fromJson(body, rcon.type)); System.out.print("[" + Logging.ANSI_BLUE + "RCON" + Logging.ANSI_RESET + "] Handled RCON Message: " + message.getSimpleName()); result = gson.toJson(rcon, RCONMessage.class); - if (Emulator.debugging) - { + if (Emulator.debugging) { System.out.print(" [" + Logging.ANSI_BLUE + "DATA" + Logging.ANSI_RESET + "]" + body + "[" + Logging.ANSI_BLUE + "RESULT" + Logging.ANSI_RESET + "]" + result); } System.out.println(""); return result; - } - catch (Exception ex) - { + } catch (Exception ex) { Emulator.getLogging().logErrorLine(ex); Emulator.getLogging().logPacketError("[RCON] Failed to handle RCONMessage: " + message.getName() + ex.getMessage() + " by: " + ctx.channel().remoteAddress()); } - } - else - { + } else { Emulator.getLogging().logPacketError("[RCON] Couldn't find: " + key); } throw new ArrayIndexOutOfBoundsException("Unhandled RCON Message"); } - public List getCommands() - { + public List getCommands() { return new ArrayList<>(this.messages.keySet()); } } 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 678f2cf1..f790cc7a 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java @@ -11,17 +11,13 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -public class RCONServerHandler extends ChannelInboundHandlerAdapter -{ +public class RCONServerHandler extends ChannelInboundHandlerAdapter { @Override - public void channelRegistered(ChannelHandlerContext ctx) throws Exception - { + public void channelRegistered(ChannelHandlerContext ctx) throws Exception { String adress = ctx.channel().remoteAddress().toString().split(":")[0].replace("/", ""); - for(String s : Emulator.getRconServer().allowedAdresses) - { - if(s.equalsIgnoreCase(adress)) - { + for (String s : Emulator.getRconServer().allowedAdresses) { + if (s.equalsIgnoreCase(adress)) { return; } } @@ -31,8 +27,7 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception - { + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf data = (ByteBuf) msg; byte[] d = new byte[data.readableBytes()]; @@ -41,18 +36,13 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter Gson gson = new Gson(); String response = "ERROR"; String key = ""; - try - { + try { JsonObject object = gson.fromJson(message, JsonObject.class); key = object.get("key").getAsString(); response = Emulator.getRconServer().handle(ctx, key, object.get("data").toString()); - } - catch (ArrayIndexOutOfBoundsException e) - { + } catch (ArrayIndexOutOfBoundsException e) { System.out.println("[" + Logging.ANSI_RED + "RCON" + Logging.ANSI_RESET + "] Unknown RCON Message: " + key); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logDebugLine("[RCON] Not JSON: " + message); e.printStackTrace(); } diff --git a/src/main/java/com/eu/habbo/plugin/Event.java b/src/main/java/com/eu/habbo/plugin/Event.java index b1de758f..91da0f36 100644 --- a/src/main/java/com/eu/habbo/plugin/Event.java +++ b/src/main/java/com/eu/habbo/plugin/Event.java @@ -1,16 +1,13 @@ package com.eu.habbo.plugin; -public abstract class Event -{ +public abstract class Event { private boolean cancelled = false; - public void setCancelled(boolean cancelled) - { - this.cancelled = cancelled; - } - - public boolean isCancelled() - { + public boolean isCancelled() { return this.cancelled; } + + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } } diff --git a/src/main/java/com/eu/habbo/plugin/EventListener.java b/src/main/java/com/eu/habbo/plugin/EventListener.java index 381a9498..f5b59954 100644 --- a/src/main/java/com/eu/habbo/plugin/EventListener.java +++ b/src/main/java/com/eu/habbo/plugin/EventListener.java @@ -1,5 +1,4 @@ package com.eu.habbo.plugin; -public interface EventListener -{ +public interface EventListener { } diff --git a/src/main/java/com/eu/habbo/plugin/EventPriority.java b/src/main/java/com/eu/habbo/plugin/EventPriority.java index 34418704..62488f50 100644 --- a/src/main/java/com/eu/habbo/plugin/EventPriority.java +++ b/src/main/java/com/eu/habbo/plugin/EventPriority.java @@ -1,7 +1,6 @@ package com.eu.habbo.plugin; -public enum EventPriority -{ +public enum EventPriority { LOWEST(0), @@ -17,13 +16,11 @@ public enum EventPriority private final int slot; - EventPriority(int slot) - { + EventPriority(int slot) { this.slot = slot; } - public int getSlot() - { + public int getSlot() { return this.slot; } } diff --git a/src/main/java/com/eu/habbo/plugin/HabboPlugin.java b/src/main/java/com/eu/habbo/plugin/HabboPlugin.java index 05147429..56d2da17 100644 --- a/src/main/java/com/eu/habbo/plugin/HabboPlugin.java +++ b/src/main/java/com/eu/habbo/plugin/HabboPlugin.java @@ -8,25 +8,20 @@ import java.io.InputStream; import java.lang.reflect.Method; import java.net.URLClassLoader; -public abstract class HabboPlugin -{ +public abstract class HabboPlugin { public final THashMap, THashSet> registeredEvents = new THashMap<>(); public HabboPluginConfiguration configuration; + public URLClassLoader classLoader; + public InputStream stream; public abstract void onEnable() throws Exception; public abstract void onDisable() throws Exception; - public boolean isRegistered(Class clazz) - { + public boolean isRegistered(Class clazz) { return this.registeredEvents.containsKey(clazz); } - public abstract boolean hasPermission(Habbo habbo, String key); - - public URLClassLoader classLoader; - - public InputStream stream; } diff --git a/src/main/java/com/eu/habbo/plugin/HabboPluginConfiguration.java b/src/main/java/com/eu/habbo/plugin/HabboPluginConfiguration.java index e5795596..621845af 100644 --- a/src/main/java/com/eu/habbo/plugin/HabboPluginConfiguration.java +++ b/src/main/java/com/eu/habbo/plugin/HabboPluginConfiguration.java @@ -1,7 +1,6 @@ package com.eu.habbo.plugin; -public class HabboPluginConfiguration -{ +public class HabboPluginConfiguration { public String name; public String author; public String main; diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index cdae96d8..9391fcb3 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -7,7 +7,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.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.games.tag.TagGame; import com.eu.habbo.habbohotel.items.ItemManager; @@ -36,7 +35,6 @@ import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; import java.io.File; -import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; @@ -47,280 +45,12 @@ import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Objects; -public class PluginManager -{ +public class PluginManager { private final THashSet plugins = new THashSet<>(); - private final THashSet methods = new THashSet<>(); - - public void loadPlugins() - { - this.disposePlugins(); - - File loc = new File("plugins"); - - if (!loc.exists()) - { - if (loc.mkdirs()) - { - Emulator.getLogging().logStart("Created plugins directory!"); - } - } - - for (File file : Objects.requireNonNull(loc.listFiles(file -> file.getPath().toLowerCase().endsWith(".jar")))) - { - URLClassLoader urlClassLoader; - InputStream stream; - try - { - urlClassLoader = URLClassLoader.newInstance(new URL[]{file.toURI().toURL()}); - stream = urlClassLoader.getResourceAsStream("plugin.json"); - - if (stream == null) - { - throw new RuntimeException("Invalid Jar! Missing plugin.json in: " + file.getName()); - } - - byte[] content = new byte[stream.available()]; - - if (stream.read(content) > 0) - { - String body = new String(content); - - Gson gson = new GsonBuilder().create(); - HabboPluginConfiguration pluginConfigurtion = gson.fromJson(body, HabboPluginConfiguration.class); - - try - { - Class clazz = urlClassLoader.loadClass(pluginConfigurtion.main); - Class stackClazz = clazz.asSubclass(HabboPlugin.class); - Constructor constructor = stackClazz.getConstructor(); - HabboPlugin plugin = constructor.newInstance(); - plugin.configuration = pluginConfigurtion; - plugin.classLoader = urlClassLoader; - plugin.stream = stream; - this.plugins.add(plugin); - plugin.onEnable(); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine("Could not load plugin " + pluginConfigurtion.name + "!"); - Emulator.getLogging().logErrorLine(e); - } - } - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine(e); - } - } - } - - - public void registerEvents(HabboPlugin plugin, EventListener listener) - { - synchronized (plugin.registeredEvents) - { - Method[] methods = listener.getClass().getMethods(); - - for (Method method : methods) - { - if (method.getAnnotation(EventHandler.class) != null) - { - if (method.getParameterTypes().length == 1) - { - if(Event.class.isAssignableFrom(method.getParameterTypes()[0])) - { - final Class eventClass = method.getParameterTypes()[0]; - - if (!plugin.registeredEvents.containsKey(eventClass.asSubclass(Event.class))) - { - plugin.registeredEvents.put(eventClass.asSubclass(Event.class), new THashSet<>()); - } - - plugin.registeredEvents.get(eventClass.asSubclass(Event.class)).add(method); - } - } - } - } - } - } - - - public Event fireEvent(Event event) - { - for (Method method : this.methods) - { - if(method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(event.getClass())) - { - try - { - method.invoke(null, event); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine("Could not pass default event " + event.getClass().getName() + " to " + method.getClass().getName() + ":" + method.getName()); - Emulator.getLogging().logErrorLine(e); - } - } - } - - TObjectHashIterator iterator = this.plugins.iterator(); - while (iterator.hasNext()) - { - try - { - HabboPlugin plugin = iterator.next(); - - if (plugin != null) - { - THashSet methods = plugin.registeredEvents.get(event.getClass().asSubclass(Event.class)); - - if(methods != null) - { - for(Method method : methods) - { - try - { - method.invoke(plugin, event); - } - catch (Exception e) - { - Emulator.getLogging().logErrorLine("Could not pass event " + event.getClass().getName() + " to " + plugin.configuration.name); - Emulator.getLogging().logErrorLine(e); - } - } - } - } - } - catch (NoSuchElementException e) - { - break; - } - } - - return event; - } - - - public boolean isRegistered(Class clazz, boolean pluginsOnly) - { - TObjectHashIterator iterator = this.plugins.iterator(); - while (iterator.hasNext()) - { - try - { - HabboPlugin plugin = iterator.next(); - if(plugin.isRegistered(clazz)) - return true; - } - catch (NoSuchElementException e) - { - break; - } - } - - if(!pluginsOnly) - { - for (Method method : this.methods) - { - if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(clazz)) - { - return true; - } - } - } - - return false; - } - - - public void dispose() - { - this.disposePlugins(); - - Emulator.getLogging().logShutdownLine("Disposed Plugin Manager!"); - } - - private void disposePlugins() - { - TObjectHashIterator iterator = this.plugins.iterator(); - while (iterator.hasNext()) - { - try - { - HabboPlugin p = iterator.next(); - - if (p != null) - { - - try - { - p.onDisable(); - p.stream.close(); - p.classLoader.close(); - } - catch (IOException e) - { - Emulator.getLogging().logErrorLine(e); - } - catch (Exception ex) - { - Emulator.getLogging().logErrorLine("[CRITICAL][PLUGIN] Failed to disable " + p.configuration.name + " caused by: " + ex.getLocalizedMessage()); - Emulator.getLogging().logErrorLine(ex); - } - } - } - catch (NoSuchElementException e) - { - break; - } - } - this.plugins.clear(); - } - - public void reload() - { - long millis = System.currentTimeMillis(); - - this.methods.clear(); - - this.loadPlugins(); - - Emulator.getLogging().logStart("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); - - this.registerDefaultEvents(); - } - - private void registerDefaultEvents() - { - try - { - this.methods.add(RoomTrashing.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); - this.methods.add(Easter.class.getMethod("onUserChangeMotto", UserSavedMottoEvent.class)); - this.methods.add(TagGame.class.getMethod("onUserLookAtPoint", RoomUnitLookAtPointEvent.class)); - this.methods.add(TagGame.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); - this.methods.add(FreezeGame.class.getMethod("onConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); - this.methods.add(PacketManager.class.getMethod("onConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); - this.methods.add(InteractionFootballGate.class.getMethod("onUserDisconnectEvent", UserDisconnectEvent.class)); - this.methods.add(InteractionFootballGate.class.getMethod("onUserExitRoomEvent", UserExitRoomEvent.class)); - this.methods.add(InteractionFootballGate.class.getMethod("onUserSavedLookEvent", UserSavedLookEvent.class)); - this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); - } - catch (NoSuchMethodException e) - { - Emulator.getLogging().logStart("Failed to define default events!"); - Emulator.getLogging().logErrorLine(e); - } - } - - public THashSet getPlugins() - { - return this.plugins; - } + private final THashSet methods = new THashSet<>(); @EventHandler - public static void globalOnConfigurationUpdated(EmulatorConfigUpdatedEvent event) - { + public static void globalOnConfigurationUpdated(EmulatorConfigUpdatedEvent event) { ItemManager.RECYCLER_ENABLED = Emulator.getConfig().getBoolean("hotel.catalog.recycler.enabled"); MarketPlace.MARKETPLACE_ENABLED = Emulator.getConfig().getBoolean("hotel.marketplace.enabled"); MarketPlace.MARKETPLACE_CURRENCY = Emulator.getConfig().getInt("hotel.marketplace.currency"); @@ -363,14 +93,11 @@ public class PluginManager String[] bannedBubbles = Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";"); RoomChatMessage.BANNED_BUBBLES = new int[bannedBubbles.length]; - for (int i = 0; i < RoomChatMessage.BANNED_BUBBLES.length; i++) - { - try - { + for (int i = 0; i < RoomChatMessage.BANNED_BUBBLES.length; i++) { + try { RoomChatMessage.BANNED_BUBBLES[i] = Integer.valueOf(bannedBubbles[i]); + } catch (Exception e) { } - catch (Exception e) - {} } HabboManager.WELCOME_MESSAGE = Emulator.getConfig().getValue("hotel.welcome.alert.message").replace("
", "
").replace("
", "
").replace("\\r", "\r").replace("\\n", "\n").replace("\\t", "\t"); @@ -379,7 +106,7 @@ public class PluginManager FloorPlanEditorSaveEvent.MAXIMUM_FLOORPLAN_SIZE = Emulator.getConfig().getInt("hotel.floorplan.max.totalarea"); HotelViewRequestLTDAvailabilityEvent.ENABLED = Emulator.getConfig().getBoolean("hotel.view.ltdcountdown.enabled"); - HotelViewRequestLTDAvailabilityEvent.TIMESTAMP = Emulator.getConfig().getInt("hotel.view.ltdcountdown.timestamp"); + HotelViewRequestLTDAvailabilityEvent.TIMESTAMP = Emulator.getConfig().getInt("hotel.view.ltdcountdown.timestamp"); HotelViewRequestLTDAvailabilityEvent.ITEM_ID = Emulator.getConfig().getInt("hotel.view.ltdcountdown.itemid"); HotelViewRequestLTDAvailabilityEvent.PAGE_ID = Emulator.getConfig().getInt("hotel.view.ltdcountdown.pageid"); HotelViewRequestLTDAvailabilityEvent.ITEM_NAME = Emulator.getConfig().getValue("hotel.view.ltdcountdown.itemname"); @@ -391,10 +118,211 @@ public class PluginManager AchievementManager.TALENTTRACK_ENABLED = Emulator.getConfig().getBoolean("hotel.talenttrack.enabled"); InteractionRoller.NO_RULES = Emulator.getConfig().getBoolean("hotel.room.rollers.norules"); RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics"); - if(Emulator.isReady) { + if (Emulator.isReady) { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPointsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPixelScheduler().reloadConfig(); } } + + public void loadPlugins() { + this.disposePlugins(); + + File loc = new File("plugins"); + + if (!loc.exists()) { + if (loc.mkdirs()) { + Emulator.getLogging().logStart("Created plugins directory!"); + } + } + + for (File file : Objects.requireNonNull(loc.listFiles(file -> file.getPath().toLowerCase().endsWith(".jar")))) { + URLClassLoader urlClassLoader; + InputStream stream; + try { + urlClassLoader = URLClassLoader.newInstance(new URL[]{file.toURI().toURL()}); + stream = urlClassLoader.getResourceAsStream("plugin.json"); + + if (stream == null) { + throw new RuntimeException("Invalid Jar! Missing plugin.json in: " + file.getName()); + } + + byte[] content = new byte[stream.available()]; + + if (stream.read(content) > 0) { + String body = new String(content); + + Gson gson = new GsonBuilder().create(); + HabboPluginConfiguration pluginConfigurtion = gson.fromJson(body, HabboPluginConfiguration.class); + + try { + Class clazz = urlClassLoader.loadClass(pluginConfigurtion.main); + Class stackClazz = clazz.asSubclass(HabboPlugin.class); + Constructor constructor = stackClazz.getConstructor(); + HabboPlugin plugin = constructor.newInstance(); + plugin.configuration = pluginConfigurtion; + plugin.classLoader = urlClassLoader; + plugin.stream = stream; + this.plugins.add(plugin); + plugin.onEnable(); + } catch (Exception e) { + Emulator.getLogging().logErrorLine("Could not load plugin " + pluginConfigurtion.name + "!"); + Emulator.getLogging().logErrorLine(e); + } + } + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } + } + + public void registerEvents(HabboPlugin plugin, EventListener listener) { + synchronized (plugin.registeredEvents) { + Method[] methods = listener.getClass().getMethods(); + + for (Method method : methods) { + if (method.getAnnotation(EventHandler.class) != null) { + if (method.getParameterTypes().length == 1) { + if (Event.class.isAssignableFrom(method.getParameterTypes()[0])) { + final Class eventClass = method.getParameterTypes()[0]; + + if (!plugin.registeredEvents.containsKey(eventClass.asSubclass(Event.class))) { + plugin.registeredEvents.put(eventClass.asSubclass(Event.class), new THashSet<>()); + } + + plugin.registeredEvents.get(eventClass.asSubclass(Event.class)).add(method); + } + } + } + } + } + } + + public Event fireEvent(Event event) { + for (Method method : this.methods) { + if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(event.getClass())) { + try { + method.invoke(null, event); + } catch (Exception e) { + Emulator.getLogging().logErrorLine("Could not pass default event " + event.getClass().getName() + " to " + method.getClass().getName() + ":" + method.getName()); + Emulator.getLogging().logErrorLine(e); + } + } + } + + TObjectHashIterator iterator = this.plugins.iterator(); + while (iterator.hasNext()) { + try { + HabboPlugin plugin = iterator.next(); + + if (plugin != null) { + THashSet methods = plugin.registeredEvents.get(event.getClass().asSubclass(Event.class)); + + if (methods != null) { + for (Method method : methods) { + try { + method.invoke(plugin, event); + } catch (Exception e) { + Emulator.getLogging().logErrorLine("Could not pass event " + event.getClass().getName() + " to " + plugin.configuration.name); + Emulator.getLogging().logErrorLine(e); + } + } + } + } + } catch (NoSuchElementException e) { + break; + } + } + + return event; + } + + public boolean isRegistered(Class clazz, boolean pluginsOnly) { + TObjectHashIterator iterator = this.plugins.iterator(); + while (iterator.hasNext()) { + try { + HabboPlugin plugin = iterator.next(); + if (plugin.isRegistered(clazz)) + return true; + } catch (NoSuchElementException e) { + break; + } + } + + if (!pluginsOnly) { + for (Method method : this.methods) { + if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(clazz)) { + return true; + } + } + } + + return false; + } + + public void dispose() { + this.disposePlugins(); + + Emulator.getLogging().logShutdownLine("Disposed Plugin Manager!"); + } + + private void disposePlugins() { + TObjectHashIterator iterator = this.plugins.iterator(); + while (iterator.hasNext()) { + try { + HabboPlugin p = iterator.next(); + + if (p != null) { + + try { + p.onDisable(); + p.stream.close(); + p.classLoader.close(); + } catch (IOException e) { + Emulator.getLogging().logErrorLine(e); + } catch (Exception ex) { + Emulator.getLogging().logErrorLine("[CRITICAL][PLUGIN] Failed to disable " + p.configuration.name + " caused by: " + ex.getLocalizedMessage()); + Emulator.getLogging().logErrorLine(ex); + } + } + } catch (NoSuchElementException e) { + break; + } + } + this.plugins.clear(); + } + + public void reload() { + long millis = System.currentTimeMillis(); + + this.methods.clear(); + + this.loadPlugins(); + + Emulator.getLogging().logStart("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); + + this.registerDefaultEvents(); + } + + private void registerDefaultEvents() { + try { + this.methods.add(RoomTrashing.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); + this.methods.add(Easter.class.getMethod("onUserChangeMotto", UserSavedMottoEvent.class)); + this.methods.add(TagGame.class.getMethod("onUserLookAtPoint", RoomUnitLookAtPointEvent.class)); + this.methods.add(TagGame.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); + this.methods.add(FreezeGame.class.getMethod("onConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); + this.methods.add(PacketManager.class.getMethod("onConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); + this.methods.add(InteractionFootballGate.class.getMethod("onUserDisconnectEvent", UserDisconnectEvent.class)); + this.methods.add(InteractionFootballGate.class.getMethod("onUserExitRoomEvent", UserExitRoomEvent.class)); + this.methods.add(InteractionFootballGate.class.getMethod("onUserSavedLookEvent", UserSavedLookEvent.class)); + this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); + } catch (NoSuchMethodException e) { + Emulator.getLogging().logStart("Failed to define default events!"); + Emulator.getLogging().logErrorLine(e); + } + } + + public THashSet getPlugins() { + return this.plugins; + } } diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotChatEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotChatEvent.java index 690fae90..1a5dcd19 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotChatEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotChatEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; -public abstract class BotChatEvent extends BotEvent -{ +public abstract class BotChatEvent extends BotEvent { public String message; - public BotChatEvent(Bot bot, String message) - { + public BotChatEvent(Bot bot, String message) { super(bot); this.message = message; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotEvent.java index 9b3d9410..d23c2991 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.plugin.Event; -public abstract class BotEvent extends Event -{ +public abstract class BotEvent extends Event { public final Bot bot; - public BotEvent(Bot bot) - { + public BotEvent(Bot bot) { this.bot = bot; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotPickUpEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotPickUpEvent.java index 3eff18f7..4dd068fa 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotPickUpEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotPickUpEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.Habbo; -public class BotPickUpEvent extends BotEvent -{ +public class BotPickUpEvent extends BotEvent { public final Habbo picker; - public BotPickUpEvent(Bot bot, Habbo picker) - { + public BotPickUpEvent(Bot bot, Habbo picker) { super(bot); this.picker = picker; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotPlacedEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotPlacedEvent.java index e13be07b..f77062d4 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotPlacedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotPlacedEvent.java @@ -4,16 +4,14 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -public class BotPlacedEvent extends BotEvent -{ +public class BotPlacedEvent extends BotEvent { public final RoomTile location; public final Habbo placer; - public BotPlacedEvent(Bot bot, RoomTile location, Habbo placer) - { + public BotPlacedEvent(Bot bot, RoomTile location, Habbo placer) { super(bot); this.location = location; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedChatEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedChatEvent.java index 84d9d66d..fa5bbd6f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedChatEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedChatEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import java.util.ArrayList; -public class BotSavedChatEvent extends BotEvent -{ +public class BotSavedChatEvent extends BotEvent { public boolean autoChat; @@ -19,8 +18,7 @@ public class BotSavedChatEvent extends BotEvent public ArrayList chat; - public BotSavedChatEvent(Bot bot, boolean autoChat, boolean randomChat, int chatDelay, ArrayList chat) - { + public BotSavedChatEvent(Bot bot, boolean autoChat, boolean randomChat, int chatDelay, ArrayList chat) { super(bot); this.autoChat = autoChat; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedLookEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedLookEvent.java index 34788a6a..0f3aba16 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedLookEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedLookEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.HabboGender; -public class BotSavedLookEvent extends BotEvent -{ +public class BotSavedLookEvent extends BotEvent { public HabboGender gender; @@ -15,12 +14,11 @@ public class BotSavedLookEvent extends BotEvent public int effect; - public BotSavedLookEvent(Bot bot, HabboGender gender, String newLook, int effect) - { + public BotSavedLookEvent(Bot bot, HabboGender gender, String newLook, int effect) { super(bot); - this.gender = gender; + this.gender = gender; this.newLook = newLook; - this.effect = effect; + this.effect = effect; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedNameEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedNameEvent.java index d391ce35..3109166d 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedNameEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotSavedNameEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; -public class BotSavedNameEvent extends BotEvent -{ +public class BotSavedNameEvent extends BotEvent { public String name; - public BotSavedNameEvent(Bot bot, String name) - { + public BotSavedNameEvent(Bot bot, String name) { super(bot); this.name = name; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotServerItemEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotServerItemEvent.java index 74922b43..b9e073ad 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotServerItemEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotServerItemEvent.java @@ -3,16 +3,14 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.Habbo; -public class BotServerItemEvent extends BotEvent -{ +public class BotServerItemEvent extends BotEvent { public Habbo habbo; public int itemId; - public BotServerItemEvent(Bot bot, Habbo habbo, int itemId) - { + public BotServerItemEvent(Bot bot, Habbo habbo, int itemId) { super(bot); this.habbo = habbo; diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotShoutEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotShoutEvent.java index 54b6973c..ec44b244 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotShoutEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotShoutEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; -public class BotShoutEvent extends BotChatEvent -{ +public class BotShoutEvent extends BotChatEvent { - public BotShoutEvent(Bot bot, String message) - { + public BotShoutEvent(Bot bot, String message) { super(bot, message); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotTalkEvent.java index 4b0d4094..4b4ecdce 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotTalkEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; -public class BotTalkEvent extends BotChatEvent -{ +public class BotTalkEvent extends BotChatEvent { - public BotTalkEvent(Bot bot, String message) - { + public BotTalkEvent(Bot bot, String message) { super(bot, message); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/bots/BotWhisperEvent.java b/src/main/java/com/eu/habbo/plugin/events/bots/BotWhisperEvent.java index e4788ea7..5be8bb46 100644 --- a/src/main/java/com/eu/habbo/plugin/events/bots/BotWhisperEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/bots/BotWhisperEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.bots; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.Habbo; -public class BotWhisperEvent extends BotChatEvent -{ +public class BotWhisperEvent extends BotChatEvent { public Habbo target; - public BotWhisperEvent(Bot bot, String message, Habbo target) - { + public BotWhisperEvent(Bot bot, String message, Habbo target) { super(bot, message); this.target = target; diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorConfigUpdatedEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorConfigUpdatedEvent.java index 291b185d..ad091bcd 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorConfigUpdatedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorConfigUpdatedEvent.java @@ -1,5 +1,4 @@ package com.eu.habbo.plugin.events.emulator; -public class EmulatorConfigUpdatedEvent extends EmulatorEvent -{ +public class EmulatorConfigUpdatedEvent extends EmulatorEvent { } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorEvent.java index 202a300b..00935eef 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorEvent.java @@ -2,6 +2,5 @@ package com.eu.habbo.plugin.events.emulator; import com.eu.habbo.plugin.Event; -public abstract class EmulatorEvent extends Event -{ +public abstract class EmulatorEvent extends Event { } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadCatalogManagerEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadCatalogManagerEvent.java index 60bf595a..9636988a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadCatalogManagerEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadCatalogManagerEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.plugin.events.emulator; -public class EmulatorLoadCatalogManagerEvent extends EmulatorEvent -{ +public class EmulatorLoadCatalogManagerEvent extends EmulatorEvent { - public EmulatorLoadCatalogManagerEvent() - { + public EmulatorLoadCatalogManagerEvent() { } } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadItemsManagerEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadItemsManagerEvent.java index 09d581b5..10ec915e 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadItemsManagerEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadItemsManagerEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.plugin.events.emulator; -public class EmulatorLoadItemsManagerEvent extends EmulatorEvent -{ +public class EmulatorLoadItemsManagerEvent extends EmulatorEvent { - public EmulatorLoadItemsManagerEvent() - { + public EmulatorLoadItemsManagerEvent() { } } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadedEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadedEvent.java index a6b46462..2d926905 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorLoadedEvent.java @@ -2,10 +2,8 @@ package com.eu.habbo.plugin.events.emulator; import com.eu.habbo.plugin.Event; -public class EmulatorLoadedEvent extends Event -{ +public class EmulatorLoadedEvent extends Event { - public EmulatorLoadedEvent() - { + public EmulatorLoadedEvent() { } } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStartShutdownEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStartShutdownEvent.java index c14aae78..bee59986 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStartShutdownEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStartShutdownEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.plugin.events.emulator; -public class EmulatorStartShutdownEvent extends EmulatorEvent -{ +public class EmulatorStartShutdownEvent extends EmulatorEvent { - public EmulatorStartShutdownEvent() - { + public EmulatorStartShutdownEvent() { } } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStoppedEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStoppedEvent.java index 0dcd3c41..e3a00e2e 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStoppedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/EmulatorStoppedEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.plugin.events.emulator; -public class EmulatorStoppedEvent extends EmulatorEvent -{ +public class EmulatorStoppedEvent extends EmulatorEvent { - public EmulatorStoppedEvent() - { + public EmulatorStoppedEvent() { } } diff --git a/src/main/java/com/eu/habbo/plugin/events/emulator/SSOAuthenticationEvent.java b/src/main/java/com/eu/habbo/plugin/events/emulator/SSOAuthenticationEvent.java index 0ff7e73c..31dbd331 100644 --- a/src/main/java/com/eu/habbo/plugin/events/emulator/SSOAuthenticationEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/emulator/SSOAuthenticationEvent.java @@ -2,12 +2,10 @@ package com.eu.habbo.plugin.events.emulator; import com.eu.habbo.plugin.Event; -public class SSOAuthenticationEvent extends Event -{ +public class SSOAuthenticationEvent extends Event { public final String sso; - public SSOAuthenticationEvent(String sso) - { + public SSOAuthenticationEvent(String sso) { this.sso = sso; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java index d696664a..5bad7182 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureDiceRolledEvent extends FurnitureUserEvent -{ +public class FurnitureDiceRolledEvent extends FurnitureUserEvent { public int result; - public FurnitureDiceRolledEvent(HabboItem furniture, Habbo habbo, int result) - { + public FurnitureDiceRolledEvent(HabboItem furniture, Habbo habbo, int result) { super(furniture, habbo); this.result = result; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java index 9ec1c436..00e5db80 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.plugin.Event; -public abstract class FurnitureEvent extends Event -{ +public abstract class FurnitureEvent extends Event { public final HabboItem furniture; - public FurnitureEvent(HabboItem furniture) - { + public FurnitureEvent(HabboItem furniture) { this.furniture = furniture; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java index b138461f..13ce67e0 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureMovedEvent extends FurnitureUserEvent -{ +public class FurnitureMovedEvent extends FurnitureUserEvent { public final RoomTile oldPosition; @@ -13,8 +12,7 @@ public class FurnitureMovedEvent extends FurnitureUserEvent public final RoomTile newPosition; - public FurnitureMovedEvent(HabboItem furniture, Habbo habbo, RoomTile oldPosition, RoomTile newPosition) - { + public FurnitureMovedEvent(HabboItem furniture, Habbo habbo, RoomTile oldPosition, RoomTile newPosition) { super(furniture, habbo); this.oldPosition = oldPosition; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java index f2c8e24c..37114d2f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurniturePickedUpEvent extends FurnitureUserEvent -{ +public class FurniturePickedUpEvent extends FurnitureUserEvent { - public FurniturePickedUpEvent(HabboItem furniture, Habbo habbo) - { + public FurniturePickedUpEvent(HabboItem furniture, Habbo habbo) { super(furniture, habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java index 0de2e88d..10308ebb 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurniturePlacedEvent extends FurnitureUserEvent -{ +public class FurniturePlacedEvent extends FurnitureUserEvent { public final RoomTile location; - public FurniturePlacedEvent(HabboItem furniture, Habbo habbo, RoomTile location) - { + public FurniturePlacedEvent(HabboItem furniture, Habbo habbo, RoomTile location) { super(furniture, habbo); this.location = location; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java index 83224bb4..dbf63128 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureRedeemedEvent extends FurnitureUserEvent -{ +public class FurnitureRedeemedEvent extends FurnitureUserEvent { public static final int CREDITS = 0; public static final int PIXELS = 1; public static final int DIAMONDS = 5; @@ -16,8 +15,7 @@ public class FurnitureRedeemedEvent extends FurnitureUserEvent public final int currencyID; - public FurnitureRedeemedEvent(HabboItem furniture, Habbo habbo, int amount, int currencyID) - { + public FurnitureRedeemedEvent(HabboItem furniture, Habbo habbo, int amount, int currencyID) { super(furniture, habbo); this.amount = amount; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java index 046fca84..92da1e6b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureRolledEvent extends FurnitureEvent -{ +public class FurnitureRolledEvent extends FurnitureEvent { public final HabboItem roller; @@ -12,8 +11,7 @@ public class FurnitureRolledEvent extends FurnitureEvent public final RoomTile newLocation; - public FurnitureRolledEvent(HabboItem furniture, HabboItem roller, RoomTile newLocation) - { + public FurnitureRolledEvent(HabboItem furniture, HabboItem roller, RoomTile newLocation) { super(furniture); this.roller = roller; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java index 95a64220..4ee85218 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java @@ -3,15 +3,13 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureRoomTonerEvent extends FurnitureUserEvent -{ +public class FurnitureRoomTonerEvent extends FurnitureUserEvent { public int hue; public int saturation; public int brightness; - public FurnitureRoomTonerEvent(HabboItem furniture, Habbo habbo, int hue, int saturation, int brightness) - { + public FurnitureRoomTonerEvent(HabboItem furniture, Habbo habbo, int hue, int saturation, int brightness) { super(furniture, habbo); this.hue = hue; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java index 6772e945..da314b59 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class FurnitureRotatedEvent extends FurnitureUserEvent -{ +public class FurnitureRotatedEvent extends FurnitureUserEvent { public final int oldRotation; - public FurnitureRotatedEvent(HabboItem furniture, Habbo habbo, int oldRotation) - { + public FurnitureRotatedEvent(HabboItem furniture, Habbo habbo, int oldRotation) { super(furniture, habbo); this.oldRotation = oldRotation; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java index 9f2867c2..54017a4b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public abstract class FurnitureUserEvent extends FurnitureEvent -{ +public abstract class FurnitureUserEvent extends FurnitureEvent { public final Habbo habbo; - public FurnitureUserEvent(HabboItem furniture, Habbo habbo) - { + public FurnitureUserEvent(HabboItem furniture, Habbo habbo) { super(furniture); this.habbo = habbo; } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java index b20ca507..c8e420f1 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java @@ -6,8 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; -public class WiredConditionFailedEvent extends RoomUnitEvent -{ +public class WiredConditionFailedEvent extends RoomUnitEvent { public final InteractionWiredTrigger trigger; @@ -15,8 +14,7 @@ public class WiredConditionFailedEvent extends RoomUnitEvent public final InteractionWiredCondition condition; - public WiredConditionFailedEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, InteractionWiredCondition condition) - { + public WiredConditionFailedEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, InteractionWiredCondition condition) { super(room, roomUnit); this.trigger = trigger; this.condition = condition; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java index a844208f..9ed4385a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java @@ -8,8 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; import gnu.trove.set.hash.THashSet; -public class WiredStackExecutedEvent extends RoomUnitEvent -{ +public class WiredStackExecutedEvent extends RoomUnitEvent { public final InteractionWiredTrigger trigger; @@ -20,8 +19,7 @@ public class WiredStackExecutedEvent extends RoomUnitEvent public final THashSet conditions; - public WiredStackExecutedEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, THashSet effects, THashSet conditions) - { + public WiredStackExecutedEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, THashSet effects, THashSet conditions) { super(room, roomUnit); this.trigger = trigger; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java index 5051b7b3..59e3f8ac 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java @@ -8,8 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; import gnu.trove.set.hash.THashSet; -public class WiredStackTriggeredEvent extends RoomUnitEvent -{ +public class WiredStackTriggeredEvent extends RoomUnitEvent { public final InteractionWiredTrigger trigger; @@ -20,8 +19,7 @@ public class WiredStackTriggeredEvent extends RoomUnitEvent public final THashSet conditions; - public WiredStackTriggeredEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, THashSet effects, THashSet conditions) - { + public WiredStackTriggeredEvent(Room room, RoomUnit roomUnit, InteractionWiredTrigger trigger, THashSet effects, THashSet conditions) { super(room, roomUnit); this.trigger = trigger; diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameEvent.java index 600fbfdc..21930be3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.plugin.Event; -public abstract class GameEvent extends Event -{ +public abstract class GameEvent extends Event { public final Game game; - public GameEvent(Game game) - { + public GameEvent(Game game) { this.game = game; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameHabboJoinEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameHabboJoinEvent.java index c8cb9839..560271f4 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameHabboJoinEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameHabboJoinEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.users.Habbo; -public class GameHabboJoinEvent extends GameUserEvent -{ +public class GameHabboJoinEvent extends GameUserEvent { - public GameHabboJoinEvent(Game game, Habbo habbo) - { + public GameHabboJoinEvent(Game game, Habbo habbo) { super(game, habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameHabboLeaveEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameHabboLeaveEvent.java index 46e0535a..1dd267b3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameHabboLeaveEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameHabboLeaveEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.users.Habbo; -public class GameHabboLeaveEvent extends GameUserEvent -{ +public class GameHabboLeaveEvent extends GameUserEvent { - public GameHabboLeaveEvent(Game game, Habbo habbo) - { + public GameHabboLeaveEvent(Game game, Habbo habbo) { super(game, habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameStartedEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameStartedEvent.java index fab72bf4..d4b14ce3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameStartedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameStartedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; -public class GameStartedEvent extends GameEvent -{ +public class GameStartedEvent extends GameEvent { - public GameStartedEvent(Game game) - { + public GameStartedEvent(Game game) { super(game); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameStoppedEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameStoppedEvent.java index 50f9d6dc..dc595933 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameStoppedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameStoppedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; -public class GameStoppedEvent extends GameEvent -{ +public class GameStoppedEvent extends GameEvent { - public GameStoppedEvent(Game game) - { + public GameStoppedEvent(Game game) { super(game); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/games/GameUserEvent.java b/src/main/java/com/eu/habbo/plugin/events/games/GameUserEvent.java index eaa0b8f8..aaf2e981 100644 --- a/src/main/java/com/eu/habbo/plugin/events/games/GameUserEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/games/GameUserEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.games; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.users.Habbo; -public abstract class GameUserEvent extends GameEvent -{ +public abstract class GameUserEvent extends GameEvent { public final Habbo habbo; - public GameUserEvent(Game game, Habbo habbo) - { + public GameUserEvent(Game game, Habbo habbo) { super(game); this.habbo = habbo; 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 9056044f..ab700f01 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 @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildAcceptedMembershipEvent extends GuildEvent -{ +public class GuildAcceptedMembershipEvent extends GuildEvent { public final int userId; @@ -12,8 +11,7 @@ public class GuildAcceptedMembershipEvent extends GuildEvent public final Habbo user; - public GuildAcceptedMembershipEvent(Guild guild, int userId, Habbo user) - { + public GuildAcceptedMembershipEvent(Guild guild, int userId, Habbo user) { super(guild); this.userId = userId; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedBadgeEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedBadgeEvent.java index 63099027..fac0988a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedBadgeEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedBadgeEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -public class GuildChangedBadgeEvent extends GuildEvent -{ +public class GuildChangedBadgeEvent extends GuildEvent { public String badge; - public GuildChangedBadgeEvent(Guild guild, String badge) - { + public GuildChangedBadgeEvent(Guild guild, String badge) { super(guild); this.badge = badge; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedColorsEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedColorsEvent.java index a850512a..6beb5631 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedColorsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedColorsEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -public class GuildChangedColorsEvent extends GuildEvent -{ +public class GuildChangedColorsEvent extends GuildEvent { public int colorOne; @@ -11,8 +10,7 @@ public class GuildChangedColorsEvent extends GuildEvent public int colorTwo; - public GuildChangedColorsEvent(Guild guild, int colorOne, int colorTwo) - { + public GuildChangedColorsEvent(Guild guild, int colorOne, int colorTwo) { super(guild); this.colorOne = colorOne; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedNameEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedNameEvent.java index 7113b768..0a52395b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedNameEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedNameEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -public class GuildChangedNameEvent extends GuildEvent -{ +public class GuildChangedNameEvent extends GuildEvent { public String name; @@ -11,8 +10,7 @@ public class GuildChangedNameEvent extends GuildEvent public String description; - public GuildChangedNameEvent(Guild guild, String name, String description) - { + public GuildChangedNameEvent(Guild guild, String name, String description) { super(guild); this.name = name; this.description = description; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedSettingsEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedSettingsEvent.java index a5ac7341..8c72a076 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedSettingsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildChangedSettingsEvent.java @@ -2,15 +2,13 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -public class GuildChangedSettingsEvent extends GuildEvent -{ +public class GuildChangedSettingsEvent extends GuildEvent { public int state; public boolean rights; - public GuildChangedSettingsEvent(Guild guild, int state, boolean rights) - { + public GuildChangedSettingsEvent(Guild guild, int state, boolean rights) { super(guild); this.state = state; this.rights = rights; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeclinedMembershipEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeclinedMembershipEvent.java index 7bcc0d62..836c5193 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeclinedMembershipEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeclinedMembershipEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildDeclinedMembershipEvent extends GuildEvent -{ +public class GuildDeclinedMembershipEvent extends GuildEvent { public final int userId; @@ -15,8 +14,7 @@ public class GuildDeclinedMembershipEvent extends GuildEvent public final Habbo admin; - public GuildDeclinedMembershipEvent(Guild guild, int userId, Habbo user, Habbo admin) - { + public GuildDeclinedMembershipEvent(Guild guild, int userId, Habbo user, Habbo admin) { super(guild); this.userId = userId; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeletedEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeletedEvent.java index 9a85b142..bd650d01 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeletedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildDeletedEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildDeletedEvent extends GuildEvent -{ +public class GuildDeletedEvent extends GuildEvent { public final Habbo deleter; - public GuildDeletedEvent(Guild guild, Habbo deleter) - { + public GuildDeletedEvent(Guild guild, Habbo deleter) { super(guild); this.deleter = deleter; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildEvent.java index 8c2ccc30..e327d892 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.plugin.Event; -public abstract class GuildEvent extends Event -{ +public abstract class GuildEvent extends Event { public final Guild guild; - public GuildEvent(Guild guild) - { + public GuildEvent(Guild guild) { this.guild = guild; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildFavoriteSetEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildFavoriteSetEvent.java index 5d26070c..bb772464 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildFavoriteSetEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildFavoriteSetEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildFavoriteSetEvent extends GuildEvent -{ +public class GuildFavoriteSetEvent extends GuildEvent { public final Habbo habbo; - public GuildFavoriteSetEvent(Guild guild, Habbo habbo) - { + public GuildFavoriteSetEvent(Guild guild, Habbo habbo) { super(guild); this.habbo = habbo; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildGivenAdminEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildGivenAdminEvent.java index 7e5b1cdc..4c0b14a9 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildGivenAdminEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildGivenAdminEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildGivenAdminEvent extends GuildEvent -{ +public class GuildGivenAdminEvent extends GuildEvent { public final int userId; @@ -15,8 +14,7 @@ public class GuildGivenAdminEvent extends GuildEvent public final Habbo admin; - public GuildGivenAdminEvent(Guild guild, int userId, Habbo habbo, Habbo admin) - { + public GuildGivenAdminEvent(Guild guild, int userId, Habbo habbo, Habbo admin) { super(guild); this.userId = userId; this.habbo = habbo; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildPurchasedEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildPurchasedEvent.java index fd04d4fe..05c0c513 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildPurchasedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildPurchasedEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildPurchasedEvent extends GuildEvent -{ +public class GuildPurchasedEvent extends GuildEvent { public final Habbo habbo; - public GuildPurchasedEvent(Guild guild, Habbo habbo) - { + public GuildPurchasedEvent(Guild guild, Habbo habbo) { super(guild); this.habbo = habbo; } diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedAdminEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedAdminEvent.java index c2f3baed..64f400ec 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedAdminEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedAdminEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildRemovedAdminEvent extends GuildEvent -{ +public class GuildRemovedAdminEvent extends GuildEvent { public final int userId; @@ -12,8 +11,7 @@ public class GuildRemovedAdminEvent extends GuildEvent public final Habbo admin; - public GuildRemovedAdminEvent(Guild guild, int userId, Habbo admin) - { + public GuildRemovedAdminEvent(Guild guild, int userId, Habbo admin) { super(guild); this.userId = userId; this.admin = admin; diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedFavoriteEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedFavoriteEvent.java index b3ae0b31..a69459ec 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedFavoriteEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildRemovedFavoriteEvent extends GuildEvent -{ +public class GuildRemovedFavoriteEvent extends GuildEvent { public final Habbo habbo; - public GuildRemovedFavoriteEvent(Guild guild, Habbo habbo) - { + public GuildRemovedFavoriteEvent(Guild guild, Habbo habbo) { super(guild); this.habbo = habbo; } diff --git a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedMemberEvent.java b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedMemberEvent.java index e17605bf..622fa406 100644 --- a/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedMemberEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/guilds/GuildRemovedMemberEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.guilds; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -public class GuildRemovedMemberEvent extends GuildEvent -{ +public class GuildRemovedMemberEvent extends GuildEvent { public final int userId; @@ -12,8 +11,7 @@ public class GuildRemovedMemberEvent extends GuildEvent public final Habbo guildMember; - public GuildRemovedMemberEvent(Guild guild, int userId, Habbo guildMember) - { + public GuildRemovedMemberEvent(Guild guild, int userId, Habbo guildMember) { super(guild); this.guildMember = guildMember; this.userId = userId; diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryEvent.java index f2c1130d..5d9502a4 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryEvent.java @@ -3,12 +3,10 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.plugin.Event; -public abstract class InventoryEvent extends Event -{ +public abstract class InventoryEvent extends Event { public final HabboInventory inventory; - protected InventoryEvent(HabboInventory inventory) - { + protected InventoryEvent(HabboInventory inventory) { this.inventory = inventory; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java index 5b439140..af3ed727 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java @@ -3,10 +3,8 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboItem; -public class InventoryItemAddedEvent extends InventoryItemEvent -{ - public InventoryItemAddedEvent(HabboInventory inventory, HabboItem item) - { +public class InventoryItemAddedEvent extends InventoryItemEvent { + public InventoryItemAddedEvent(HabboInventory inventory, HabboItem item) { super(inventory, item); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java index f4515832..1b93cf86 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java @@ -3,12 +3,10 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboItem; -public class InventoryItemEvent extends InventoryEvent -{ +public class InventoryItemEvent extends InventoryEvent { public HabboItem item; - public InventoryItemEvent(HabboInventory inventory, HabboItem item) - { + public InventoryItemEvent(HabboInventory inventory, HabboItem item) { super(inventory); this.item = item; diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java index 1d9a272c..26330b8a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java @@ -3,10 +3,8 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboItem; -public class InventoryItemRemovedEvent extends InventoryItemEvent -{ - public InventoryItemRemovedEvent(HabboInventory inventory, HabboItem item) - { +public class InventoryItemRemovedEvent extends InventoryItemEvent { + public InventoryItemRemovedEvent(HabboInventory inventory, HabboItem item) { super(inventory, item); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java index e0be6c37..a0ead84f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java @@ -4,12 +4,10 @@ import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -public class InventoryItemsAddedEvent extends InventoryEvent -{ +public class InventoryItemsAddedEvent extends InventoryEvent { public final THashSet items; - public InventoryItemsAddedEvent(HabboInventory inventory, THashSet items) - { + public InventoryItemsAddedEvent(HabboInventory inventory, THashSet items) { super(inventory); this.items = items; } diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceEvent.java index 6a75efff..da5e5a47 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceEvent.java @@ -2,6 +2,5 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.plugin.Event; -public class MarketPlaceEvent extends Event -{ +public class MarketPlaceEvent extends Event { } diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemCancelledEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemCancelledEvent.java index 3395c035..993d4cc5 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemCancelledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemCancelledEvent.java @@ -2,12 +2,10 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer; -public class MarketPlaceItemCancelledEvent extends MarketPlaceEvent -{ +public class MarketPlaceItemCancelledEvent extends MarketPlaceEvent { public final MarketPlaceOffer offer; - public MarketPlaceItemCancelledEvent(MarketPlaceOffer offer) - { + public MarketPlaceItemCancelledEvent(MarketPlaceOffer offer) { this.offer = offer; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java index b377e4f4..fa351db2 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class MarketPlaceItemOfferedEvent extends MarketPlaceEvent -{ +public class MarketPlaceItemOfferedEvent extends MarketPlaceEvent { public final Habbo habbo; public final HabboItem item; public int price; - public MarketPlaceItemOfferedEvent(Habbo habbo, HabboItem item, int price) - { + public MarketPlaceItemOfferedEvent(Habbo habbo, HabboItem item, int price) { this.habbo = habbo; this.item = item; this.price = price; diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java index 8a09c563..2f6957b8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java @@ -3,15 +3,13 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class MarketPlaceItemSoldEvent extends MarketPlaceEvent -{ +public class MarketPlaceItemSoldEvent extends MarketPlaceEvent { public final Habbo seller; public final Habbo purchaser; public final HabboItem item; public int price; - public MarketPlaceItemSoldEvent(Habbo seller, Habbo purchaser, HabboItem item, int price) - { + public MarketPlaceItemSoldEvent(Habbo seller, Habbo purchaser, HabboItem item, int price) { this.seller = seller; this.purchaser = purchaser; this.item = item; diff --git a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorPopularRoomsEvent.java b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorPopularRoomsEvent.java index 17ace2ec..73dafe22 100644 --- a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorPopularRoomsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorPopularRoomsEvent.java @@ -5,14 +5,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; -public class NavigatorPopularRoomsEvent extends NavigatorRoomsEvent -{ +public class NavigatorPopularRoomsEvent extends NavigatorRoomsEvent { public final ArrayList rooms; - public NavigatorPopularRoomsEvent(Habbo habbo, ArrayList rooms) - { + public NavigatorPopularRoomsEvent(Habbo habbo, ArrayList rooms) { super(habbo, rooms); this.rooms = rooms; diff --git a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomCreatedEvent.java b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomCreatedEvent.java index 8b8f35a4..8e0215aa 100644 --- a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomCreatedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomCreatedEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public class NavigatorRoomCreatedEvent extends UserEvent -{ +public class NavigatorRoomCreatedEvent extends UserEvent { public final Room room; - public NavigatorRoomCreatedEvent(Habbo habbo, Room room) - { + public NavigatorRoomCreatedEvent(Habbo habbo, Room room) { super(habbo); this.room = room; diff --git a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomDeletedEvent.java b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomDeletedEvent.java index ccdf8c3c..581813a5 100644 --- a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomDeletedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomDeletedEvent.java @@ -4,12 +4,10 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public class NavigatorRoomDeletedEvent extends UserEvent -{ +public class NavigatorRoomDeletedEvent extends UserEvent { public final Room room; - public NavigatorRoomDeletedEvent(Habbo habbo, Room room) - { + public NavigatorRoomDeletedEvent(Habbo habbo, Room room) { super(habbo); this.room = room; diff --git a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomsEvent.java index 83cf7d5f..43262830 100644 --- a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorRoomsEvent.java @@ -6,14 +6,12 @@ import com.eu.habbo.plugin.events.users.UserEvent; import java.util.ArrayList; -public abstract class NavigatorRoomsEvent extends UserEvent -{ +public abstract class NavigatorRoomsEvent extends UserEvent { public final ArrayList rooms; - public NavigatorRoomsEvent(Habbo habbo, ArrayList rooms) - { + public NavigatorRoomsEvent(Habbo habbo, ArrayList rooms) { super(habbo); this.rooms = rooms; diff --git a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorSearchResultEvent.java b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorSearchResultEvent.java index 2f71a750..d6c7a785 100644 --- a/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorSearchResultEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/navigator/NavigatorSearchResultEvent.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.ArrayList; -public class NavigatorSearchResultEvent extends NavigatorRoomsEvent -{ +public class NavigatorSearchResultEvent extends NavigatorRoomsEvent { public final String prefix; @@ -14,8 +13,7 @@ public class NavigatorSearchResultEvent extends NavigatorRoomsEvent public final String query; - public NavigatorSearchResultEvent(Habbo habbo, String prefix, String query, ArrayList rooms) - { + public NavigatorSearchResultEvent(Habbo habbo, String prefix, String query, ArrayList rooms) { super(habbo, rooms); this.prefix = prefix; diff --git a/src/main/java/com/eu/habbo/plugin/events/pets/PetEvent.java b/src/main/java/com/eu/habbo/plugin/events/pets/PetEvent.java index 8c29dac1..f888cb35 100644 --- a/src/main/java/com/eu/habbo/plugin/events/pets/PetEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/pets/PetEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.pets; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.plugin.Event; -public abstract class PetEvent extends Event -{ +public abstract class PetEvent extends Event { public final Pet pet; - public PetEvent(Pet pet) - { + public PetEvent(Pet pet) { this.pet = pet; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java index abd6c52b..8fefd42e 100644 --- a/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java @@ -3,15 +3,13 @@ package com.eu.habbo.plugin.events.pets; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; -public class PetTalkEvent extends PetEvent -{ +public class PetTalkEvent extends PetEvent { public RoomChatMessage message; - public PetTalkEvent(Pet pet, RoomChatMessage message) - { + public PetTalkEvent(Pet pet, RoomChatMessage message) { super(pet); - + this.message = message; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomEvent.java index 76f32669..a6df7762 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.plugin.Event; -public abstract class RoomEvent extends Event -{ +public abstract class RoomEvent extends Event { public final Room room; - public RoomEvent(Room room) - { + public RoomEvent(Room room) { this.room = room; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomLoadedEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomLoadedEvent.java index 210ec58d..a5452cf9 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomLoadedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomLoadedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.rooms.Room; -public class RoomLoadedEvent extends RoomEvent -{ +public class RoomLoadedEvent extends RoomEvent { - public RoomLoadedEvent(Room room) - { + public RoomLoadedEvent(Room room) { super(room); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUncachedEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUncachedEvent.java index fb51498a..dd4c132d 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUncachedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUncachedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.rooms.Room; -public class RoomUncachedEvent extends RoomEvent -{ +public class RoomUncachedEvent extends RoomEvent { - public RoomUncachedEvent(Room room) - { + public RoomUncachedEvent(Room room) { super(room); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadedEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadedEvent.java index e8151d12..f312604f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.rooms.Room; -public class RoomUnloadedEvent extends RoomEvent -{ +public class RoomUnloadedEvent extends RoomEvent { - public RoomUnloadedEvent(Room room) - { + public RoomUnloadedEvent(Room room) { super(room); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadingEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadingEvent.java index cde143f5..af8af26c 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadingEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomUnloadingEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.rooms.Room; -public class RoomUnloadingEvent extends RoomEvent -{ +public class RoomUnloadingEvent extends RoomEvent { - public RoomUnloadingEvent(Room room) - { + public RoomUnloadingEvent(Room room) { super(room); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java index 61de0b19..6979df52 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.plugin.Event; -public abstract class RoomUnitEvent extends Event -{ +public abstract class RoomUnitEvent extends Event { public final Room room; @@ -13,8 +12,7 @@ public abstract class RoomUnitEvent extends Event public final RoomUnit roomUnit; - public RoomUnitEvent(Room room, RoomUnit roomUnit) - { + public RoomUnitEvent(Room room, RoomUnit roomUnit) { this.room = room; this.roomUnit = roomUnit; } diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java index ab94e45d..b1e5c280 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; -public class RoomUnitLookAtPointEvent extends RoomUnitEvent -{ +public class RoomUnitLookAtPointEvent extends RoomUnitEvent { public final RoomTile location; - public RoomUnitLookAtPointEvent(Room room, RoomUnit roomUnit, RoomTile location) - { + public RoomUnitLookAtPointEvent(Room room, RoomUnit roomUnit, RoomTile location) { super(room, roomUnit); this.location = location; diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java index b7096bd3..c7583272 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java @@ -4,21 +4,18 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; -public class RoomUnitSetGoalEvent extends RoomUnitEvent -{ +public class RoomUnitSetGoalEvent extends RoomUnitEvent { public final RoomTile goal; - public RoomUnitSetGoalEvent(Room room, RoomUnit roomUnit, RoomTile goal) - { + public RoomUnitSetGoalEvent(Room room, RoomUnit roomUnit, RoomTile goal) { super(room, roomUnit); this.goal = goal; } - public void setGoal(RoomTile t) - { + public void setGoal(RoomTile t) { super.roomUnit.setGoalLocation(t); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportEvent.java index 8910d420..b198ecd8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.Event; -public abstract class SupportEvent extends Event -{ +public abstract class SupportEvent extends Event { public Habbo moderator; - public SupportEvent(Habbo moderator) - { + public SupportEvent(Habbo moderator) { this.moderator = moderator; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportRoomActionEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportRoomActionEvent.java index 4c79da3f..f05df35b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportRoomActionEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportRoomActionEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportRoomActionEvent extends SupportEvent -{ +public class SupportRoomActionEvent extends SupportEvent { public final Room room; @@ -18,13 +17,12 @@ public class SupportRoomActionEvent extends SupportEvent public boolean changeTitle; - public SupportRoomActionEvent(Habbo moderator, Room room, boolean kickUsers, boolean lockDoor, boolean changeTitle) - { + public SupportRoomActionEvent(Habbo moderator, Room room, boolean kickUsers, boolean lockDoor, boolean changeTitle) { super(moderator); - this.room = room; - this.kickUsers = kickUsers; - this.lockDoor = lockDoor; + this.room = room; + this.kickUsers = kickUsers; + this.lockDoor = lockDoor; this.changeTitle = changeTitle; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketEvent.java index a6290c40..2d5a410f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketEvent.java @@ -3,13 +3,11 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportTicketEvent extends SupportEvent -{ +public class SupportTicketEvent extends SupportEvent { public final ModToolIssue ticket; - public SupportTicketEvent(Habbo moderator, ModToolIssue ticket) - { + public SupportTicketEvent(Habbo moderator, ModToolIssue ticket) { super(moderator); this.ticket = ticket; diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketStatusChangedEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketStatusChangedEvent.java index 1f5b02db..16d8f007 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketStatusChangedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportTicketStatusChangedEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportTicketStatusChangedEvent extends SupportTicketEvent -{ +public class SupportTicketStatusChangedEvent extends SupportTicketEvent { - public SupportTicketStatusChangedEvent(Habbo moderator, ModToolIssue ticket) - { + public SupportTicketStatusChangedEvent(Habbo moderator, ModToolIssue ticket) { super(moderator, ticket); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java index efba63be..de3dc547 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportUserAlertedEvent extends SupportEvent -{ +public class SupportUserAlertedEvent extends SupportEvent { public Habbo target; @@ -11,12 +10,11 @@ public class SupportUserAlertedEvent extends SupportEvent public SupportUserAlertedReason reason; - public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) - { + public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) { super(moderator); this.message = message; - this.target = target; + this.target = target; this.reason = reason; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java index 552d2b90..b1afb347 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java @@ -12,13 +12,11 @@ public enum SupportUserAlertedReason { private final int code; - SupportUserAlertedReason(int code) - { + SupportUserAlertedReason(int code) { this.code = code; } - public int getCode() - { + public int getCode() { return this.code; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserBannedEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserBannedEvent.java index 8e8acf12..7712dd77 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserBannedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserBannedEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportUserBannedEvent extends SupportEvent -{ +public class SupportUserBannedEvent extends SupportEvent { public final Habbo target; @@ -12,11 +11,10 @@ public class SupportUserBannedEvent extends SupportEvent public final ModToolBan ban; - public SupportUserBannedEvent(Habbo moderator, Habbo target, ModToolBan ban) - { + public SupportUserBannedEvent(Habbo moderator, Habbo target, ModToolBan ban) { super(moderator); this.target = target; - this.ban = ban; + this.ban = ban; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserKickEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserKickEvent.java index 4871d87c..9a28a94a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserKickEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserKickEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.support; import com.eu.habbo.habbohotel.users.Habbo; -public class SupportUserKickEvent extends SupportEvent -{ +public class SupportUserKickEvent extends SupportEvent { public Habbo target; @@ -11,8 +10,7 @@ public class SupportUserKickEvent extends SupportEvent public String message; - public SupportUserKickEvent(Habbo moderator, Habbo target, String message) - { + public SupportUserKickEvent(Habbo moderator, Habbo target, String message) { super(moderator); this.target = target; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java index 3980cfcc..be861f8a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -public class HabboAddedToRoomEvent extends UserEvent -{ +public class HabboAddedToRoomEvent extends UserEvent { public final Room room; - public HabboAddedToRoomEvent(Habbo habbo, Room room) - { + public HabboAddedToRoomEvent(Habbo habbo, Room room) { super(habbo); this.room = room; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserCommandEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserCommandEvent.java index a939b8bd..06952611 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserCommandEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserCommandEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserCommandEvent extends UserEvent -{ +public class UserCommandEvent extends UserEvent { public final String[] args; @@ -11,8 +10,7 @@ public class UserCommandEvent extends UserEvent public final boolean succes; - public UserCommandEvent(Habbo habbo, String[] args, boolean succes) - { + public UserCommandEvent(Habbo habbo, String[] args, boolean succes) { super(habbo); this.args = args; this.succes = succes; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserCreditsEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserCreditsEvent.java index 92dc008b..0186e98f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserCreditsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserCreditsEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserCreditsEvent extends UserEvent -{ +public class UserCreditsEvent extends UserEvent { public int credits; - public UserCreditsEvent(Habbo habbo, int credits) - { + public UserCreditsEvent(Habbo habbo, int credits) { super(habbo); this.credits = credits; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserDisconnectEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserDisconnectEvent.java index a771d732..a3c4304c 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserDisconnectEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserDisconnectEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserDisconnectEvent extends UserEvent -{ +public class UserDisconnectEvent extends UserEvent { - public UserDisconnectEvent(Habbo habbo) - { + public UserDisconnectEvent(Habbo habbo) { super(habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserEnterRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserEnterRoomEvent.java index 3e9d242d..05ae0a8a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserEnterRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserEnterRoomEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -public class UserEnterRoomEvent extends UserEvent -{ +public class UserEnterRoomEvent extends UserEvent { public final Room room; - public UserEnterRoomEvent(Habbo habbo, Room room) - { + public UserEnterRoomEvent(Habbo habbo, Room room) { super(habbo); this.room = room; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserEvent.java index 0d49b89a..14876e8e 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.Event; -public abstract class UserEvent extends Event -{ +public abstract class UserEvent extends Event { public final Habbo habbo; - public UserEvent(Habbo habbo) - { + public UserEvent(Habbo habbo) { this.habbo = habbo; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserExecuteCommandEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserExecuteCommandEvent.java index e3b5c07f..b70999e4 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserExecuteCommandEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserExecuteCommandEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.users.Habbo; -public class UserExecuteCommandEvent extends UserEvent -{ +public class UserExecuteCommandEvent extends UserEvent { public final Command command; @@ -12,8 +11,7 @@ public class UserExecuteCommandEvent extends UserEvent public final String[] params; - public UserExecuteCommandEvent(Habbo habbo, Command command, String[] params) - { + public UserExecuteCommandEvent(Habbo habbo, Command command, String[] params) { super(habbo); this.command = command; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserExitRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserExitRoomEvent.java index 8a410297..c63ae3db 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserExitRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserExitRoomEvent.java @@ -2,10 +2,16 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserExitRoomEvent extends UserEvent -{ - public enum UserExitRoomReason - { +public class UserExitRoomEvent extends UserEvent { + public final UserExitRoomReason reason; + + public UserExitRoomEvent(Habbo habbo, UserExitRoomReason reason) { + super(habbo); + this.reason = reason; + } + + + public enum UserExitRoomReason { DOOR(false), KICKED_HABBO(false), KICKED_IDLE(true), @@ -13,18 +19,8 @@ public class UserExitRoomEvent extends UserEvent public final boolean cancellable; - UserExitRoomReason(boolean cancellable) - { + UserExitRoomReason(boolean cancellable) { this.cancellable = cancellable; } } - - public final UserExitRoomReason reason; - - - public UserExitRoomEvent(Habbo habbo, UserExitRoomReason reason) - { - super(habbo); - this.reason = reason; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserIdleEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserIdleEvent.java index 25669eb1..5e5b7782 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserIdleEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserIdleEvent.java @@ -2,26 +2,22 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserIdleEvent extends UserEvent -{ - public enum IdleReason - { +public class UserIdleEvent extends UserEvent { + public final IdleReason reason; + public boolean idle; + public UserIdleEvent(Habbo habbo, IdleReason reason, boolean idle) { + super(habbo); + + this.reason = reason; + this.idle = idle; + } + + + public enum IdleReason { ACTION, DANCE, TIMEOUT, WALKED, TALKED } - - public final IdleReason reason; - public boolean idle; - - - public UserIdleEvent(Habbo habbo, IdleReason reason, boolean idle) - { - super(habbo); - - this.reason = reason; - this.idle = idle; - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserKickEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserKickEvent.java index 11216529..5e4feb02 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserKickEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserKickEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserKickEvent extends UserEvent -{ +public class UserKickEvent extends UserEvent { public final Habbo target; - public UserKickEvent(Habbo habbo, Habbo target) - { + public UserKickEvent(Habbo habbo, Habbo target) { super(habbo); this.target = target; 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 907f3b52..15268bcb 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 @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.net.SocketAddress; -public class UserLoginEvent extends UserEvent -{ +public class UserLoginEvent extends UserEvent { public final SocketAddress ip; - public UserLoginEvent(Habbo habbo, SocketAddress ip) - { + public UserLoginEvent(Habbo habbo, SocketAddress ip) { super(habbo); this.ip = ip; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserNameChangedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserNameChangedEvent.java index 9f9a9d7e..2e7384c3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserNameChangedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserNameChangedEvent.java @@ -2,13 +2,11 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserNameChangedEvent extends UserEvent -{ +public class UserNameChangedEvent extends UserEvent { public final String oldName; - public UserNameChangedEvent(Habbo habbo, String oldName) - { + public UserNameChangedEvent(Habbo habbo, String oldName) { super(habbo); this.oldName = oldName; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserPickGiftEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserPickGiftEvent.java index bd46ceda..22c27a7e 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserPickGiftEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserPickGiftEvent.java @@ -2,15 +2,13 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserPickGiftEvent extends UserEvent -{ +public class UserPickGiftEvent extends UserEvent { public final int keyA; public final int keyB; public final int index; - public UserPickGiftEvent(Habbo habbo, int keyA, int keyB, int index) - { + public UserPickGiftEvent(Habbo habbo, int keyA, int keyB, int index) { super(habbo); this.keyA = keyA; this.keyB = keyB; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserPointsEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserPointsEvent.java index 31b36952..d014e419 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserPointsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserPointsEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserPointsEvent extends UserEvent -{ +public class UserPointsEvent extends UserEvent { public int points; @@ -11,11 +10,10 @@ public class UserPointsEvent extends UserEvent public int type; - public UserPointsEvent(Habbo habbo, int points, int type) - { + public UserPointsEvent(Habbo habbo, int points, int type) { super(habbo); this.points = points; - this.type = type; + this.type = type; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserPublishPictureEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserPublishPictureEvent.java index 0015fe1c..7c794fb3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserPublishPictureEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserPublishPictureEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserPublishPictureEvent extends UserEvent -{ +public class UserPublishPictureEvent extends UserEvent { public String URL; @@ -14,8 +13,7 @@ public class UserPublishPictureEvent extends UserEvent public int roomId; - public UserPublishPictureEvent(Habbo habbo, String url, int timestamp, int roomId) - { + public UserPublishPictureEvent(Habbo habbo, String url, int timestamp, int roomId) { super(habbo); this.URL = url; this.timestamp = timestamp; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserPurchasePictureEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserPurchasePictureEvent.java index 8905d966..b79fbb2a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserPurchasePictureEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserPurchasePictureEvent.java @@ -2,8 +2,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserPurchasePictureEvent extends UserEvent -{ +public class UserPurchasePictureEvent extends UserEvent { public String url; @@ -14,8 +13,7 @@ public class UserPurchasePictureEvent extends UserEvent public int timestamp; - public UserPurchasePictureEvent(Habbo habbo, String url, int roomId, int timestamp) - { + public UserPurchasePictureEvent(Habbo habbo, String url, int roomId, int timestamp) { super(habbo); this.url = url; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRankChangedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRankChangedEvent.java index d6bb33e6..41cb109d 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRankChangedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRankChangedEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRankChangedEvent extends UserEvent -{ +public class UserRankChangedEvent extends UserEvent { - public UserRankChangedEvent(Habbo habbo) - { + public UserRankChangedEvent(Habbo habbo) { super(habbo); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRegisteredEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRegisteredEvent.java index bf7a7d6f..3aa79047 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRegisteredEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRegisteredEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRegisteredEvent extends UserEvent -{ +public class UserRegisteredEvent extends UserEvent { - public UserRegisteredEvent(Habbo habbo) - { + public UserRegisteredEvent(Habbo habbo) { super(habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java index c161c6b3..6834835d 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java @@ -2,12 +2,10 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRespectedEvent extends UserEvent -{ +public class UserRespectedEvent extends UserEvent { public final Habbo from; - public UserRespectedEvent(Habbo habbo, Habbo from) - { + public UserRespectedEvent(Habbo habbo, Habbo from) { super(habbo); this.from = from; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRightsGivenEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRightsGivenEvent.java index 09af0ea3..ba84083b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRightsGivenEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRightsGivenEvent.java @@ -2,12 +2,10 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRightsGivenEvent extends UserEvent -{ +public class UserRightsGivenEvent extends UserEvent { public final Habbo receiver; - public UserRightsGivenEvent(Habbo habbo, Habbo receiver) - { + public UserRightsGivenEvent(Habbo habbo, Habbo receiver) { super(habbo); this.receiver = receiver; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRightsTakenEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRightsTakenEvent.java index 366c5cb5..ee55630d 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRightsTakenEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRightsTakenEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRightsTakenEvent extends UserEvent -{ +public class UserRightsTakenEvent extends UserEvent { public final int victimId; public final Habbo victim; - public UserRightsTakenEvent(Habbo habbo, int victimId, Habbo victim) - { + public UserRightsTakenEvent(Habbo habbo, int victimId, Habbo victim) { super(habbo); this.victimId = victimId; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java index 3f76d293..c38f36a3 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class UserRolledEvent extends UserEvent -{ +public class UserRolledEvent extends UserEvent { public final HabboItem roller; @@ -13,8 +12,7 @@ public class UserRolledEvent extends UserEvent public final RoomTile location; - public UserRolledEvent(Habbo habbo, HabboItem roller, RoomTile location) - { + public UserRolledEvent(Habbo habbo, HabboItem roller, RoomTile location) { super(habbo); this.roller = roller; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedLookEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedLookEvent.java index 06df3b68..096cbe3a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedLookEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedLookEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -public class UserSavedLookEvent extends UserEvent -{ +public class UserSavedLookEvent extends UserEvent { public HabboGender gender; public String newLook; - public UserSavedLookEvent(Habbo habbo, HabboGender gender, String newLook) - { + public UserSavedLookEvent(Habbo habbo, HabboGender gender, String newLook) { super(habbo); this.gender = gender; this.newLook = newLook; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedMottoEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedMottoEvent.java index 4523f573..0b64b449 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedMottoEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedMottoEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserSavedMottoEvent extends UserEvent -{ +public class UserSavedMottoEvent extends UserEvent { public final String oldMotto; public String newMotto; - public UserSavedMottoEvent(Habbo habbo, String oldMotto, String newMotto) - { + public UserSavedMottoEvent(Habbo habbo, String oldMotto, String newMotto) { super(habbo); this.oldMotto = oldMotto; this.newMotto = newMotto; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedSettingsEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedSettingsEvent.java index f5532335..687eeea4 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedSettingsEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedSettingsEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserSavedSettingsEvent extends UserEvent -{ +public class UserSavedSettingsEvent extends UserEvent { - public UserSavedSettingsEvent(Habbo habbo) - { + public UserSavedSettingsEvent(Habbo habbo) { super(habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedWardrobeEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedWardrobeEvent.java index 5411f929..f1d57c62 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserSavedWardrobeEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserSavedWardrobeEvent.java @@ -3,13 +3,11 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.inventory.WardrobeComponent; -public class UserSavedWardrobeEvent extends UserEvent -{ +public class UserSavedWardrobeEvent extends UserEvent { public final WardrobeComponent.WardrobeItem wardrobeItem; - public UserSavedWardrobeEvent(Habbo habbo, WardrobeComponent.WardrobeItem wardrobeItem) - { + public UserSavedWardrobeEvent(Habbo habbo, WardrobeComponent.WardrobeItem wardrobeItem) { super(habbo); this.wardrobeItem = wardrobeItem; } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserSignEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserSignEvent.java index 7d1f001d..04899467 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserSignEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserSignEvent.java @@ -2,14 +2,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.users.Habbo; -public class UserSignEvent extends UserEvent -{ +public class UserSignEvent extends UserEvent { public int sign; - public UserSignEvent(Habbo habbo, int sign) - { + public UserSignEvent(Habbo habbo, int sign) { super(habbo); this.sign = sign; } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserTakeStepEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserTakeStepEvent.java index d2a261c1..133016fd 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserTakeStepEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserTakeStepEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -public class UserTakeStepEvent extends UserEvent -{ +public class UserTakeStepEvent extends UserEvent { public final RoomTile fromLocation; @@ -12,8 +11,7 @@ public class UserTakeStepEvent extends UserEvent public final RoomTile toLocation; - public UserTakeStepEvent(Habbo habbo, RoomTile fromLocation, RoomTile toLocation) - { + public UserTakeStepEvent(Habbo habbo, RoomTile fromLocation, RoomTile toLocation) { super(habbo); this.fromLocation = fromLocation; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java index 335f44fc..853e3647 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java @@ -4,13 +4,11 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.habbohotel.users.Habbo; -public class UserTalkEvent extends UserEvent -{ +public class UserTalkEvent extends UserEvent { public final RoomChatMessage chatMessage; public final RoomChatType chatType; - public UserTalkEvent(Habbo habbo, RoomChatMessage chatMessage, RoomChatType chatType) - { + public UserTalkEvent(Habbo habbo, RoomChatMessage chatMessage, RoomChatType chatType) { super(habbo); this.chatMessage = chatMessage; this.chatType = chatType; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserTriggerWordFilterEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserTriggerWordFilterEvent.java index e767d0a1..e7fa9811 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserTriggerWordFilterEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserTriggerWordFilterEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.modtool.WordFilterWord; import com.eu.habbo.habbohotel.users.Habbo; -public class UserTriggerWordFilterEvent extends UserEvent -{ +public class UserTriggerWordFilterEvent extends UserEvent { public final WordFilterWord word; - public UserTriggerWordFilterEvent(Habbo habbo, WordFilterWord word) - { + public UserTriggerWordFilterEvent(Habbo habbo, WordFilterWord word) { super(habbo); this.word = word; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserWiredRewardReceived.java b/src/main/java/com/eu/habbo/plugin/events/users/UserWiredRewardReceived.java index 6987d874..c2c16e30 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserWiredRewardReceived.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserWiredRewardReceived.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectGiveReward; import com.eu.habbo.habbohotel.users.Habbo; -public class UserWiredRewardReceived extends UserEvent -{ +public class UserWiredRewardReceived extends UserEvent { public final WiredEffectGiveReward wiredEffectGiveReward; @@ -15,8 +14,7 @@ public class UserWiredRewardReceived extends UserEvent public String value; - public UserWiredRewardReceived(Habbo habbo, WiredEffectGiveReward wiredEffectGiveReward, String type, String value) - { + public UserWiredRewardReceived(Habbo habbo, WiredEffectGiveReward wiredEffectGiveReward, String type, String value) { super(habbo); this.wiredEffectGiveReward = wiredEffectGiveReward; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementEvent.java index 6c1ea72f..5d50f75f 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public abstract class UserAchievementEvent extends UserEvent -{ +public abstract class UserAchievementEvent extends UserEvent { public final Achievement achievement; - public UserAchievementEvent(Habbo habbo, Achievement achievement) - { + public UserAchievementEvent(Habbo habbo, Achievement achievement) { super(habbo); this.achievement = achievement; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementLeveledEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementLeveledEvent.java index 739133f3..825b8715 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementLeveledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementLeveledEvent.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementLevel; import com.eu.habbo.habbohotel.users.Habbo; -public class UserAchievementLeveledEvent extends UserAchievementEvent -{ +public class UserAchievementLeveledEvent extends UserAchievementEvent { public final AchievementLevel oldLevel; @@ -13,8 +12,7 @@ public class UserAchievementLeveledEvent extends UserAchievementEvent public final AchievementLevel newLevel; - public UserAchievementLeveledEvent(Habbo habbo, Achievement achievement, AchievementLevel oldLevel, AchievementLevel newLevel) - { + public UserAchievementLeveledEvent(Habbo habbo, Achievement achievement, AchievementLevel oldLevel, AchievementLevel newLevel) { super(habbo, achievement); this.oldLevel = oldLevel; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementProgressEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementProgressEvent.java index 071a92f3..8074f198 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementProgressEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/achievements/UserAchievementProgressEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users.achievements; import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.users.Habbo; -public class UserAchievementProgressEvent extends UserAchievementEvent -{ +public class UserAchievementProgressEvent extends UserAchievementEvent { public final int progressed; - public UserAchievementProgressEvent(Habbo habbo, Achievement achievement, int progressed) - { + public UserAchievementProgressEvent(Habbo habbo, Achievement achievement, int progressed) { super(habbo, achievement); this.progressed = progressed; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogEvent.java index b5c5dc8e..6fe222af 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogEvent.java @@ -4,14 +4,12 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public class UserCatalogEvent extends UserEvent -{ +public class UserCatalogEvent extends UserEvent { public CatalogItem catalogItem; - public UserCatalogEvent(Habbo habbo, CatalogItem catalogItem) - { + public UserCatalogEvent(Habbo habbo, CatalogItem catalogItem) { super(habbo); this.catalogItem = catalogItem; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java index 608ee5a9..2e38aa88 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java @@ -5,14 +5,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -public class UserCatalogFurnitureBoughtEvent extends UserCatalogEvent -{ +public class UserCatalogFurnitureBoughtEvent extends UserCatalogEvent { public final THashSet furniture; - public UserCatalogFurnitureBoughtEvent( Habbo habbo, CatalogItem catalogItem ,THashSet furniture) - { + public UserCatalogFurnitureBoughtEvent(Habbo habbo, CatalogItem catalogItem, THashSet furniture) { super(habbo, catalogItem); this.furniture = furniture; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java index dc004078..d95bc226 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java @@ -7,8 +7,7 @@ import gnu.trove.set.hash.THashSet; import java.util.List; -public class UserCatalogItemPurchasedEvent extends UserCatalogEvent -{ +public class UserCatalogItemPurchasedEvent extends UserCatalogEvent { public final THashSet itemsList; @@ -22,13 +21,12 @@ public class UserCatalogItemPurchasedEvent extends UserCatalogEvent public List badges; - public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, THashSet itemsList, int totalCredits, int totalPoints, List badges) - { + public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, THashSet itemsList, int totalCredits, int totalPoints, List badges) { super(habbo, catalogItem); - this.itemsList = itemsList; + this.itemsList = itemsList; this.totalCredits = totalCredits; - this.totalPoints = totalPoints; - this.badges = badges; + this.totalPoints = totalPoints; + this.badges = badges; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserAcceptFriendRequestEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserAcceptFriendRequestEvent.java index 893aad9e..12b54561 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserAcceptFriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserAcceptFriendRequestEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.plugin.events.users.friends; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; -public class UserAcceptFriendRequestEvent extends UserFriendEvent -{ +public class UserAcceptFriendRequestEvent extends UserFriendEvent { - public UserAcceptFriendRequestEvent(Habbo habbo, MessengerBuddy friend) - { + public UserAcceptFriendRequestEvent(Habbo habbo, MessengerBuddy friend) { super(habbo, friend); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendChatEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendChatEvent.java index 168586eb..144ef541 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendChatEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendChatEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.plugin.events.users.friends; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; -public class UserFriendChatEvent extends UserFriendEvent -{ +public class UserFriendChatEvent extends UserFriendEvent { public String message; - public UserFriendChatEvent(Habbo habbo, MessengerBuddy friend, String message) - { + public UserFriendChatEvent(Habbo habbo, MessengerBuddy friend, String message) { super(habbo, friend); this.message = message; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendEvent.java index ab5b2138..4cf600e2 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserFriendEvent.java @@ -4,13 +4,11 @@ import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public abstract class UserFriendEvent extends UserEvent -{ +public abstract class UserFriendEvent extends UserEvent { public final MessengerBuddy friend; - public UserFriendEvent(Habbo habbo, MessengerBuddy friend) - { + public UserFriendEvent(Habbo habbo, MessengerBuddy friend) { super(habbo); this.friend = friend; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRelationShipEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRelationShipEvent.java index 8cec4d97..416c58a8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRelationShipEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRelationShipEvent.java @@ -3,13 +3,11 @@ package com.eu.habbo.plugin.events.users.friends; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; -public class UserRelationShipEvent extends UserFriendEvent -{ +public class UserRelationShipEvent extends UserFriendEvent { public int relationShip; - public UserRelationShipEvent(Habbo habbo, MessengerBuddy friend, int relationShip) - { + public UserRelationShipEvent(Habbo habbo, MessengerBuddy friend, int relationShip) { super(habbo, friend); this.relationShip = relationShip; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRequestFriendshipEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRequestFriendshipEvent.java index 17dcfb91..7e825596 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRequestFriendshipEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/friends/UserRequestFriendshipEvent.java @@ -3,8 +3,7 @@ package com.eu.habbo.plugin.events.users.friends; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.UserEvent; -public class UserRequestFriendshipEvent extends UserEvent -{ +public class UserRequestFriendshipEvent extends UserEvent { public final String name; @@ -12,8 +11,7 @@ public class UserRequestFriendshipEvent extends UserEvent public final Habbo friend; - public UserRequestFriendshipEvent(Habbo habbo, String name, Habbo friend) - { + public UserRequestFriendshipEvent(Habbo habbo, String name, Habbo friend) { super(habbo); this.name = name; diff --git a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java index 7e927fbb..be426435 100644 --- a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java +++ b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java @@ -6,26 +6,20 @@ import java.io.IOException; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; -public class HabboExecutorService extends ScheduledThreadPoolExecutor -{ - public HabboExecutorService(int corePoolSize, ThreadFactory threadFactory) - { +public class HabboExecutorService extends ScheduledThreadPoolExecutor { + public HabboExecutorService(int corePoolSize, ThreadFactory threadFactory) { super(corePoolSize, threadFactory); } @Override - protected void afterExecute(Runnable r, Throwable t) - { + protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); - if (t != null && !(t instanceof IOException)) - { - try - { + if (t != null && !(t instanceof IOException)) { + try { Emulator.getLogging().logErrorLine(t); + } catch (Exception e) { } - catch (Exception e) - {} } } } diff --git a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java index 22b9c39c..2888ed04 100644 --- a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java +++ b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java @@ -5,12 +5,10 @@ import com.eu.habbo.Emulator; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; -public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler -{ +public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler { @Override - public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) - { + public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { Emulator.getLogging().logErrorLine(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 8500112d..349781a7 100644 --- a/src/main/java/com/eu/habbo/threading/ThreadPooling.java +++ b/src/main/java/com/eu/habbo/threading/ThreadPooling.java @@ -7,90 +7,67 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -public class ThreadPooling -{ +public class ThreadPooling { public final int threads; private final ScheduledExecutorService scheduledPool; private volatile boolean canAdd; - public ThreadPooling(Integer threads) - { + public ThreadPooling(Integer threads) { this.threads = threads; this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("ArcturusThreadFactory")); this.canAdd = true; Emulator.getLogging().logStart("Thread Pool -> Loaded!"); } - public ScheduledFuture run(Runnable run) - { - try - { - if (this.canAdd) - { + public ScheduledFuture run(Runnable run) { + try { + if (this.canAdd) { return this.run(run, 0); - } - else - { - if (Emulator.isShuttingDown) - { + } else { + if (Emulator.isShuttingDown) { run.run(); } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - public ScheduledFuture run(Runnable run, long delay) - { - try - { - if (this.canAdd) - { - return this.scheduledPool.schedule(new Runnable() - { + public ScheduledFuture run(Runnable run, long delay) { + try { + if (this.canAdd) { + return this.scheduledPool.schedule(new Runnable() { @Override - public void run() - { - try - { + public void run() { + try { run.run(); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } }, delay, TimeUnit.MILLISECONDS); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } return null; } - public void shutDown() - { + public void shutDown() { this.canAdd = false; this.scheduledPool.shutdownNow(); Emulator.getLogging().logShutdownLine("Threading -> Disposed!"); } - public void setCanAdd(boolean canAdd) - { + public void setCanAdd(boolean canAdd) { this.canAdd = canAdd; } - public ScheduledExecutorService getService() - { + public ScheduledExecutorService getService() { return this.scheduledPool; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java b/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java index 81f54493..2ee1dcbf 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java +++ b/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java @@ -7,29 +7,24 @@ import com.eu.habbo.habbohotel.users.Habbo; import java.util.Map; -public class AchievementUpdater implements Runnable -{ +public class AchievementUpdater implements Runnable { public static final int INTERVAL = 5 * 60; public int lastExecutionTimestamp = Emulator.getIntUnixTimestamp(); + @Override - public void run() - { - if (!Emulator.isShuttingDown) - { + public void run() { + if (!Emulator.isShuttingDown) { Emulator.getThreading().run(this, INTERVAL * 1000); } - if (Emulator.isReady) - { + if (Emulator.isReady) { Achievement onlineTime = Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"); int timestamp = Emulator.getIntUnixTimestamp(); - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) - { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { int timeOnlineSinceLastInterval = INTERVAL; Habbo habbo = set.getValue(); - if (habbo.getHabboInfo().getLastOnline() > this.lastExecutionTimestamp) - { + if (habbo.getHabboInfo().getLastOnline() > this.lastExecutionTimestamp) { timeOnlineSinceLastInterval = timestamp - habbo.getHabboInfo().getLastOnline(); } AchievementManager.progressAchievement(habbo, onlineTime, (int) Math.floor((timeOnlineSinceLastInterval) / 60)); 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 e276c776..e3fafa53 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java @@ -4,30 +4,25 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -public class BackgroundAnimation implements Runnable -{ - private int length = 1000; - private int state = 0; +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) - { + public BackgroundAnimation(HabboItem toner, Room room) { this.toner = toner; this.room = room; } @Override - public void run() - { - if(this.room.isLoaded() && !this.room.isPreLoaded()) - { + public void run() { + if (this.room.isLoaded() && !this.room.isPreLoaded()) { this.toner.setExtradata("1:" + this.state + ":126:126"); this.state = (this.state + 1) % 256; this.room.updateItem(this.toner); - if (this.toner.getRoomId() > 0 && this.length > 0) - { + if (this.toner.getRoomId() > 0 && this.length > 0) { Emulator.getThreading().run(this, 500); this.length--; } 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 3b601716..c372652a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -4,18 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class BanzaiRandomTeleport implements Runnable -{ +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) - { + public BanzaiRandomTeleport(HabboItem item, HabboItem toItem, RoomUnit habbo, Room room) { this.item = item; this.toItem = toItem; this.habbo = habbo; @@ -23,8 +20,7 @@ public class BanzaiRandomTeleport implements Runnable } @Override - public void run() - { + public void run() { this.habbo.setCanWalk(true); this.item.setExtradata("0"); this.toItem.setExtradata("0"); 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 6cc2ff2d..331cf787 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -7,8 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -public class BattleBanzaiTilesFlicker implements Runnable -{ +public class BattleBanzaiTilesFlicker implements Runnable { private final THashSet items; private final GameTeamColors color; private final Room room; @@ -16,40 +15,32 @@ public class BattleBanzaiTilesFlicker implements Runnable private boolean on = false; private int count = 0; - public BattleBanzaiTilesFlicker(THashSet items, GameTeamColors color, Room room) - { + public BattleBanzaiTilesFlicker(THashSet items, GameTeamColors color, Room room) { this.items = items; this.color = color; this.room = room; } @Override - public void run() - { - if(this.items == null || this.room == null) + public void run() { + if (this.items == null || this.room == null) return; int state = 0; - if(this.on) - { + if (this.on) { state = (this.color.type * 3) + 5; this.on = false; - } - else - { + } else { this.on = true; } - for(HabboItem item : this.items) - { + for (HabboItem item : this.items) { item.setExtradata(state + ""); this.room.updateItem(item); } - if(this.count == 5) - { - for(HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) - { + if (this.count == 5) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("0"); this.room.updateItemState(item); } 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 efd508b3..b6926f62 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java @@ -6,41 +6,31 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -public class BotFollowHabbo implements Runnable -{ +public class BotFollowHabbo implements Runnable { private final Bot bot; private final Habbo habbo; private final Room room; - public BotFollowHabbo(Bot bot, Habbo habbo, Room room) - { + public BotFollowHabbo(Bot bot, Habbo habbo, Room room) { this.bot = bot; this.habbo = habbo; this.room = room; } @Override - public void run() - { - if (this.bot != null) - { - if (this.habbo != null && this.bot.getFollowingHabboId() == this.habbo.getHabboInfo().getId()) - { - if(this.habbo.getHabboInfo().getCurrentRoom() != null && this.habbo.getHabboInfo().getCurrentRoom() == this.room) - { - if (this.habbo.getRoomUnit() != null) - { - if (this.bot.getRoomUnit() != null) - { + public void run() { + if (this.bot != null) { + if (this.habbo != null && this.bot.getFollowingHabboId() == this.habbo.getHabboInfo().getId()) { + if (this.habbo.getHabboInfo().getCurrentRoom() != null && this.habbo.getHabboInfo().getCurrentRoom() == this.room) { + if (this.habbo.getRoomUnit() != null) { + if (this.bot.getRoomUnit() != null) { RoomTile target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + 4)) % 8); - if (target != null) - { + if (target != null) { if (target.x < 0 || target.y < 0) target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue()); - if (target.x >= 0 && target.y >= 0) - { + if (target.x >= 0 && target.y >= 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 81e3db8a..507330f1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java @@ -4,36 +4,24 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.Logging; import com.eu.habbo.networking.camera.CameraClient; -public class CameraClientAutoReconnect implements Runnable -{ +public class CameraClientAutoReconnect implements Runnable { @Override - public void run() - { - if (CameraClient.attemptReconnect && !Emulator.isShuttingDown) - { - if (!(CameraClient.channelFuture != null && CameraClient.channelFuture.channel().isRegistered())) - { + public void run() { + if (CameraClient.attemptReconnect && !Emulator.isShuttingDown) { + if (!(CameraClient.channelFuture != null && CameraClient.channelFuture.channel().isRegistered())) { System.out.println("[" + Logging.ANSI_YELLOW + "CAMERA" + Logging.ANSI_RESET + "] Attempting to connect to the Camera server."); - if (Emulator.getCameraClient() != null) - { + if (Emulator.getCameraClient() != null) { Emulator.getCameraClient().disconnect(); - } - else - { + } else { Emulator.setCameraClient(new CameraClient()); } - try - { + try { Emulator.getCameraClient().connect(); - } - catch (Exception e) - { + } catch (Exception e) { System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to start the camera client."); } - } - else - { + } else { CameraClient.attemptReconnect = false; System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] 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 dcc4bc0e..65eff558 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -13,24 +13,20 @@ import gnu.trove.map.hash.THashMap; import java.util.List; -public class CannonKickAction implements Runnable -{ +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) - { + public CannonKickAction(InteractionCannon cannon, Room room, GameClient client) { this.cannon = cannon; this.room = room; this.client = client; } @Override - public void run() - { - if (this.client != null) - { + public void run() { + if (this.client != null) { this.client.getHabbo().getRoomUnit().setCanWalk(true); } THashMap dater = new THashMap<>(); @@ -42,12 +38,9 @@ public class CannonKickAction implements Runnable int rotation = this.cannon.getRotation(); List tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3); - for(RoomTile t : tiles) - { - for(Habbo habbo : this.room.getHabbosAt(t.x, t.y)) - { - if(!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) - { + for (RoomTile t : tiles) { + for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) { + 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 59ca5d8c..5155a6ea 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonResetCooldownAction.java @@ -2,20 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.items.interactions.InteractionCannon; -public class CannonResetCooldownAction implements Runnable -{ +public class CannonResetCooldownAction implements Runnable { private final InteractionCannon cannon; - public CannonResetCooldownAction(InteractionCannon cannon) - { + public CannonResetCooldownAction(InteractionCannon cannon) { this.cannon = cannon; } @Override - public void run() - { - if(this.cannon != null) - { + public void run() { + if (this.cannon != null) { this.cannon.cooldown = false; } } 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 a2ac561b..f21cbea6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ChannelReadHandler.java @@ -8,39 +8,32 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -public class ChannelReadHandler implements Runnable -{ +public class ChannelReadHandler implements Runnable { private final ChannelHandlerContext ctx; private final Object msg; - public ChannelReadHandler(ChannelHandlerContext ctx, Object msg) - { + public ChannelReadHandler(ChannelHandlerContext ctx, Object msg) { this.ctx = ctx; this.msg = msg; } - public void run() - { + public void run() { ByteBuf m = (ByteBuf) this.msg; int length = m.readInt(); short header = m.readShort(); GameClient client = this.ctx.channel().attr(GameClientManager.CLIENT).get(); - if (client != null) - { + if (client != null) { int count = 0; int timestamp = Emulator.getIntUnixTimestamp(); - if (timestamp - client.lastPacketCounterCleared > 1) - { + if (timestamp - client.lastPacketCounterCleared > 1) { client.incomingPacketCounter.clear(); client.lastPacketCounterCleared = timestamp; - } else - { + } else { count = client.incomingPacketCounter.getOrDefault(header, 0); } - if (count <= 10) - { + if (count <= 10) { count++; client.incomingPacketCounter.put((int) header, count); ByteBuf body = Unpooled.wrappedBuffer(m.readBytes(m.readableBytes())); 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 a979a702..0349a434 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -9,28 +9,22 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import gnu.trove.set.hash.THashSet; -public class ClearRentedSpace implements Runnable -{ +public class ClearRentedSpace implements Runnable { private final InteractionRentableSpace item; private final Room room; - public ClearRentedSpace(InteractionRentableSpace item, Room room) - { + public ClearRentedSpace(InteractionRentableSpace item, Room room) { this.item = item; this.room = room; } @Override - public void run() - { + public void run() { THashSet items = new THashSet<>(); - for(RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) - { - for(HabboItem i : this.room.getItemsAt(t)) - { - if(i.getUserId() == this.item.getRenterId()) - { + for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { + for (HabboItem i : this.room.getItemsAt(t)) { + if (i.getUserId() == this.item.getRenterId()) { items.add(i); i.setRoomId(0); i.needsUpdate(true); @@ -40,16 +34,12 @@ public class ClearRentedSpace implements Runnable Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.item.getRenterId()); - if(owner != null) - { + if (owner != null) { owner.getClient().sendResponse(new AddHabboItemComposer(items)); owner.getHabboStats().rentedItemId = 0; owner.getHabboStats().rentedTimeEnd = 0; - } - else - { - for(HabboItem i : items) - { + } 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 233f9720..f63e6f47 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java @@ -3,26 +3,20 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -public class CloseGate implements Runnable -{ +public class CloseGate implements Runnable { private final HabboItem guildGate; private final Room room; - public CloseGate(HabboItem guildGate, Room room) - { + public CloseGate(HabboItem guildGate, Room room) { this.guildGate = guildGate; this.room = room; } @Override - public void run() - { - if(this.guildGate.getRoomId() == this.room.getId()) - { - if(this.room.isLoaded()) - { - if(this.room.getHabbosAt(this.guildGate.getX(), this.guildGate.getY()).isEmpty()) - { + public void run() { + if (this.guildGate.getRoomId() == this.room.getId()) { + if (this.room.isLoaded()) { + if (this.room.getHabbosAt(this.guildGate.getX(), this.guildGate.getY()).isEmpty()) { this.guildGate.setExtradata("0"); this.room.updateItem(this.guildGate); this.guildGate.needsUpdate(true); 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 2ef1e34d..d39b2f57 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -11,8 +11,7 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.rooms.items.AddFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; -public class CrackableExplode implements Runnable -{ +public class CrackableExplode implements Runnable { private final Room room; private final InteractionCrackable habboItem; private final Habbo habbo; @@ -20,8 +19,7 @@ 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) - { + public CrackableExplode(Room room, InteractionCrackable item, Habbo habbo, boolean toInventory, short x, short y) { this.room = room; this.habboItem = item; this.habbo = habbo; @@ -32,40 +30,30 @@ public class CrackableExplode implements Runnable } @Override - public void run() - { - if (this.habboItem.getRoomId() == 0) - { + public void run() { + if (this.habboItem.getRoomId() == 0) { return; } //MAKING DINNER BRB - if (!this.habboItem.resetable()) - { + if (!this.habboItem.resetable()) { this.room.removeHabboItem(this.habboItem); this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose()); this.habboItem.setRoomId(0); Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem); - } - else - { + } else { this.habboItem.reset(this.room); } Item rewardItem = Emulator.getGameEnvironment().getItemManager().getCrackableReward(this.habboItem.getBaseItem().getId()); - if (rewardItem != null) - { + if (rewardItem != null) { HabboItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getUserId(), rewardItem, 0, 0, ""); - if (newItem != null) - { - if (this.toInventory) - { + if (newItem != null) { + if (this.toInventory) { this.habbo.getInventory().getItemsComponent().addItem(newItem); this.habbo.getClient().sendResponse(new AddHabboItemComposer(newItem)); this.habbo.getClient().sendResponse(new InventoryRefreshComposer()); - } - else - { + } else { newItem.setX(this.x); newItem.setY(this.y); newItem.setZ(this.room.getStackHeight(this.x, this.y, false)); 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 caf3546d..8885ef9f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianNotAccepted.java @@ -6,26 +6,21 @@ import com.eu.habbo.habbohotel.guides.GuardianVote; import com.eu.habbo.habbohotel.guides.GuardianVoteType; import com.eu.habbo.habbohotel.users.Habbo; -public class GuardianNotAccepted implements Runnable -{ +public class GuardianNotAccepted implements Runnable { private final GuardianTicket ticket; private final Habbo habbo; - public GuardianNotAccepted(GuardianTicket ticket, Habbo habbo) - { + public GuardianNotAccepted(GuardianTicket ticket, Habbo habbo) { this.ticket = ticket; this.habbo = habbo; } @Override - public void run() - { + public void run() { GuardianVote vote = this.ticket.getVoteForGuardian(this.habbo); - if(vote != null) - { - if(vote.type == GuardianVoteType.SEARCHING) - { + if (vote != null) { + if (vote.type == GuardianVoteType.SEARCHING) { Emulator.getGameEnvironment().getGuideManager().acceptTicket(this.habbo, false); } } 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 1757af20..b0434c6a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianTicketFindMoreSlaves.java @@ -3,18 +3,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuardianTicket; -public class GuardianTicketFindMoreSlaves implements Runnable -{ +public class GuardianTicketFindMoreSlaves implements Runnable { private final GuardianTicket ticket; - public GuardianTicketFindMoreSlaves(GuardianTicket ticket) - { + public GuardianTicketFindMoreSlaves(GuardianTicket ticket) { this.ticket = ticket; } @Override - public void run() - { + public void run() { Emulator.getGameEnvironment().getGuideManager().findGuardians(this.ticket); } } 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 8e1caed2..15a361ea 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuardianVotingFinish.java @@ -2,24 +2,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.guides.GuardianTicket; -public class GuardianVotingFinish implements Runnable -{ +public class GuardianVotingFinish implements Runnable { private final GuardianTicket ticket; private int checkSum; - public GuardianVotingFinish(GuardianTicket ticket) - { + public GuardianVotingFinish(GuardianTicket ticket) { this.ticket = ticket; this.checkSum = this.ticket.getCheckSum(); } @Override - public void run() - { - if(this.ticket.inProgress()) - { - if(this.ticket.getCheckSum() == this.checkSum) - { + public void run() { + if (this.ticket.inProgress()) { + if (this.ticket.getCheckSum() == this.checkSum) { this.ticket.finish(); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/GuideFindNewHelper.java b/src/main/java/com/eu/habbo/threading/runnables/GuideFindNewHelper.java index 8770f96c..cb873097 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/GuideFindNewHelper.java +++ b/src/main/java/com/eu/habbo/threading/runnables/GuideFindNewHelper.java @@ -5,26 +5,21 @@ import com.eu.habbo.habbohotel.guides.GuideTour; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.guides.GuideSessionDetachedComposer; -public class GuideFindNewHelper implements Runnable -{ +public class GuideFindNewHelper implements Runnable { private final GuideTour tour; private final Habbo helper; private final int checkSum; - public GuideFindNewHelper(GuideTour tour, Habbo helper) - { + public GuideFindNewHelper(GuideTour tour, Habbo helper) { this.tour = tour; this.helper = helper; this.checkSum = tour.checkSum; } @Override - public void run() - { - if(!this.tour.isEnded() && this.tour.checkSum == this.checkSum && this.tour.getHelper() == null) - { - if(this.helper != null && this.helper.getClient() != null) - { + public void run() { + if (!this.tour.isEnded() && this.tour.checkSum == this.checkSum && this.tour.getHelper() == null) { + if (this.helper != null && this.helper.getClient() != null) { this.helper.getClient().sendResponse(new GuideSessionDetachedComposer()); } 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 d1d6386d..3c29ee52 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java @@ -4,30 +4,26 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserHandItemComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserReceivedHandItemComposer; -public class HabboGiveHandItemToHabbo implements Runnable -{ +public class HabboGiveHandItemToHabbo implements Runnable { private final Habbo target; private final Habbo from; - public HabboGiveHandItemToHabbo(Habbo from, Habbo target) - { + 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) + public void run() { + if (this.from.getHabboInfo().getCurrentRoom() == null || this.target.getHabboInfo().getCurrentRoom() == null) return; - if(this.from.getHabboInfo().getCurrentRoom() != this.target.getHabboInfo().getCurrentRoom()) + if (this.from.getHabboInfo().getCurrentRoom() != this.target.getHabboInfo().getCurrentRoom()) return; int itemId = this.from.getRoomUnit().getHandItem(); - if(itemId > 0) - { + if (itemId > 0) { this.from.getRoomUnit().setHandItem(0); this.from.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(this.from.getRoomUnit()).compose()); this.target.getClient().sendResponse(new RoomUserReceivedHandItemComposer(this.from.getRoomUnit(), itemId)); 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 cc57a8ee..4bb3875e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java @@ -3,26 +3,22 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -public class HabboItemNewState implements Runnable -{ +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) - { + public HabboItemNewState(HabboItem item, Room room, String state) { this.item = item; this.room = room; this.state = state; } @Override - public void run() - { + public void run() { this.item.setExtradata(this.state); - if(this.item.getRoomId() == this.room.getId()) - { + if (this.item.getRoomId() == this.room.getId()) { this.room.updateItemState(this.item); } } 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 95ca6e99..cda020d6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -5,20 +5,16 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import java.sql.*; -public class InsertModToolIssue implements Runnable -{ +public class InsertModToolIssue implements Runnable { private final ModToolIssue issue; - public InsertModToolIssue(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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) - { + 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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.issue.state.getState()); statement.setInt(2, this.issue.timestamp); statement.setInt(3, this.issue.priority); @@ -30,16 +26,12 @@ public class InsertModToolIssue implements Runnable statement.setInt(9, this.issue.category); statement.execute(); - try (ResultSet key = statement.getGeneratedKeys()) - { - if (key.first()) - { + try (ResultSet key = statement.getGeneratedKeys()) { + if (key.first()) { this.issue.id = key.getInt(1); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 c888eedb..d4f5b1bf 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java @@ -14,13 +14,12 @@ public class KickBallAction implements Runnable { private final InteractionPushable ball; //The item which is moving private final Room room; //The room that the item belongs to private final RoomUnit kicker; //The Habbo which initiated the move of the item - private RoomUserRotation currentDirection; //The current direction the item is moving in private final int totalSteps; //The total number of steps in the move sequence - private int currentStep; //The current step of the move sequence public boolean dead = false; //When true the run() function will not execute. Used when another user kicks the ball whilst it is arleady moving. + private RoomUserRotation currentDirection; //The current direction the item is moving in + private int currentStep; //The current step of the move sequence - public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomUserRotation direction, int steps) - { + public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomUserRotation direction, int steps) { this.ball = ball; this.room = room; this.kicker = kicker; @@ -30,55 +29,42 @@ public class KickBallAction implements Runnable { } @Override - public void run() - { - if(this.dead || !this.room.isLoaded()) + public void run() { + if (this.dead || !this.room.isLoaded()) return; - if(this.currentStep < this.totalSteps) - { + if (this.currentStep < this.totalSteps) { RoomTile currentTile = this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()); RoomTile next = this.room.getLayout().getTileInFront(currentTile, this.currentDirection.getValue()); - if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) - { + if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) { RoomUserRotation oldDirection = this.currentDirection; this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection); - if(this.currentDirection != oldDirection) - { + if (this.currentDirection != oldDirection) { this.ball.onBounce(this.room, oldDirection, this.currentDirection, this.kicker); - } - else - { + } else { this.currentStep = this.totalSteps; //End the move sequence, the ball can't bounce anywhere } this.run(); - } - else - { + } else { //Move the ball & run again this.currentStep++; int delay = this.ball.getNextRollDelay(this.currentStep, this.totalSteps); //Algorithm to work out the delay till next run - if(this.ball.canStillMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps)) - { + if (this.ball.canStillMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps)) { this.ball.onMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps); this.room.sendComposer(new FloorItemOnRollerComposer(this.ball, null, next, next.getStackHeight() - this.ball.getZ(), this.room).compose()); - Emulator.getThreading().run(this, (long)delay); - } - else - { + Emulator.getThreading().run(this, (long) delay); + } else { this.currentStep = this.totalSteps; //End the move sequence, the ball can't bounce anywhere this.run(); } } - } - else - { + } else { //We're done with the move sequence. Stop it the sequence & end the thread. this.ball.onStop(this.room, this.kicker, this.currentStep, this.totalSteps); this.dead = true; 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 51b6b6aa..5de407fa 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java +++ b/src/main/java/com/eu/habbo/threading/runnables/LoadCustomHeightMap.java @@ -3,18 +3,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -public class LoadCustomHeightMap implements Runnable -{ +public class LoadCustomHeightMap implements Runnable { private final Room room; - public LoadCustomHeightMap(Room room) - { + public LoadCustomHeightMap(Room room) { this.room = room; } @Override - public void run() - { + 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 b67dec34..0cb6ae50 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -7,39 +7,32 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class OneWayGateActionOne implements Runnable -{ +public class OneWayGateActionOne implements Runnable { private HabboItem oneWayGate; private Room room; private GameClient client; - public OneWayGateActionOne(GameClient client, Room room, HabboItem item) - { + public OneWayGateActionOne(GameClient client, Room room, HabboItem item) { this.oneWayGate = item; this.room = room; this.client = client; } @Override - public void run() - { + public void run() { this.room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit()).compose()); RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getX(), this.oneWayGate.getY()), (this.oneWayGate.getRotation() + 4) % 8); - - if(this.client.getHabbo().getRoomUnit().animateWalk) - { + + if (this.client.getHabbo().getRoomUnit().animateWalk) { this.client.getHabbo().getRoomUnit().animateWalk = false; } - if (t.isWalkable()) - { - if (this.room.tileWalkable(t) && this.client.getHabbo().getRoomUnit().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getY() == this.oneWayGate.getY()) - { + if (t.isWalkable()) { + if (this.room.tileWalkable(t) && this.client.getHabbo().getRoomUnit().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getY() == this.oneWayGate.getY()) { this.client.getHabbo().getRoomUnit().setGoalLocation(t); - if (!this.oneWayGate.getExtradata().equals("0")) - { + if (!this.oneWayGate.getExtradata().equals("0")) { Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000); } } @@ -47,10 +40,8 @@ public class OneWayGateActionOne implements Runnable //{ //} - else - { - if (!this.oneWayGate.getExtradata().equals("0")) - { + else { + if (!this.oneWayGate.getExtradata().equals("0")) { Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000); } } 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 a9b56aef..07d84aae 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -1,14 +1,12 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.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.AddHabboItemComposer; -import com.eu.habbo.messages.outgoing.inventory.InventoryItemsComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryUpdateItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.PresentItemOpenedComposer; @@ -18,32 +16,26 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -public class OpenGift implements Runnable -{ +public class OpenGift implements Runnable { private final HabboItem item; private final Habbo habbo; private final Room room; - public OpenGift(HabboItem item, Habbo habbo, Room room) - { + public OpenGift(HabboItem item, Habbo habbo, Room room) { this.item = item; this.habbo = habbo; this.room = room; } @Override - public void run() - { - try - { + public void run() { + try { HabboItem inside = null; THashSet items = ((InteractionGift) this.item).loadItems(); - for (HabboItem i : items) - { - if(inside == null) + for (HabboItem i : items) { + if (inside == null) inside = i; i.setUserId(this.habbo.getHabboInfo().getId()); @@ -56,8 +48,7 @@ public class OpenGift implements Runnable this.habbo.getInventory().getItemsComponent().addItems(items); RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY()); - if (tile != null) - { + if (tile != null) { this.room.updateTile(tile); } @@ -72,26 +63,30 @@ public class OpenGift implements Runnable switch (item.getBaseItem().getType()) { case WALL: case FLOOR: - if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI, new ArrayList<>()); + if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI)) + unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI, new ArrayList<>()); unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI).add(item.getGiftAdjustedId()); break; case BADGE: - if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BADGE)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BADGE, new ArrayList<>()); + if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BADGE)) + unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BADGE, new ArrayList<>()); unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BADGE).add(item.getId()); // badges cannot be placed so no need for gift adjusted ID break; case PET: - if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.PET)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.PET, new ArrayList<>()); + if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.PET)) + unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.PET, new ArrayList<>()); unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.PET).add(item.getGiftAdjustedId()); break; case ROBOT: - if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BOT)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BOT, new ArrayList<>()); + if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BOT)) + unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BOT, new ArrayList<>()); unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BOT).add(item.getGiftAdjustedId()); break; @@ -100,14 +95,11 @@ public class OpenGift implements Runnable this.habbo.getClient().sendResponse(new AddHabboItemComposer(unseenItems)); - if (inside != null) - { + if (inside != null) { this.habbo.getClient().sendResponse(new InventoryUpdateItemComposer(inside)); this.habbo.getClient().sendResponse(new PresentItemOpenedComposer(inside, "", false)); } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(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 b0da3e13..199faf45 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetClearPosture.java @@ -4,15 +4,13 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -public class PetClearPosture implements Runnable -{ +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) - { + public PetClearPosture(Pet pet, RoomUnitStatus key, PetTasks newTask, boolean clearTask) { this.pet = pet; this.key = key; this.newTask = newTask; @@ -20,21 +18,16 @@ public class PetClearPosture implements Runnable } @Override - public void run() - { - if(this.pet != null) - { - if(this.pet.getRoom() != null) - { - if(this.pet.getRoomUnit() != null) - { + public void run() { + if (this.pet != null) { + if (this.pet.getRoom() != null) { + if (this.pet.getRoomUnit() != null) { this.pet.getRoomUnit().removeStatus(this.key); - if(this.clearTask) + if (this.clearTask) this.pet.setTask(PetTasks.FREE); - else - if(this.newTask != null) - this.pet.setTask(this.newTask); + else if (this.newTask != null) + this.pet.setTask(this.newTask); } } } 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 8341fa3a..28c0cf96 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java @@ -10,24 +10,19 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class PetEatAction implements Runnable -{ +public class PetEatAction implements Runnable { private final Pet pet; private final InteractionPetFood food; - public PetEatAction(Pet pet, 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()) - { + 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()) { this.pet.addHunger(-20); this.pet.setTask(PetTasks.EAT); this.pet.getRoomUnit().setCanWalk(false); @@ -35,30 +30,21 @@ public class PetEatAction implements Runnable this.food.setExtradata(Integer.valueOf(this.food.getExtradata()) + 1 + ""); this.pet.getRoom().updateItem(this.food); - if (this.pet instanceof GnomePet) - { - if (this.pet.getPetData().getType() == 26) - { + if (this.pet instanceof GnomePet) { + if (this.pet.getPetData().getType() == 26) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GnomeFeeding"), 20); - } - else - { + } else { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("LeprechaunFeeding"), 20); } - } - else - { + } else { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetFeeding"), 20); } Emulator.getThreading().run(this, 1000); - } else - { - if (this.food != null && Integer.valueOf(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) - { + } else { + if (this.food != null && Integer.valueOf(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.food.getId()), 500); - if (this.pet.getRoom() != null) - { + if (this.pet.getRoom() != null) { this.pet.getRoom().removeHabboItem(this.food); this.pet.getRoom().sendComposer(new RemoveFloorItemComposer(this.food, true).compose()); } 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 636e86c9..b790916f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -6,44 +6,34 @@ import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -public class PetFollowHabbo implements Runnable -{ +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) - { + public PetFollowHabbo(Pet pet, Habbo habbo, int offset) { this.pet = pet; this.habbo = habbo; this.directionOffset = offset; } @Override - public void run() - { - if (this.pet != null) - { + public void run() { + if (this.pet != null) { if (this.pet.getTask() != PetTasks.FOLLOW) return; - if (this.habbo != null) - { - if (this.habbo.getRoomUnit() != null) - { - if (this.pet.getRoomUnit() != null) - { + if (this.habbo != null) { + if (this.habbo.getRoomUnit() != null) { + if (this.pet.getRoomUnit() != null) { 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 != null) { if (target.x < 0 || target.y < 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.x >= 0 && target.y >= 0) { + if (this.pet.getRoom().getLayout().tileWalkable(target.x, target.y)) { 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 59eeea1e..7cef3cff 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java @@ -7,27 +7,22 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -class QueryDeleteHabboBadge implements Runnable -{ +class QueryDeleteHabboBadge implements Runnable { private final String name; private final Habbo habbo; - public QueryDeleteHabboBadge(Habbo habbo, String name) - { + public QueryDeleteHabboBadge(Habbo habbo, String name) { this.name = name; this.habbo = habbo; } + @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM user_badges WHERE users_id = ? AND badge_code = ?")) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM user_badges WHERE users_id = ? AND badge_code = ?")) { statement.setInt(1, this.habbo.getHabboInfo().getId()); statement.setString(2, this.name); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 084dddcb..b8fb5746 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -7,30 +7,23 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class QueryDeleteHabboItem implements Runnable -{ +public class QueryDeleteHabboItem implements Runnable { private final int itemId; - public QueryDeleteHabboItem(int itemId) - { + public QueryDeleteHabboItem(int itemId) { this.itemId = itemId; } - public QueryDeleteHabboItem(HabboItem item) - { + public QueryDeleteHabboItem(HabboItem item) { this.itemId = item.getId(); } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { statement.setInt(1, this.itemId); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 214cf35f..0b6b0647 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -8,22 +8,17 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class QueryDeleteHabboItems implements Runnable -{ +public class QueryDeleteHabboItems implements Runnable { private TIntObjectMap items; - public QueryDeleteHabboItems(TIntObjectMap items) - { + public QueryDeleteHabboItems(TIntObjectMap items) { this.items = items; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) - { - for (HabboItem item : this.items.valueCollection()) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { + for (HabboItem item : this.items.valueCollection()) { if (item.getRoomId() > 0) continue; @@ -32,9 +27,7 @@ public class QueryDeleteHabboItems implements Runnable } statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java index 650663dc..e6c83600 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java @@ -5,23 +5,20 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionColorWheel; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -public class RandomDiceNumber implements Runnable -{ +public class RandomDiceNumber implements Runnable { private final HabboItem item; private final Room room; private final int maxNumber; private int result; - public RandomDiceNumber(HabboItem item, Room room, int maxNumber) - { + public RandomDiceNumber(HabboItem item, Room room, int maxNumber) { this.item = item; this.room = room; this.maxNumber = maxNumber; this.result = -1; } - public RandomDiceNumber(Room room, HabboItem item, int result) - { + public RandomDiceNumber(Room room, HabboItem item, int result) { this.item = item; this.room = room; this.maxNumber = -1; @@ -29,9 +26,8 @@ public class RandomDiceNumber implements Runnable } @Override - public void run() - { - if(this.result <= 0) + public void run() { + if (this.result <= 0) this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1); this.item.setExtradata(this.result + ""); @@ -39,9 +35,8 @@ public class RandomDiceNumber implements Runnable Emulator.getThreading().run(this.item); this.room.updateItem(this.item); - if(this.item instanceof InteractionColorWheel) - { - ((InteractionColorWheel)this.item).clearRunnable(); + if (this.item instanceof InteractionColorWheel) { + ((InteractionColorWheel) this.item).clearRunnable(); } } } 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 9fc3f109..f03b76d9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -6,21 +6,18 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; -class RemoveFloorItemTask implements Runnable -{ +class RemoveFloorItemTask implements Runnable { private final Room room; private final HabboItem item; - public RemoveFloorItemTask(Room room, HabboItem item) - { + public RemoveFloorItemTask(Room room, HabboItem item) { this.room = room; this.item = item; } @Override - public void run() - { - if(this.item == null || this.room == null) + public void run() { + if (this.item == null || this.room == null) return; RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY()); 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 6d2eee46..4e645380 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java @@ -11,45 +11,33 @@ import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.users.UserTakeStepEvent; import gnu.trove.set.hash.THashSet; -public class RoomTrashing implements Runnable -{ +public class RoomTrashing implements Runnable { public static RoomTrashing INSTANCE; private Habbo habbo; private Room room; - public RoomTrashing(Habbo habbo, Room room) - { + public RoomTrashing(Habbo habbo, Room room) { this.habbo = habbo; this.room = room; RoomTrashing.INSTANCE = this; } - @Override - public void run() - { - - } - @EventHandler - public static void onUserWalkEvent(UserTakeStepEvent event) - { - if(INSTANCE == null) + public static void onUserWalkEvent(UserTakeStepEvent event) { + if (INSTANCE == null) return; - if(INSTANCE.habbo == null) + if (INSTANCE.habbo == null) return; - if(!INSTANCE.habbo.isOnline()) + if (!INSTANCE.habbo.isOnline()) INSTANCE.habbo = null; - if(INSTANCE.habbo == event.habbo) - { - if(event.habbo.getHabboInfo().getCurrentRoom() != null) - { - if(event.habbo.getHabboInfo().getCurrentRoom().equals(INSTANCE.room)) - { + if (INSTANCE.habbo == event.habbo) { + if (event.habbo.getHabboInfo().getCurrentRoom() != null) { + if (event.habbo.getHabboInfo().getCurrentRoom().equals(INSTANCE.room)) { THashSet messages = new THashSet<>(); THashSet items = INSTANCE.room.getItemsAt(event.toLocation); @@ -57,22 +45,17 @@ public class RoomTrashing implements Runnable int offset = Emulator.getRandom().nextInt(4) + 2; RoomTile t = null; - while(offset > 0) - { + 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); - if(!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) - { + if (!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) { offset--; - } - else - { + } else { break; } } - for(HabboItem item : items) - { + for (HabboItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); @@ -82,29 +65,23 @@ public class RoomTrashing implements Runnable offset = Emulator.getRandom().nextInt(4) + 2; t = null; - while(offset > 0) - { + 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); - if(!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) - { + if (!INSTANCE.room.getLayout().tileWalkable(t.x, t.y)) { offset--; - } - else - { + } else { break; } } RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentLocation(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); - if (s != null) - { + if (s != null) { items = INSTANCE.room.getItemsAt(s); } - for(HabboItem item : items) - { + for (HabboItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); @@ -113,16 +90,12 @@ public class RoomTrashing implements Runnable offset = Emulator.getRandom().nextInt(4) + 2; t = null; - while(offset > 0) - { + 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.x, t.y)) { offset--; - } - else - { + } else { break; } } @@ -130,20 +103,16 @@ public class RoomTrashing implements Runnable s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentLocation(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); items = INSTANCE.room.getItemsAt(s); - for(HabboItem item : items) - { + for (HabboItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.x, t.y)) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } - for(ServerMessage message : messages) - { + for (ServerMessage message : messages) { INSTANCE.room.sendComposer(message); } - } - else - { + } else { INSTANCE.habbo = null; INSTANCE.room = null; } @@ -151,23 +120,24 @@ public class RoomTrashing implements Runnable } } - public Habbo getHabbo() - { + @Override + public void run() { + + } + + public Habbo getHabbo() { return this.habbo; } - public void setHabbo(Habbo habbo) - { + public void setHabbo(Habbo habbo) { this.habbo = habbo; } - public Room getRoom() - { + public Room getRoom() { return this.room; } - public void setRoom(Room room) - { + public void setRoom(Room room) { this.room = room; } } 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 38eaef16..d70a6845 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java @@ -4,24 +4,20 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserHandItemComposer; -public class RoomUnitGiveHanditem implements Runnable -{ +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) - { + 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()) - { + public void run() { + if (this.room != null && this.roomUnit.isInRoom()) { this.roomUnit.setHandItem(this.itemId); this.room.sendComposer(new RoomUserHandItemComposer(this.roomUnit).compose()); } 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 111dddfd..7d2cce57 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java @@ -4,24 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -public class RoomUnitKick implements Runnable -{ +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) - { + public RoomUnitKick(Habbo habbo, Room room, boolean removeEffect) { this.habbo = habbo; this.room = room; this.removeEffect = removeEffect; } @Override - public void run() - { - if(this.removeEffect) - { + public void run() { + if (this.removeEffect) { this.habbo.getRoomUnit().setEffectId(0, 0); } 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 340ce934..bcfd8ef2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -8,27 +8,23 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class RoomUnitRidePet implements Runnable -{ +public class RoomUnitRidePet implements Runnable { private RideablePet pet; private Habbo habbo; private RoomTile goalTile; - public RoomUnitRidePet(RideablePet pet, Habbo habbo, RoomTile goalTile) - { + public RoomUnitRidePet(RideablePet pet, Habbo habbo, RoomTile goalTile) { this.pet = pet; this.habbo = habbo; this.goalTile = goalTile; } @Override - public void run() - { - if(this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getHabboInfo().getCurrentRoom() || this.goalTile == null || this.habbo.getRoomUnit().getGoal() != this.goalTile) + public void run() { + if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getHabboInfo().getCurrentRoom() || this.goalTile == null || this.habbo.getRoomUnit().getGoal() != this.goalTile) return; - if (habbo.getRoomUnit().getCurrentLocation().distance(pet.getRoomUnit().getCurrentLocation()) <= 1) - { + if (habbo.getRoomUnit().getCurrentLocation().distance(pet.getRoomUnit().getCurrentLocation()) <= 1) { habbo.getRoomUnit().stopWalking(); habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, 77, -1); habbo.getHabboInfo().setRiding(pet); @@ -42,9 +38,7 @@ public class RoomUnitRidePet implements Runnable habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserEffectComposer(habbo.getRoomUnit()).compose()); pet.setTask(PetTasks.RIDE); - } - else - { + } else { pet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp()); pet.getRoomUnit().stopWalking(); habbo.getRoomUnit().setGoalLocation(goalTile); 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 df10d433..9e342d34 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -11,8 +11,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import java.util.LinkedList; -public class RoomUnitTeleport implements Runnable -{ +public class RoomUnitTeleport implements Runnable { private RoomUnit roomUnit; private Room room; private int x; @@ -21,8 +20,7 @@ public class RoomUnitTeleport implements Runnable private int newEffect; - public RoomUnitTeleport(RoomUnit roomUnit, Room room, int x, int y, double z, 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; @@ -32,22 +30,17 @@ public class RoomUnitTeleport implements Runnable } @Override - public void run() - { - if(roomUnit == null || roomUnit.getRoom() == null) + public void run() { + if (roomUnit == null || roomUnit.getRoom() == null) return; RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y); HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); - if (topItem != null) - { - try - { + if (topItem != null) { + try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } @@ -64,7 +57,7 @@ public class RoomUnitTeleport implements Runnable this.room.updateHabbosAt(t.x, t.y); topItem = room.getTopItemAt(x, y); - if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short)x, (short)y))) { + if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) { try { topItem.onWalkOn(roomUnit, room, new Object[]{}); } catch (Exception e) { 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 ca75f194..4403235a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -6,47 +6,33 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class RoomUnitTeleportWalkToAction implements Runnable -{ +public class RoomUnitTeleportWalkToAction implements Runnable { private final Habbo habbo; private final HabboItem habboItem; private final Room room; - public RoomUnitTeleportWalkToAction(Habbo habbo, HabboItem habboItem, Room room) - { + public RoomUnitTeleportWalkToAction(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) - { - if(this.habboItem.getRoomId() == this.room.getId()) - { + public void run() { + if (this.habbo.getHabboInfo().getCurrentRoom() == this.room) { + if (this.habboItem.getRoomId() == this.room.getId()) { RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem); - if (tile != null) - { - if (this.habbo.getRoomUnit().getGoal().equals(tile)) - { - if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) - { - try - { + if (tile != null) { + if (this.habbo.getRoomUnit().getGoal().equals(tile)) { + if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) { + try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - } - else - { - if (tile.isWalkable()) - { + } else { + if (tile.isWalkable()) { this.habbo.getRoomUnit().setGoalLocation(tile); Emulator.getThreading().run(this, this.habbo.getRoomUnit().getPath().size() + 2 * 510); } 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 88ef4828..10e13ce8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -6,46 +6,32 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -public class RoomUnitVendingMachineAction implements Runnable -{ +public class RoomUnitVendingMachineAction implements Runnable { private final Habbo habbo; private final HabboItem habboItem; private final Room room; - public RoomUnitVendingMachineAction(Habbo habbo, HabboItem habboItem, 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) - { - if(this.habboItem.getRoomId() == this.room.getId()) - { + public void run() { + if (this.habbo.getHabboInfo().getCurrentRoom() == this.room) { + if (this.habboItem.getRoomId() == this.room.getId()) { RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem); - if (tile != null) - { - if (this.habbo.getRoomUnit().getGoal().equals(tile)) - { - if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) - { - try - { + if (tile != null) { + if (this.habbo.getRoomUnit().getGoal().equals(tile)) { + if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) { + try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } - } - else - { - if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) - { + } else { + if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { this.habbo.getRoomUnit().setGoalLocation(tile); Emulator.getThreading().run(this, 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 3ba48d22..cb3e2935 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -4,21 +4,17 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.util.List; -public class RoomUnitWalkToLocation implements Runnable -{ +public class RoomUnitWalkToLocation implements Runnable { private RoomUnit walker; private RoomTile goalTile; private Room room; private List targetReached; private List failedReached; - public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List targetReached, List failedReached) - { + public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List targetReached, List failedReached) { this.walker = walker; this.goalTile = goalTile; this.room = room; @@ -27,19 +23,18 @@ public class RoomUnitWalkToLocation implements Runnable } @Override - public void run() { - if(this.goalTile == null || this.walker == null || this.room == null || this.walker.getRoom() == null || this.walker.getRoom().getId() != this.room.getId()) { + public void run() { + if (this.goalTile == null || this.walker == null || this.room == null || this.walker.getRoom() == null || this.walker.getRoom().getId() != this.room.getId()) { onFail(); return; } - if(!this.walker.getGoal().equals(this.goalTile)) { + if (!this.walker.getGoal().equals(this.goalTile)) { onFail(); return; } - if(this.walker.getCurrentLocation().equals(this.goalTile)) - { + if (this.walker.getCurrentLocation().equals(this.goalTile)) { onSuccess(); return; } @@ -48,12 +43,12 @@ public class RoomUnitWalkToLocation implements Runnable } private void onSuccess() { - for(Runnable r : this.targetReached) + for (Runnable r : this.targetReached) Emulator.getThreading().run(r); } private void onFail() { - for(Runnable r : this.failedReached) + for (Runnable r : this.failedReached) Emulator.getThreading().run(r); } } 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 3e233e96..1eeac72d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -9,8 +9,7 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.util.List; -public class RoomUnitWalkToRoomUnit implements Runnable -{ +public class RoomUnitWalkToRoomUnit implements Runnable { private final int minDistance; private RoomUnit walker; private RoomUnit target; @@ -20,8 +19,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable private RoomTile goalTile = null; - public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List targetReached, List failedReached) - { + public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List targetReached, List failedReached) { this.walker = walker; this.target = target; this.room = room; @@ -30,8 +28,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable this.minDistance = 1; } - public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List targetReached, List failedReached, int minDistance) - { + public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List targetReached, List failedReached, int minDistance) { this.walker = walker; this.target = target; this.room = room; @@ -41,37 +38,29 @@ public class RoomUnitWalkToRoomUnit implements Runnable } @Override - public void run() - { - if(this.goalTile == null) - { + public void run() { + if (this.goalTile == null) { this.findNewLocation(); Emulator.getThreading().run(this, 500); } - if(this.goalTile == null) + if (this.goalTile == null) return; - if(this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task. + if (this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task. { //Check if arrived. - if(this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) - { - for(Runnable r : this.targetReached) - { + if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) { + for (Runnable r : this.targetReached) { Emulator.getThreading().run(r); WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, this.target, this.room, new Object[]{this.walker}); } - } - else - { + } else { List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation()); - for(RoomTile t : tiles) - { - if(t.equals(this.goalTile)) - { + for (RoomTile t : tiles) { + if (t.equals(this.goalTile)) { Emulator.getThreading().run(this, 500); return; } @@ -84,21 +73,17 @@ public class RoomUnitWalkToRoomUnit implements Runnable } } - private void findNewLocation() - { + private void findNewLocation() { this.goalTile = this.room.getLayout().getTileInFront(this.target.getCurrentLocation(), this.target.getBodyRotation().getValue()); if (this.goalTile == null) return; - if (!this.room.tileWalkable(this.goalTile)) - { + if (!this.room.tileWalkable(this.goalTile)) { List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation()); - for (RoomTile t : tiles) - { - if (this.room.tileWalkable(t)) - { + for (RoomTile t : tiles) { + if (this.room.tileWalkable(t)) { this.goalTile = t; break; @@ -108,10 +93,8 @@ public class RoomUnitWalkToRoomUnit implements Runnable this.walker.setGoalLocation(this.goalTile); - if (this.walker.getPath().isEmpty() && this.failedReached != null) - { - for(Runnable r : this.failedReached) - { + if (this.walker.getPath().isEmpty() && this.failedReached != null) { + for (Runnable r : this.failedReached) { Emulator.getThreading().run(r); } } 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 a96abbc3..6007f83a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -9,24 +9,19 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class SaveScoreForTeam implements Runnable -{ +public class SaveScoreForTeam implements Runnable { public final GameTeam team; public final Game game; - public SaveScoreForTeam(GameTeam team, Game game) - { + public SaveScoreForTeam(GameTeam team, Game game) { this.team = team; this.game = game; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_game_scores (room_id, game_start_timestamp, game_name, user_id, team_id, score, team_score) VALUES (?, ?, ?, ?, ?, ?, ?)")) - { - for(GamePlayer player : this.team.getMembers()) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_game_scores (room_id, game_start_timestamp, game_name, user_id, team_id, score, team_score) VALUES (?, ?, ?, ?, ?, ?, ?)")) { + for (GamePlayer player : this.team.getMembers()) { statement.setInt(1, this.game.getRoom().getId()); statement.setInt(2, this.game.getStartTime()); statement.setString(3, this.game.getClass().getName()); @@ -38,9 +33,7 @@ public class SaveScoreForTeam implements Runnable } statement.executeBatch(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(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 7a70a931..9b24eaee 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java @@ -4,8 +4,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer; -public class SendRoomUnitEffectComposer implements Runnable -{ +public class SendRoomUnitEffectComposer implements Runnable { private final Room room; private final RoomUnit roomUnit; @@ -15,9 +14,8 @@ public class SendRoomUnitEffectComposer implements Runnable } @Override - public void run() - { - if(this.room != null && this.roomUnit != null) { + public void run() { + if (this.room != null && this.roomUnit != null) { this.room.sendComposer(new RoomUserEffectComposer(roomUnit).compose()); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/ShutdownEmulator.java b/src/main/java/com/eu/habbo/threading/runnables/ShutdownEmulator.java index 71bdbcaa..8ba9ff82 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ShutdownEmulator.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ShutdownEmulator.java @@ -3,26 +3,22 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.messages.ServerMessage; -public class ShutdownEmulator implements Runnable -{ +public class ShutdownEmulator implements Runnable { public static boolean instantiated = false; public static int timestamp = 0; - public ShutdownEmulator(ServerMessage message) - { - if (!instantiated) - { + public ShutdownEmulator(ServerMessage message) { + if (!instantiated) { instantiated = true; - if (message != null) - { + if (message != null) { Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(message); } } } + @Override - public void run() - { + public void run() { Emulator.getRuntime().exit(0); } } \ No newline at end of file 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 46ee51fa..895dde84 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -12,18 +12,16 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; -class TeleportInteraction extends Thread -{ - private int state; +class TeleportInteraction extends Thread { private final Room room; - private Room targetRoom; private final GameClient client; private final HabboItem teleportOne; + private int state; + private Room targetRoom; private HabboItem teleportTwo; @Deprecated - public TeleportInteraction(Room room, GameClient client, HabboItem teleportOne) - { + public TeleportInteraction(Room room, GameClient client, HabboItem teleportOne) { this.room = room; this.client = client; this.teleportOne = teleportOne; @@ -33,43 +31,33 @@ class TeleportInteraction extends Thread } @Override - public void run() - { - try - { - if (this.state == 5) - { + public void run() { + try { + if (this.state == 5) { this.teleportTwo.setExtradata("1"); this.targetRoom.updateItem(this.teleportTwo); this.room.updateItem(this.teleportOne); RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.teleportTwo); - if (tile != null) - { + if (tile != null) { this.client.getHabbo().getRoomUnit().setGoalLocation(tile); } Emulator.getThreading().run(this.teleportTwo, 500); Emulator.getThreading().run(this.teleportOne, 500); - } else if (this.state == 4) - { + } else if (this.state == 4) { int[] data = Emulator.getGameEnvironment().getItemManager().getTargetTeleportRoomId(this.teleportOne); - if (data.length == 2 && data[0] != 0) - { - if (this.room.getId() == data[0]) - { + if (data.length == 2 && data[0] != 0) { + if (this.room.getId() == data[0]) { this.targetRoom = this.room; this.teleportTwo = this.room.getHabboItem(data[1]); - if (this.teleportTwo == null) - { + if (this.teleportTwo == null) { this.teleportTwo = this.teleportOne; } - } else - { + } else { this.targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(data[0]); this.teleportTwo = this.targetRoom.getHabboItem(data[1]); } - } else - { + } else { this.targetRoom = this.room; this.teleportTwo = this.teleportOne; } @@ -77,8 +65,7 @@ class TeleportInteraction extends Thread this.teleportOne.setExtradata("2"); this.teleportTwo.setExtradata("2"); - if (this.room != this.targetRoom) - { + if (this.room != this.targetRoom) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); this.room.removeHabbo(this.client.getHabbo()); Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), this.targetRoom); @@ -99,14 +86,12 @@ class TeleportInteraction extends Thread this.state = 5; Emulator.getThreading().run(this, 500); - } else if (this.state == 3) - { + } else if (this.state == 3) { this.teleportOne.setExtradata("0"); this.room.updateItem(this.teleportOne); this.state = 4; Emulator.getThreading().run(this, 500); - } else if (this.state == 2) - { + } else if (this.state == 2) { this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getX(), this.teleportOne.getY())); this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[this.newRotation(this.teleportOne.getRotation())]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); @@ -115,12 +100,10 @@ class TeleportInteraction extends Thread this.state = 3; Emulator.getThreading().run(this, 500); - } else if (this.state == 1) - { + } 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.x && this.client.getHabbo().getRoomUnit().getY() == loc.y) { this.teleportOne.setExtradata("1"); this.room.updateItem(this.teleportOne); this.state = 2; @@ -128,18 +111,15 @@ class TeleportInteraction extends Thread Emulator.getThreading().run(this, 250); } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - private int newRotation(int rotation) - { - if(rotation == 4) + private int newRotation(int rotation) { + if (rotation == 4) return 0; - if(rotation == 6) + if (rotation == 6) return 2; else return rotation + 4; 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 8498387e..03df0f4d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java @@ -7,29 +7,23 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class UpdateModToolIssue implements Runnable -{ +public class UpdateModToolIssue implements Runnable { private final ModToolIssue issue; - public UpdateModToolIssue(ModToolIssue issue) - { + public UpdateModToolIssue(ModToolIssue issue) { this.issue = issue; } @Override - public void run() - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE support_tickets SET state = ?, type = ?, mod_id = ?, category = ? WHERE id = ?")) - { + public void run() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE support_tickets SET state = ?, type = ?, mod_id = ?, category = ? WHERE id = ?")) { statement.setInt(1, this.issue.state.getState()); statement.setInt(2, this.issue.type.getType()); statement.setInt(3, this.issue.modId); statement.setInt(4, this.issue.category); statement.setInt(5, this.issue.id); statement.execute(); - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java b/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java index af5cfc5a..a7479cfa 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java @@ -7,38 +7,31 @@ import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerAtT import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.wired.WiredHandler; -public class WiredExecuteTask implements Runnable -{ +public class WiredExecuteTask implements Runnable { private final InteractionWiredTrigger task; private final Room room; private int taskId; - public WiredExecuteTask(InteractionWiredTrigger trigger, Room room) - { + public WiredExecuteTask(InteractionWiredTrigger trigger, Room room) { this.task = trigger; this.room = room; - if(this.task instanceof WiredTriggerAtSetTime) + if (this.task instanceof WiredTriggerAtSetTime) this.taskId = ((WiredTriggerAtSetTime) this.task).taskId; - if(this.task instanceof WiredTriggerAtTimeLong) + if (this.task instanceof WiredTriggerAtTimeLong) this.taskId = ((WiredTriggerAtTimeLong) this.task).taskId; } @Override - public void run() - { - if (!Emulator.isShuttingDown && Emulator.isReady) - { - if (this.room != null && this.room.getId() == this.task.getRoomId()) - { - if (this.task instanceof WiredTriggerAtSetTime) - { + public void run() { + if (!Emulator.isShuttingDown && Emulator.isReady) { + if (this.room != null && this.room.getId() == this.task.getRoomId()) { + if (this.task instanceof WiredTriggerAtSetTime) { if (((WiredTriggerAtSetTime) this.task).taskId != this.taskId) return; } - if (this.task instanceof WiredTriggerAtTimeLong) - { + if (this.task instanceof WiredTriggerAtTimeLong) { if (((WiredTriggerAtTimeLong) this.task).taskId != this.taskId) return; } 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 16d7119a..a6ccde40 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java @@ -4,26 +4,21 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -class WiredRepeatEffectTask implements Runnable -{ +class WiredRepeatEffectTask implements Runnable { private final InteractionWiredEffect effect; private final Room room; private final int delay; - public WiredRepeatEffectTask(InteractionWiredEffect effect, Room room, int delay) - { + public WiredRepeatEffectTask(InteractionWiredEffect effect, Room room, int delay) { this.effect = effect; this.room = room; this.delay = delay; } @Override - public void run() - { - if (!Emulator.isShuttingDown && Emulator.isReady) - { - if (this.room != null && this.room.getId() == this.effect.getRoomId()) - { + public void run() { + if (!Emulator.isShuttingDown && Emulator.isReady) { + if (this.room != null && this.room.getId() == this.effect.getRoomId()) { this.effect.execute(null, this.room, null); Emulator.getThreading().run(this, this.delay); 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 fe9de6f8..7ea428b1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredResetTimers.java @@ -4,20 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.wired.WiredHandler; -public class WiredResetTimers implements Runnable -{ +public class WiredResetTimers implements Runnable { private Room room; - public WiredResetTimers(Room room) - { + public WiredResetTimers(Room room) { this.room = room; } @Override - public void run() - { - if (!Emulator.isShuttingDown && Emulator.isReady) - { + public void run() { + if (!Emulator.isShuttingDown && Emulator.isReady) { WiredHandler.resetTimers(this.room); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java index f200b84c..a9eb50a0 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java @@ -7,69 +7,68 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.habbohotel.users.Habbo; -public class YouAreAPirate implements Runnable -{ +public class YouAreAPirate implements Runnable { public static String[] iamapirate = new String[]{ - "Do what you want, 'cause a pirate is free,", - "You are a pirate!", - "", - "Yar har, fiddle di dee,", - "Being a pirate is all right with me,", - "Do what you want 'cause a pirate is free, ", - "You are a pirate!", - "Yo Ho, ahoy and avast,", - "Being a pirate is really badass!", - "Hang the black flag at the end of the mast!", - "You are a pirate!", - "", - "You are a pirate! - Yay!", - "", - "We've got us a map, (a map! )", - "To lead us to a hidden box,", - "That's all locked up with locks! (with locks! )", - "And buried deep away!", - "", - "We'll dig up the box, (the box! )", - "We know it's full of precious booty! ", - "Burst open the locks!", - "And then we'll say hooray! ", - "", - "Yar har, fiddle di dee,", - "Being a pirate is all right with me!", - "Do what you want 'cause a pirate is free, ", - "", - "You are a pirate!", - "Yo Ho, ahoy and avast,", - "Being a Pirate is really badass!", - "Hang the black flag", - "At the end of the mast!", - "You are a pirate!", - "", - "Hahaha!", - "", - "", - "We're sailing away (set sail! ), ", - "Adventure awaits on every shore!", - "We set sail and explore (ya-har! )", - "And run and jump all day (Yay! )", - "We float on our boat (the boat! )", - "Until it's time to drop the anchor, ", - "Then hang up our coats (aye-aye! )", - "Until we sail again!", - "", - "Yar har, fiddle di dee,", - "Being a pirate is all right with me!", - "Do what you want 'cause a pirate is free, ", - "You are a pirate!", - "", - "Yar har, wind at your back, lads,", - "Wherever you go!", - "", - "", - "Blue sky above and blue ocean below,", - "You are a pirate!", - "", - "You are a pirate!" + "Do what you want, 'cause a pirate is free,", + "You are a pirate!", + "", + "Yar har, fiddle di dee,", + "Being a pirate is all right with me,", + "Do what you want 'cause a pirate is free, ", + "You are a pirate!", + "Yo Ho, ahoy and avast,", + "Being a pirate is really badass!", + "Hang the black flag at the end of the mast!", + "You are a pirate!", + "", + "You are a pirate! - Yay!", + "", + "We've got us a map, (a map! )", + "To lead us to a hidden box,", + "That's all locked up with locks! (with locks! )", + "And buried deep away!", + "", + "We'll dig up the box, (the box! )", + "We know it's full of precious booty! ", + "Burst open the locks!", + "And then we'll say hooray! ", + "", + "Yar har, fiddle di dee,", + "Being a pirate is all right with me!", + "Do what you want 'cause a pirate is free, ", + "", + "You are a pirate!", + "Yo Ho, ahoy and avast,", + "Being a Pirate is really badass!", + "Hang the black flag", + "At the end of the mast!", + "You are a pirate!", + "", + "Hahaha!", + "", + "", + "We're sailing away (set sail! ), ", + "Adventure awaits on every shore!", + "We set sail and explore (ya-har! )", + "And run and jump all day (Yay! )", + "We float on our boat (the boat! )", + "Until it's time to drop the anchor, ", + "Then hang up our coats (aye-aye! )", + "Until we sail again!", + "", + "Yar har, fiddle di dee,", + "Being a pirate is all right with me!", + "Do what you want 'cause a pirate is free, ", + "You are a pirate!", + "", + "Yar har, wind at your back, lads,", + "Wherever you go!", + "", + "", + "Blue sky above and blue ocean below,", + "You are a pirate!", + "", + "You are a pirate!" }; public final Habbo habbo; @@ -77,8 +76,8 @@ public class YouAreAPirate implements Runnable private int index = 0; private int oldEffect; - public YouAreAPirate(Habbo habbo, Room room) - { + + public YouAreAPirate(Habbo habbo, Room room) { this.habbo = habbo; this.room = room; this.oldEffect = this.habbo.getRoomUnit().getEffectId(); @@ -86,23 +85,19 @@ public class YouAreAPirate implements Runnable } @Override - public void run() - { - if(this.room == this.habbo.getHabboInfo().getCurrentRoom()) - { - if(!iamapirate[this.index].isEmpty()) - { + public void run() { + if (this.room == this.habbo.getHabboInfo().getCurrentRoom()) { + if (!iamapirate[this.index].isEmpty()) { this.room.talk(this.habbo, new RoomChatMessage(iamapirate[this.index], this.habbo, RoomChatMessageBubbles.PIRATE), RoomChatType.SHOUT); } this.index++; - if(this.index == iamapirate.length) - { + if (this.index == iamapirate.length) { this.room.giveEffect(this.habbo, this.oldEffect, -1); return; } - Emulator.getThreading().run(this, iamapirate[this.index -1].length() * 100); + Emulator.getThreading().run(this, iamapirate[this.index - 1].length() * 100); } } } 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 0460d4bb..27de5820 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 @@ -3,22 +3,18 @@ package com.eu.habbo.threading.runnables.freeze; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer; -public class FreezeClearEffects implements Runnable -{ +public class FreezeClearEffects implements Runnable { private final Habbo habbo; - public FreezeClearEffects(Habbo habbo) - { + public FreezeClearEffects(Habbo habbo) { this.habbo = habbo; } @Override - public void run() - { + public void run() { this.habbo.getRoomUnit().setEffectId(0, 0); this.habbo.getRoomUnit().setCanWalk(true); - if(this.habbo.getHabboInfo().getCurrentRoom() != null) - { + if (this.habbo.getHabboInfo().getCurrentRoom() != null) { this.habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserEffectComposer(this.habbo.getRoomUnit()).compose()); } } 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 6a864354..6826af2e 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 @@ -11,24 +11,20 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -class FreezeHandleSnowballExplosion implements Runnable -{ +class FreezeHandleSnowballExplosion implements Runnable { private final FreezeThrowSnowball thrownData; - public FreezeHandleSnowballExplosion(FreezeThrowSnowball thrownData) - { + public FreezeHandleSnowballExplosion(FreezeThrowSnowball thrownData) { this.thrownData = thrownData; } @Override - public void run() - { - try - { - if(this.thrownData == null || this.thrownData.habbo.getHabboInfo().getGamePlayer() == null) + public void run() { + try { + if (this.thrownData == null || this.thrownData.habbo.getHabboInfo().getGamePlayer() == null) return; - - FreezeGamePlayer player = (FreezeGamePlayer)this.thrownData.habbo.getHabboInfo().getGamePlayer(); + + FreezeGamePlayer player = (FreezeGamePlayer) this.thrownData.habbo.getHabboInfo().getGamePlayer(); if (player == null) return; @@ -37,44 +33,35 @@ class FreezeHandleSnowballExplosion implements Runnable THashSet tiles = new THashSet<>(); - FreezeGame game = ((FreezeGame)this.thrownData.room.getGame(FreezeGame.class)); + FreezeGame game = ((FreezeGame) this.thrownData.room.getGame(FreezeGame.class)); - if(game == null) + if (game == null) return; - if (player.nextHorizontal) - { + if (player.nextHorizontal) { tiles.addAll(game.affectedTilesByExplosion(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY(), this.thrownData.radius + 1)); } - if (player.nextDiagonal) - { + if (player.nextDiagonal) { tiles.addAll(game.affectedTilesByExplosionDiagonal(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY(), this.thrownData.radius + 1)); player.nextDiagonal = false; } THashSet freezeTiles = new THashSet<>(); - for (RoomTile roomTile : tiles) - { + for (RoomTile roomTile : tiles) { THashSet items = this.thrownData.room.getItemsAt(roomTile); - for (HabboItem freezeTile : items) - { - if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) - { + for (HabboItem freezeTile : items) { + if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) { int distance = 0; - if (freezeTile.getX() != this.thrownData.targetTile.getX() && freezeTile.getY() != this.thrownData.targetTile.getY()) - { + if (freezeTile.getX() != this.thrownData.targetTile.getX() && freezeTile.getY() != this.thrownData.targetTile.getY()) { distance = Math.abs(freezeTile.getX() - this.thrownData.targetTile.getX()); - } - else - { - distance = (int)Math.ceil(this.thrownData.room.getLayout().getTile(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY()).distance(roomTile)); + } else { + distance = (int) Math.ceil(this.thrownData.room.getLayout().getTile(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY()).distance(roomTile)); } - if (freezeTile instanceof InteractionFreezeTile) - { + if (freezeTile instanceof InteractionFreezeTile) { freezeTile.setExtradata("11" + String.format("%03d", distance * 100)); //TODO Investigate this further. Probably height dependent or something. freezeTiles.add((InteractionFreezeTile) freezeTile); this.thrownData.room.updateItem(freezeTile); @@ -83,10 +70,8 @@ class FreezeHandleSnowballExplosion implements Runnable THashSet habbos = new THashSet<>(); habbos.addAll(this.thrownData.room.getHabbosAt(freezeTile.getX(), freezeTile.getY())); - for (Habbo habbo : habbos) - { - if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getGamePlayer() instanceof FreezeGamePlayer) - { + for (Habbo habbo : habbos) { + if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getGamePlayer() instanceof FreezeGamePlayer) { FreezeGamePlayer hPlayer = (FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer(); if (!hPlayer.canGetFrozen()) continue; @@ -98,17 +83,13 @@ class FreezeHandleSnowballExplosion implements Runnable ((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).freeze(); - if (this.thrownData.habbo != habbo) - { + if (this.thrownData.habbo != habbo) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("EsA")); } } } - } - else if (freezeTile instanceof InteractionFreezeBlock) - { - if (freezeTile.getExtradata().equalsIgnoreCase("0")) - { + } else if (freezeTile instanceof InteractionFreezeBlock) { + if (freezeTile.getExtradata().equalsIgnoreCase("0")) { game.explodeBox((InteractionFreezeBlock) freezeTile, distance * 100); player.addScore(FreezeGame.DESTROY_BLOCK_POINTS); } @@ -118,9 +99,7 @@ class FreezeHandleSnowballExplosion implements Runnable } Emulator.getThreading().run(new FreezeResetExplosionTiles(freezeTiles, this.thrownData.room), 1000); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(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 2cfde3bd..80b06f71 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 @@ -5,21 +5,18 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; -class FreezeResetExplosionTiles implements Runnable -{ +class FreezeResetExplosionTiles implements Runnable { private final THashSet tiles; private final Room room; - public FreezeResetExplosionTiles(THashSet tiles, Room room) - { + public FreezeResetExplosionTiles(THashSet tiles, Room room) { this.tiles = tiles; this.room = room; } + @Override - public void run() - { - for(HabboItem item : this.tiles) - { + public void run() { + for (HabboItem item : this.tiles) { item.setExtradata("0"); this.room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java index 11b2e82e..a6101523 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java @@ -8,24 +8,21 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.HabboItemNewState; -public class FreezeThrowSnowball implements Runnable -{ +public class FreezeThrowSnowball implements Runnable { public final Habbo habbo; public final InteractionFreezeTile targetTile; public final Room room; public final int radius; - public FreezeThrowSnowball(Habbo habbo, HabboItem targetTile, Room room) - { + public FreezeThrowSnowball(Habbo habbo, HabboItem targetTile, Room room) { this.habbo = habbo; this.targetTile = (InteractionFreezeTile) targetTile; this.room = room; - this.radius = ((FreezeGamePlayer)habbo.getHabboInfo().getGamePlayer()).getExplosionBoost(); + this.radius = ((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).getExplosionBoost(); } @Override - public void run() - { + public void run() { ((FreezeGamePlayer) this.habbo.getHabboInfo().getGamePlayer()).takeSnowball(); this.targetTile.setExtradata((this.radius + 1) * 1000 + ""); this.room.updateItem(this.targetTile); 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 dbc207b1..15ac8316 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 @@ -7,26 +7,22 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.HabboItemNewState; -class HopperActionFive implements Runnable -{ +class HopperActionFive implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public HopperActionFive(HabboItem currentTeleport, Room room, GameClient client) - { + public HopperActionFive(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { this.client.getHabbo().getRoomUnit().isTeleporting = false; RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()), this.currentTeleport.getRotation()); - if (tile != null) - { + if (tile != null) { this.client.getHabbo().getRoomUnit().setGoalLocation(tile); } 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 390d7f02..2938a6d7 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 @@ -5,22 +5,19 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -class HopperActionFour implements Runnable -{ +class HopperActionFour implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public HopperActionFour(HabboItem currentTeleport, Room room, GameClient client) - { + public HopperActionFour(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { this.currentTeleport.setExtradata("1"); this.room.updateItem(this.currentTeleport); 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 d4716bc7..76ee6ab1 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 @@ -8,22 +8,19 @@ import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class HopperActionOne implements Runnable -{ +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) - { + public HopperActionOne(HabboItem teleportOne, Room room, GameClient client) { this.teleportOne = teleportOne; this.room = room; this.client = client; } @Override - public void run() - { + public void run() { //this.client.getHabbo().getRoomUnit().setGoalLocation(this.teleportOne.getX(), this.teleportOne.getY()); this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[(this.teleportOne.getRotation() + 4) % 8]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); @@ -32,11 +29,9 @@ public class HopperActionOne implements Runnable this.client.getHabbo().getRoomUnit().setZ(this.teleportOne.getZ()); this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getZ()); - Emulator.getThreading().run(new Runnable() - { + Emulator.getThreading().run(new Runnable() { @Override - public void run() - { + public void run() { HopperActionOne.this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); HopperActionOne.this.room.sendComposer(new RoomUserStatusComposer(HopperActionOne.this.client.getHabbo().getRoomUnit()).compose()); } 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 650bf355..724a426c 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 @@ -11,16 +11,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; -class HopperActionThree implements Runnable -{ +class HopperActionThree implements Runnable { private final HabboItem teleportOne; private final Room room; private final GameClient client; private final int targetRoomId; private final int targetItemId; - public HopperActionThree(HabboItem teleportOne, Room room, GameClient client, int targetRoomId, int targetItemId) - { + public HopperActionThree(HabboItem teleportOne, Room room, GameClient client, int targetRoomId, int targetItemId) { this.teleportOne = teleportOne; this.room = room; this.client = client; @@ -29,13 +27,11 @@ class HopperActionThree implements Runnable } @Override - public void run() - { + public void run() { HabboItem targetTeleport; Room targetRoom = this.room; - if(this.teleportOne.getRoomId() != this.targetRoomId) - { + if (this.teleportOne.getRoomId() != this.targetRoomId) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.room, false); targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.targetRoomId); Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getId(), "", false); @@ -43,8 +39,7 @@ class HopperActionThree implements Runnable targetTeleport = targetRoom.getHabboItem(this.targetItemId); - if(targetTeleport == null) - { + if (targetTeleport == null) { this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); this.client.getHabbo().getRoomUnit().setCanWalk(true); return; @@ -62,8 +57,7 @@ class HopperActionThree implements Runnable Emulator.getThreading().run(new HabboItemNewState(this.teleportOne, this.room, "0"), 500); Emulator.getThreading().run(new HopperActionFour(targetTeleport, targetRoom, this.client), 500); - if(targetTeleport instanceof InteractionCostumeHopper) - { + if (targetTeleport instanceof InteractionCostumeHopper) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CostumeHopper")); } } 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 65555b50..5be506d3 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 @@ -10,52 +10,41 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -class HopperActionTwo implements Runnable -{ +class HopperActionTwo implements Runnable { private final HabboItem teleportOne; private final Room room; private final GameClient client; - public HopperActionTwo(HabboItem teleportOne, Room room, GameClient client) - { + public HopperActionTwo(HabboItem teleportOne, Room room, GameClient client) { this.teleportOne = teleportOne; this.room = room; this.client = client; } @Override - public void run() - { + public void run() { this.teleportOne.setExtradata("2"); int targetRoomId = 0; int targetItemId = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_hoppers INNER JOIN items ON items_hoppers.item_id = items.id WHERE base_item = ? AND items.id != ? AND room_id > 0 ORDER BY RAND() LIMIT 1")) - { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_hoppers INNER JOIN items ON items_hoppers.item_id = items.id WHERE base_item = ? AND items.id != ? AND room_id > 0 ORDER BY RAND() LIMIT 1")) { statement.setInt(1, this.teleportOne.getBaseItem().getId()); statement.setInt(2, this.teleportOne.getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { targetItemId = set.getInt("id"); targetRoomId = set.getInt("room_id"); } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - if(targetRoomId != 0 && targetItemId != 0) - { + if (targetRoomId != 0 && targetItemId != 0) { Emulator.getThreading().run(new HopperActionThree(this.teleportOne, this.room, this.client, targetRoomId, targetItemId), 500); - } - else - { + } else { this.teleportOne.setExtradata("0"); this.client.getHabbo().getRoomUnit().setCanWalk(true); this.client.getHabbo().getRoomUnit().isTeleporting = false; 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 903f489e..a073b23a 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 @@ -2,7 +2,9 @@ package com.eu.habbo.threading.runnables.teleport; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -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; @@ -10,24 +12,21 @@ import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import java.util.ArrayList; import java.util.List; -class TeleportActionFive implements Runnable -{ +class TeleportActionFive implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionFive(HabboItem currentTeleport, Room room, GameClient client) - { + public TeleportActionFive(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { RoomUnit unit = this.client.getHabbo().getRoomUnit(); - + unit.isTeleporting = false; unit.setCanWalk(true); @@ -39,8 +38,7 @@ class TeleportActionFive implements Runnable RoomTile currentLocation = this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()); RoomTile tile = this.room.getLayout().getTileInFront(currentLocation, this.currentTeleport.getRotation()); - if (tile != null) - { + if (tile != null) { List onSuccess = new ArrayList(); onSuccess.add(() -> { unit.setCanLeaveRoomByDoor(true); 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 639c145d..cd2adb5f 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 @@ -5,24 +5,20 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; -class TeleportActionFour implements Runnable -{ +class TeleportActionFour implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionFour(HabboItem currentTeleport, Room room, GameClient client) - { + public TeleportActionFour(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) - { + public void run() { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) { this.client.getHabbo().getRoomUnit().setCanWalk(true); this.currentTeleport.setExtradata("0"); this.room.updateItem(this.currentTeleport); 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 fb7b4b00..760c2d75 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 @@ -9,34 +9,29 @@ import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -public class TeleportActionOne implements Runnable -{ +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) - { + public TeleportActionOne(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) return; int delay = 500; - if (this.currentTeleport instanceof InteractionTeleportTile) - { + if (this.currentTeleport instanceof InteractionTeleportTile) { delay = 0; } - if (this.client.getHabbo().getRoomUnit().getCurrentLocation() != this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())) - { + if (this.client.getHabbo().getRoomUnit().getCurrentLocation() != this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())) { this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())); this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[(this.currentTeleport.getRotation() + 4) % 8]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.currentTeleport.getX() + "," + this.currentTeleport.getY() + "," + this.currentTeleport.getZ()); 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 ba492e24..7701a546 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,50 +9,42 @@ 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 com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; -class TeleportActionThree implements Runnable -{ +class TeleportActionThree implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionThree(HabboItem currentTeleport, Room room, GameClient client) - { + public TeleportActionThree(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) return; HabboItem targetTeleport; Room targetRoom = this.room; - if(this.currentTeleport.getRoomId() != ((InteractionTeleport)this.currentTeleport).getTargetRoomId()) - { + if (this.currentTeleport.getRoomId() != ((InteractionTeleport) this.currentTeleport).getTargetRoomId()) { targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(((InteractionTeleport) this.currentTeleport).getTargetRoomId()); } - if(targetRoom == null) - { + if (targetRoom == null) { Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 0); return; } - if (targetRoom.isPreLoaded()) - { + if (targetRoom.isPreLoaded()) { targetRoom.loadData(); } targetTeleport = targetRoom.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); - if(targetTeleport == null) - { + if (targetTeleport == null) { Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 0); return; } @@ -66,8 +58,7 @@ class TeleportActionThree implements Runnable this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getZ()); this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[targetTeleport.getRotation() % 8]); - if(targetRoom != this.room) - { + if (targetRoom != this.room) { this.room.removeHabbo(this.client.getHabbo(), true); Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getId(), "", Emulator.getConfig().getBoolean("hotel.teleport.locked.allowed"), teleportLocation); } 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 177dd458..5509f726 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 @@ -15,26 +15,22 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -class TeleportActionTwo implements Runnable -{ +class TeleportActionTwo implements Runnable { private final HabboItem currentTeleport; private final Room room; private final GameClient client; - public TeleportActionTwo(HabboItem currentTeleport, Room room, GameClient client) - { + public TeleportActionTwo(HabboItem currentTeleport, Room room, GameClient client) { this.currentTeleport = currentTeleport; this.client = client; this.room = room; } @Override - public void run() - { + public void run() { int delayOffset = 500; - if (this.currentTeleport instanceof InteractionTeleportTile) - { + if (this.currentTeleport instanceof InteractionTeleportTile) { delayOffset = 0; } @@ -44,53 +40,38 @@ class TeleportActionTwo implements Runnable this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); this.room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit()).compose()); - if(((InteractionTeleport)this.currentTeleport).getTargetRoomId() > 0 && ((InteractionTeleport) this.currentTeleport).getTargetId() > 0) - { + if (((InteractionTeleport) this.currentTeleport).getTargetRoomId() > 0 && ((InteractionTeleport) this.currentTeleport).getTargetId() > 0) { HabboItem item = this.room.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); - if(item == null) - { + if (item == null) { ((InteractionTeleport) this.currentTeleport).setTargetRoomId(0); ((InteractionTeleport) this.currentTeleport).setTargetId(0); - } - else if(((InteractionTeleport)item).getTargetRoomId() != ((InteractionTeleport) this.currentTeleport).getTargetRoomId()) - { + } else if (((InteractionTeleport) item).getTargetRoomId() != ((InteractionTeleport) this.currentTeleport).getTargetRoomId()) { ((InteractionTeleport) this.currentTeleport).setTargetId(0); ((InteractionTeleport) this.currentTeleport).setTargetRoomId(0); ((InteractionTeleport) item).setTargetId(0); ((InteractionTeleport) item).setTargetRoomId(0); } - } - else - { + } else { ((InteractionTeleport) this.currentTeleport).setTargetRoomId(0); ((InteractionTeleport) this.currentTeleport).setTargetId(0); } - if(((InteractionTeleport)this.currentTeleport).getTargetId() == 0) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_teleports.*, A.room_id as a_room_id, A.id as a_id, B.room_id as b_room_id, B.id as b_id FROM items_teleports INNER JOIN items AS A ON items_teleports.teleport_one_id = A.id INNER JOIN items AS B ON items_teleports.teleport_two_id = B.id WHERE (teleport_one_id = ? OR teleport_two_id = ?)")) - { + if (((InteractionTeleport) this.currentTeleport).getTargetId() == 0) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_teleports.*, A.room_id as a_room_id, A.id as a_id, B.room_id as b_room_id, B.id as b_id FROM items_teleports INNER JOIN items AS A ON items_teleports.teleport_one_id = A.id INNER JOIN items AS B ON items_teleports.teleport_two_id = B.id WHERE (teleport_one_id = ? OR teleport_two_id = ?)")) { statement.setInt(1, this.currentTeleport.getId()); statement.setInt(2, this.currentTeleport.getId()); - try (ResultSet set = statement.executeQuery()) - { - if (set.next()) - { - if (set.getInt("a_id") != this.currentTeleport.getId()) - { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + if (set.getInt("a_id") != this.currentTeleport.getId()) { ((InteractionTeleport) this.currentTeleport).setTargetId(set.getInt("a_id")); ((InteractionTeleport) this.currentTeleport).setTargetRoomId(set.getInt("a_room_id")); - } - else - { + } else { ((InteractionTeleport) this.currentTeleport).setTargetId(set.getInt("b_id")); ((InteractionTeleport) this.currentTeleport).setTargetRoomId(set.getInt("b_room_id")); } } } - } - catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } @@ -98,8 +79,7 @@ class TeleportActionTwo implements Runnable this.currentTeleport.setExtradata("0"); this.room.updateItem(this.currentTeleport); - if(((InteractionTeleport) this.currentTeleport).getTargetRoomId() == 0) - { + if (((InteractionTeleport) this.currentTeleport).getTargetRoomId() == 0) { //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, room, "1"), 0); Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 0); return; diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java b/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java index df4a731b..2d1760f5 100644 --- a/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java +++ b/src/main/java/com/eu/habbo/util/callback/HTTPPostError.java @@ -1,13 +1,5 @@ package com.eu.habbo.util.callback; -import com.eu.habbo.Emulator; - -import java.io.DataOutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URL; - /* public class HTTPPostError implements Runnable { public Throwable stackTrace; diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java b/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java index 05ce6291..01fac236 100644 --- a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java +++ b/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java @@ -1,15 +1,5 @@ package com.eu.habbo.util.callback; -import com.eu.habbo.Emulator; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; - /* public class HTTPVersionCheck implements Runnable { private void sendPost() diff --git a/src/main/java/com/eu/habbo/util/crypto/ZIP.java b/src/main/java/com/eu/habbo/util/crypto/ZIP.java index 4c0e53d6..73461017 100644 --- a/src/main/java/com/eu/habbo/util/crypto/ZIP.java +++ b/src/main/java/com/eu/habbo/util/crypto/ZIP.java @@ -3,19 +3,15 @@ package com.eu.habbo.util.crypto; import java.io.ByteArrayOutputStream; import java.util.zip.Inflater; -public class ZIP -{ - public static byte[] inflate(byte[] data) - { - try - { +public class ZIP { + public static byte[] inflate(byte[] data) { + try { byte[] buffer = new byte[data.length * 5]; Inflater inflater = new Inflater(); inflater.setInput(data); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); - while (!inflater.finished()) - { + while (!inflater.finished()) { int count = inflater.inflate(buffer); outputStream.write(buffer, 0, count); } @@ -24,9 +20,7 @@ public class ZIP inflater.end(); return output; - } - catch (Exception e) - { + } catch (Exception e) { return new byte[0]; } } 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 c30361d6..efbb779a 100644 --- a/src/main/java/com/eu/habbo/util/figure/FigureUtil.java +++ b/src/main/java/com/eu/habbo/util/figure/FigureUtil.java @@ -5,17 +5,13 @@ import org.apache.commons.lang3.ArrayUtils; import java.util.Map; import java.util.Set; -import java.util.StringJoiner; -public class FigureUtil -{ - public static THashMap getFigureBits(String looks) - { +public class FigureUtil { + public static THashMap getFigureBits(String looks) { THashMap bits = new THashMap<>(); String[] sets = looks.split("\\."); - for(String set : sets) - { + for (String set : sets) { String[] setBits = set.split("-", 2); bits.put(setBits[0], setBits.length > 1 ? setBits[1] : ""); } @@ -24,13 +20,11 @@ public class FigureUtil } - public static String mergeFigures(String figure1, String figure2) - { + public static String mergeFigures(String figure1, String figure2) { return mergeFigures(figure1, figure2, null, null); } - public static String mergeFigures(String figure1, String figure2, String[] limitFigure1) - { + public static String mergeFigures(String figure1, String figure2, String[] limitFigure1) { return mergeFigures(figure1, figure2, limitFigure1, null); } @@ -50,31 +44,25 @@ public class FigureUtil return false; } - public static String mergeFigures(String figure1, String figure2, String[] limitFigure1, String[] limitFigure2) - { + public static String mergeFigures(String figure1, String figure2, String[] limitFigure1, String[] limitFigure2) { THashMap figureBits1 = getFigureBits(figure1); THashMap figureBits2 = getFigureBits(figure2); StringBuilder finalLook = new StringBuilder(); - for (Map.Entry keys : figureBits1.entrySet()) - { - if(limitFigure1 == null || ArrayUtils.contains(limitFigure1, keys.getKey())) - { + for (Map.Entry keys : figureBits1.entrySet()) { + if (limitFigure1 == null || ArrayUtils.contains(limitFigure1, keys.getKey())) { finalLook.append(keys.getKey()).append("-").append(keys.getValue()).append("."); } } - for (Map.Entry keys : figureBits2.entrySet()) - { - if(limitFigure2 == null || ArrayUtils.contains(limitFigure2, keys.getKey())) - { + for (Map.Entry keys : figureBits2.entrySet()) { + if (limitFigure2 == null || ArrayUtils.contains(limitFigure2, keys.getKey())) { finalLook.append(keys.getKey()).append("-").append(keys.getValue()).append("."); } } - if(finalLook.toString().endsWith(".")) - { + if (finalLook.toString().endsWith(".")) { finalLook = new StringBuilder(finalLook.substring(0, finalLook.length() - 1)); } 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 e41e2ab5..fb9436ec 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 @@ -15,73 +15,141 @@ import java.awt.image.WritableRaster; import java.io.File; import java.util.Map; -public class BadgeImager -{ +public class BadgeImager { final THashMap cachedImages = new THashMap<>(); - public BadgeImager() - { - if (Emulator.getConfig().getBoolean("imager.internal.enabled")) - { - if(this.reload()) - { + public BadgeImager() { + if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { + if (this.reload()) { Emulator.getLogging().logStart("Badge Imager -> Loaded!"); - } - else - { + } else { Emulator.getLogging().logStart("Badge Imager -> Disabled! Please check your configuration!"); } } } - public synchronized boolean reload() - { + public static BufferedImage deepCopy(BufferedImage bi) { + if (bi == null) + return null; + + ColorModel cm = bi.getColorModel(); + boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); + WritableRaster raster = bi.copyData(null); + return new BufferedImage(cm, raster, isAlphaPremultiplied, null); + } + + public static void recolor(BufferedImage image, Color maskColor) { + for (int x = 0; x < image.getWidth(); x++) { + for (int y = 0; y < image.getHeight(); y++) { + int pixel = image.getRGB(x, y); + + if ((pixel >> 24) == 0x00) + continue; + + Color color = new Color(pixel); + + float alpha = (color.getAlpha() / 255.0F) * (maskColor.getAlpha() / 255.0F); + float red = (color.getRed() / 255.0F) * (maskColor.getRed() / 255.0F); + float green = (color.getGreen() / 255.0F) * (maskColor.getGreen() / 255.0F); + float blue = (color.getBlue() / 255.0F) * (maskColor.getBlue() / 255.0F); +// + + +// + + +// + + + color = new Color(red, green, blue, alpha); + + + int rgb = color.getRGB(); + image.setRGB(x, y, rgb); + } + } + } + + public static Color colorFromHexString(String colorStr) { + try { + return new Color( + Integer.valueOf(colorStr, 16)); + } catch (Exception e) { + return new Color(0xffffff); + } + } + + public static Point getPoint(BufferedImage image, BufferedImage imagePart, int position) { + int x = 0; + int y = 0; + + if (position == 1) { + x = (image.getWidth() - imagePart.getWidth()) / 2; + y = 0; + } else if (position == 2) { + x = image.getWidth() - imagePart.getWidth(); + y = 0; + } else if (position == 3) { + x = 0; + y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); + } else if (position == 4) { + x = (image.getWidth() / 2) - (imagePart.getWidth() / 2); + y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); + } else if (position == 5) { + x = image.getWidth() - imagePart.getWidth(); + y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); + } else if (position == 6) { + x = 0; + y = image.getHeight() - imagePart.getHeight(); + } else if (position == 7) { + x = ((image.getWidth() - imagePart.getWidth()) / 2); + y = image.getHeight() - imagePart.getHeight(); + } else if (position == 8) { + x = image.getWidth() - imagePart.getWidth(); + y = image.getHeight() - imagePart.getHeight(); + } + + return new Point(x, y); + } + + public static BufferedImage convert32(BufferedImage src) { + BufferedImage dest = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB); + ColorConvertOp cco = new ColorConvertOp(src.getColorModel().getColorSpace(), dest.getColorModel().getColorSpace(), null); + return cco.filter(src, dest); + } + + public synchronized boolean reload() { File file = new File(Emulator.getConfig().getValue("imager.location.badgeparts")); - if (!file.exists()) - { + if (!file.exists()) { Emulator.getLogging().logErrorLine("[BadgeImager] Output folder: " + Emulator.getConfig().getValue("imager.location.badgeparts") + " does not exist!"); return false; } this.cachedImages.clear(); - try - { - 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()) - { - try - { + try { + 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()) { + try { this.cachedImages.put(map.getValue().valueA, ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().valueA.replace(".gif", ".png")))); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logStart(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueA.replace(".gif", ".png"))); } } - if (!map.getValue().valueB.isEmpty()) - { - try - { + if (!map.getValue().valueB.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")))); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logStart(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueB.replace(".gif", ".png"))); } } } } } - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return false; } @@ -89,19 +157,15 @@ public class BadgeImager return true; } - public void generate(Guild guild) - { + public void generate(Guild guild) { String badge = guild.getBadge(); File outputFile; - try - { + try { outputFile = new File(Emulator.getConfig().getValue("imager.location.output.badges"), badge + ".png"); if (outputFile.exists()) return; - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); return; } @@ -110,18 +174,14 @@ public class BadgeImager int count = 0; - for (int i = 0; i < badge.length();) - { - if (i > 0) - { - if (i % 7 == 0) - { + for (int i = 0; i < badge.length(); ) { + if (i > 0) { + if (i % 7 == 0) { count++; } } - for (int j = 0; j < 7; j++) - { + for (int j = 0; j < 7; j++) { parts[count] += badge.charAt(i); i++; } @@ -129,27 +189,23 @@ public class BadgeImager BufferedImage image = new BufferedImage(39, 39, BufferedImage.TYPE_INT_ARGB); - Graphics graphics = image.getGraphics(); + Graphics graphics = image.getGraphics(); - for (String s : parts) - { - if(s.isEmpty()) + for (String s : parts) { + if (s.isEmpty()) 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)); + 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)); GuildPart part; - GuildPart color = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.BASE_COLOR, c); + GuildPart color = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.BASE_COLOR, c); - if (type.equalsIgnoreCase("b")) - { + if (type.equalsIgnoreCase("b")) { part = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.BASE, id); - } - else - { + } else { part = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.SYMBOL, id); } @@ -157,10 +213,8 @@ public class BadgeImager Point point; - if (imagePart != null) - { - if (imagePart.getColorModel().getPixelSize() < 32) - { + if (imagePart != null) { + if (imagePart.getColorModel().getPixelSize() < 32) { imagePart = convert32(imagePart); } @@ -171,14 +225,11 @@ public class BadgeImager graphics.drawImage(imagePart, point.x, point.y, null); } - if (!part.valueB.isEmpty()) - { + if (!part.valueB.isEmpty()) { imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.valueB)); - if (imagePart != null) - { - if (imagePart.getColorModel().getPixelSize() < 32) - { + if (imagePart != null) { + if (imagePart.getColorModel().getPixelSize() < 32) { imagePart = convert32(imagePart); } @@ -188,153 +239,12 @@ public class BadgeImager } } - try - { + try { ImageIO.write(image, "PNG", outputFile); - } - catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine("Failed to generate guild badge: " + outputFile + ".png Make sure the output folder exists and is writable!"); } graphics.dispose(); } - - public static BufferedImage deepCopy(BufferedImage bi) - { - if(bi == null) - return null; - - ColorModel cm = bi.getColorModel(); - boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); - WritableRaster raster = bi.copyData(null); - return new BufferedImage(cm, raster, isAlphaPremultiplied, null); - } - - public static void recolor(BufferedImage image, Color maskColor) - { - for (int x = 0; x < image.getWidth(); x++) - { - for (int y = 0; y < image.getHeight(); y++) - { - int pixel = image.getRGB(x, y); - - if((pixel >> 24) == 0x00) - continue; - - Color color = new Color(pixel); - - float alpha = (color.getAlpha() / 255.0F) * (maskColor.getAlpha() / 255.0F); - float red = (color.getRed() / 255.0F) * (maskColor.getRed() / 255.0F); - float green = (color.getGreen() / 255.0F) * (maskColor.getGreen() / 255.0F); - float blue = (color.getBlue() / 255.0F) * (maskColor.getBlue() / 255.0F); -// - - - - - - - - - - - -// - - - - - - - - - - - - -// - - - - - - - color = new Color(red, green, blue, alpha); - - - int rgb = color.getRGB(); - image.setRGB(x, y, rgb); - } - } - } - - public static Color colorFromHexString(String colorStr) - { - try - { - return new Color( - Integer.valueOf(colorStr, 16)); - } - catch (Exception e) - { - return new Color(0xffffff); - } - } - - public static Point getPoint(BufferedImage image, BufferedImage imagePart, int position) - { - int x = 0; - int y = 0; - - if (position == 1) - { - x = (image.getWidth() - imagePart.getWidth()) / 2; - y = 0; - } - else if (position == 2) - { - x = image.getWidth() - imagePart.getWidth(); - y = 0; - } - else if(position == 3) - { - x = 0; - y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); - } - else if(position == 4) - { - x = (image.getWidth() / 2) - (imagePart.getWidth() / 2); - y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); - } - else if(position == 5) - { - x = image.getWidth() - imagePart.getWidth(); - y = (image.getHeight() / 2) - (imagePart.getHeight() / 2); - } - else if(position == 6) - { - x = 0; - y = image.getHeight() - imagePart.getHeight(); - } - else if(position == 7) - { - x = ((image.getWidth() - imagePart.getWidth()) / 2); - y = image.getHeight() - imagePart.getHeight(); - } - else if(position == 8) - { - x = image.getWidth() - imagePart.getWidth(); - y = image.getHeight() - imagePart.getHeight(); - } - - return new Point(x, y); - } - - public static BufferedImage convert32(BufferedImage src) - { - BufferedImage dest = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB); - ColorConvertOp cco = new ColorConvertOp(src.getColorModel().getColorSpace(), dest.getColorModel().getColorSpace(), null); - return cco.filter(src, dest); - } } diff --git a/src/main/java/com/eu/habbo/util/pathfinding/Rotation.java b/src/main/java/com/eu/habbo/util/pathfinding/Rotation.java index 3bf4813e..51af5412 100644 --- a/src/main/java/com/eu/habbo/util/pathfinding/Rotation.java +++ b/src/main/java/com/eu/habbo/util/pathfinding/Rotation.java @@ -1,9 +1,7 @@ package com.eu.habbo.util.pathfinding; -public class Rotation -{ - public static int Calculate(int X1, int Y1, int X2, int Y2) - { +public class Rotation { + public static int Calculate(int X1, int Y1, int X2, int Y2) { int Rotation = 0; if ((X1 > X2) && (Y1 > Y2)) { Rotation = 7; From 53cc5216e8153bf16dae97a2152b6509310e08cc Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 21:34:40 +0300 Subject: [PATCH 022/112] Unidle users when WIRED: Show Message is triggered --- .../items/interactions/wired/effects/WiredEffectWhisper.java | 4 ++++ 1 file changed, 4 insertions(+) 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 f43834ba..3cc5872a 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 @@ -88,6 +88,10 @@ public class WiredEffectWhisper extends InteractionWiredEffect { if (habbo != null) { habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); + + if (habbo.getRoomUnit().isIdle()) { + habbo.getRoomUnit().getRoom().unIdle(habbo); + } return true; } } else { From 7e9eb84d39a41160aba0dfe2606f64fa219eb0fc Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 21:46:00 +0300 Subject: [PATCH 023/112] Remove users with rights when a group is created --- .../eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java index b5b31be9..ea5e530b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java @@ -74,6 +74,7 @@ public class RequestGuildBuyEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge, colorOne, colorTwo); r.setGuild(guild.getId()); + r.removeAllRights(); r.setNeedsUpdate(true); if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { From 766fa148d085b57e00a2056faa76bbd85f3429af Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 21:49:15 +0300 Subject: [PATCH 024/112] Fix NullPointerException in RoomRelativeMapComposer --- .../com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java | 2 +- .../messages/incoming/rooms/RequestRoomHeightmapEvent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java index a827507d..073b2517 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateItemsCommand.java @@ -19,7 +19,7 @@ public class UpdateItemsCommand extends Command { synchronized (Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) { for (Room room : Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) { - if (room.isLoaded() && room.getUserCount() > 0) { + if (room.isLoaded() && room.getUserCount() > 0 && room.getLayout() != null) { room.sendComposer(new RoomRelativeMapComposer(room).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java index 6e281ce2..294f2873 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomHeightmapEvent.java @@ -12,7 +12,7 @@ public class RequestRoomHeightmapEvent extends MessageHandler { if (this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.client.getHabbo().getHabboInfo().getLoadingRoom()); - if (room != null) { + if (room != null && room.getLayout() != null) { this.client.sendResponse(new RoomRelativeMapComposer(room)); this.client.sendResponse(new RoomHeightMapComposer(room)); From 8b6c18c11d271510b107cdfd75aa655b68bd9a6d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 21:54:41 +0300 Subject: [PATCH 025/112] Fix modtool room info --- .../incoming/modtool/ModToolRequestRoomInfoEvent.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java index 3aff8583..5f140550 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomInfoEvent.java @@ -11,10 +11,9 @@ public class ModToolRequestRoomInfoEvent extends MessageHandler { @Override public void handle() throws Exception { if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { - //int roomId = this.packet.readInt(); + int roomId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - //Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); if (room != null) { this.client.sendResponse(new ModToolRoomInfoComposer(room)); From 3506f049ced9f1626d820665f63735d69733b527 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 22:33:51 +0300 Subject: [PATCH 026/112] Add RoomDecoFurniTypeCount achievement --- .../interactions/InteractionBlackHole.java | 2 ++ .../interactions/InteractionMoodLight.java | 2 ++ .../items/interactions/InteractionWater.java | 1 + .../interactions/InteractionWaterItem.java | 1 + .../InteractionWiredHighscore.java | 1 + .../games/InteractionGameTimer.java | 2 ++ .../com/eu/habbo/habbohotel/rooms/Room.java | 10 ++++++++++ .../eu/habbo/habbohotel/users/HabboItem.java | 18 ++++++++++++++++++ 8 files changed, 37 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java index 29c0e0ac..f669479a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java @@ -40,5 +40,7 @@ public class InteractionBlackHole extends InteractionGate { AchievementManager.progressAchievement(this.getUserId(), holeCountAchievement, holeDifference); } } + + super.onPlace(room); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java index d9c181d6..ee30d1eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java @@ -55,6 +55,8 @@ public class InteractionMoodLight extends HabboItem { } } } + + super.onPlace(room); } @Override 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 9a7c0183..0c10f69f 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 @@ -59,6 +59,7 @@ public class InteractionWater extends InteractionDefault { @Override public void onPlace(Room room) { this.recalculate(room); + super.onPlace(room); } public void refreshWaters(Room room) { 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 481c8ad3..a9840636 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 @@ -25,6 +25,7 @@ public class InteractionWaterItem extends InteractionDefault { @Override public void onPlace(Room room) { this.update(); + super.onPlace(room); } @Override 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 5f79597a..9da022e9 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 @@ -143,6 +143,7 @@ public class InteractionWiredHighscore extends HabboItem { @Override public void onPlace(Room room) { this.reloadData(room); + super.onPlace(room); } @Override 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 186d3afd..54d90cd8 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 @@ -138,6 +138,8 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable this.setExtradata(this.timeNow + "\t" + this.baseTime); room.updateItem(this); + + super.onPlace(room); } @Override 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 c1f21496..5077d99a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3994,6 +3994,16 @@ public class Room implements Comparable, ISerialize, Runnable { return this.furniOwnerCount.get(userId); } + public int getUserUniqueFurniCount(int userId) { + THashSet items = new THashSet<>(); + + for (HabboItem item : this.roomItems.valueCollection()) { + if (!items.contains(item.getBaseItem()) && item.getUserId() == userId) items.add(item.getBaseItem()); + } + + return items.size(); + } + public void ejectUserFurni(int userId) { THashSet items = new THashSet<>(); 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 5390cb12..ff027dd2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -323,6 +323,24 @@ public abstract class HabboItem implements Runnable, IEventTriggers { AchievementManager.progressAchievement(this.getUserId(), roomDecoAchievement, difference); } } + + Achievement roomDecoUniqueAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFurniTypeCount"); + + int uniqueFurniCollecterProgress; + if (owner == null) { + uniqueFurniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), roomDecoUniqueAchievement); + } else { + uniqueFurniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoUniqueAchievement); + } + + int uniqueDifference = room.getUserUniqueFurniCount(this.getUserId()) - uniqueFurniCollecterProgress; + if (uniqueDifference > 0) { + if (owner != null) { + AchievementManager.progressAchievement(owner, roomDecoUniqueAchievement, uniqueDifference); + } else { + AchievementManager.progressAchievement(this.getUserId(), roomDecoUniqueAchievement, uniqueDifference); + } + } } public void onPickUp(Room room) { From c06cdb7a0979c755c5aff31d56271d4b024b2d2d Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 20:53:51 +0100 Subject: [PATCH 027/112] Fixed wrong guild furni extradata --- .../items/interactions/InteractionGuildFurni.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 8b3c05ea..667c5f44 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 @@ -35,16 +35,14 @@ public class InteractionGuildFurni extends InteractionDefault { serverMessage.appendString(guild.getBadge()); serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).valueA); serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).valueA); - - super.serializeExtradata(serverMessage); } else { serverMessage.appendInt((this.isLimited() ? 256 : 0)); serverMessage.appendString(this.getExtradata()); + } - if (this.isLimited()) { - serverMessage.appendInt(10); - serverMessage.appendInt(100); - } + if (this.isLimited()) { + serverMessage.appendInt(this.getLimitedSells()); + serverMessage.appendInt(this.getLimitedStack()); } } From 3aead5f30fa8deed97ff0ab259c928b504d34f3b Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 21:05:24 +0100 Subject: [PATCH 028/112] Added unidle when clicked to walk to any spot --- .../incoming/rooms/users/RoomUserWalkEvent.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 0d798aaf..a31b9b15 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; +import com.eu.habbo.plugin.events.users.UserIdleEvent; public class RoomUserWalkEvent extends MessageHandler { @Override @@ -49,6 +50,18 @@ public class RoomUserWalkEvent extends MessageHandler { if (habbo.getHabboInfo().getCurrentRoom() == null || habbo.getHabboInfo().getCurrentRoom().getLayout() == null) return; + if (roomUnit.isIdle()) { + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); + + if (!event.isCancelled()) { + if (!event.idle) { + roomUnit.getRoom().unIdle(habbo); + roomUnit.resetIdleTimer(); + } + } + } + RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); if (tile == null) { From ccca21c171690c66b305012fb7860f1a4bd3fe9a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 23:15:16 +0300 Subject: [PATCH 029/112] Add forum moderation achievements --- .../incoming/users/UserActivityEvent.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java index 74b3030d..42f5c746 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java @@ -9,6 +9,7 @@ public class UserActivityEvent extends MessageHandler { public void handle() throws Exception { String type = this.packet.readString(); String value = this.packet.readString(); + String action = this.packet.readString(); switch (type) { case "Quiz": @@ -16,5 +17,20 @@ public class UserActivityEvent extends MessageHandler { 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; + } } } \ No newline at end of file From 87141be68830fddbb0e9b041a88b81015a1d55c3 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 23:30:51 +0300 Subject: [PATCH 030/112] Send correct amount of pending members --- .../eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 312305a8..439dc4c7 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 @@ -37,7 +37,7 @@ public class GuildMembersComposer extends MessageComposer { this.response.appendString(this.guild.getName()); this.response.appendInt(this.guild.getRoomId()); this.response.appendString(this.guild.getBadge()); - this.response.appendInt(this.guild.getMemberCount()); + this.response.appendInt(this.level == 3 ? this.guild.getRequestCount() : this.guild.getMemberCount()); this.response.appendInt(this.members.size()); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); From 35446586e05102051bffcf22542d05a3046a68c5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 23:46:02 +0300 Subject: [PATCH 031/112] Make pets unstay after 120 seconds --- .../com/eu/habbo/habbohotel/pets/Pet.java | 20 +++++++++++++++++++ .../habbohotel/pets/actions/ActionStay.java | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) 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 8b41ebb2..559a1e4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -46,6 +46,7 @@ public class Pet implements ISerialize, Runnable { private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); private int randomActionTickTimeout = Emulator.getIntUnixTimestamp(); private int postureTimeout = Emulator.getIntUnixTimestamp(); + private int stayStartedAt = 0; private int idleCommandTicks = 0; private int freeCommandTicks = -1; @@ -276,6 +277,11 @@ public class Pet implements ISerialize, Runnable { this.tickTimeout = time; } + + if (this.task == PetTasks.STAY && Emulator.getIntUnixTimestamp() - this.stayStartedAt >= 120) { + this.task = null; + this.getRoomUnit().setCanWalk(true); + } } else { int timeout = Emulator.getRandom().nextInt(10) * 2; this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time); @@ -331,6 +337,12 @@ public class Pet implements ISerialize, Runnable { public void handleCommand(PetCommand command, Habbo habbo, String[] data) { this.idleCommandTicks = 0; + if (this.task == PetTasks.STAY) { + this.stayStartedAt = 0; + this.task = null; + this.getRoomUnit().setCanWalk(true); + } + command.handle(this, habbo, data); @@ -731,4 +743,12 @@ public class Pet implements ISerialize, Runnable { this.room = null; this.needsUpdate = true; } + + public int getStayStartedAt() { + return stayStartedAt; + } + + public void setStayStartedAt(int stayStartedAt) { + this.stayStartedAt = stayStartedAt; + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java index 7ee56474..7b3851cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java @@ -1,5 +1,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.PetTasks; @@ -20,7 +21,7 @@ public class ActionStay extends PetAction { pet.clearPosture(); pet.getRoomUnit().setCanWalk(false); - + pet.setStayStartedAt(Emulator.getIntUnixTimestamp()); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; From 1d8b82c4ecac472b95f8020deee1cf0bb565aaaa Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 23:59:55 +0300 Subject: [PATCH 032/112] Add give user clothing RCON command --- .../habbo/messages/rcon/GiveUserClothing.java | 47 +++++++++++++++++++ .../networking/rconserver/RCONServer.java | 1 + 2 files changed, 48 insertions(+) create mode 100644 src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java new file mode 100644 index 00000000..e601268a --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java @@ -0,0 +1,47 @@ +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.BubbleAlertComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.users.UserClothesComposer; +import com.google.gson.Gson; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class GiveUserClothing extends RCONMessage { + public GiveUserClothing() { + super(GiveUserClothing.JSONGiveUserClothing.class); + } + + @Override + public void handle(Gson gson, GiveUserClothing.JSONGiveUserClothing object) { + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_clothing (user_id, clothing_id) VALUES (?, ?)")) { + statement.setInt(1, object.user_id); + statement.setInt(2, object.clothing_id); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + if (habbo != null) { + GameClient client = habbo.getClient(); + + if (client != null) { + habbo.getInventory().getWardrobeComponent().getClothing().add(object.clothing_id); + client.sendResponse(new UserClothesComposer(habbo)); + client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_REDEEMED.key)); + } + } + } + + static class JSONGiveUserClothing { + public int user_id; + public int clothing_id; + } +} 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 a17c100e..ea65161a 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java @@ -56,6 +56,7 @@ public class RCONServer extends Server { this.addRCONMessage("giverespect", GiveRespect.class); this.addRCONMessage("ignoreuser", IgnoreUser.class); this.addRCONMessage("setmotto", SetMotto.class); + this.addRCONMessage("giveuserclothing", GiveUserClothing.class); Collections.addAll(this.allowedAdresses, Emulator.getConfig().getValue("rcon.allowed", "127.0.0.1").split(";")); } From 12d03bebc92a03c99db8d48a91c38ecc19ee7084 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 00:28:35 +0300 Subject: [PATCH 033/112] Add game-related achievements --- .../java/com/eu/habbo/habbohotel/games/Game.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 1b22ff67..072060e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -142,6 +142,13 @@ public abstract class Game implements Runnable { this.saveScores(); + int totalPointsGained = this.teams.values().stream().mapToInt(GameTeam::getTotalScore).sum(); + + Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getOwnerId()); + if (roomOwner != null) { + AchievementManager.progressAchievement(roomOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GameAuthorExperience"), totalPointsGained); + } + GameTeam winningTeam = null; for (GameTeam team : this.teams.values()) { if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) { @@ -152,6 +159,11 @@ public abstract class Game implements Runnable { if (winningTeam != null) { for (GamePlayer player : winningTeam.getMembers()) { WiredHandler.handleCustomTrigger(WiredTriggerTeamWins.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this}); + + Habbo winner = player.getHabbo(); + if (winner != null) { + AchievementManager.progressAchievement(roomOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GamePlayerExperience")); + } } for (GameTeam team : this.teams.values()) { From 8a1dacd83181f6698096dadbb029900028531473 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 00:35:32 +0300 Subject: [PATCH 034/112] Add tag achievements --- .../tag/icetag/InteractionIceTagField.java | 29 +++++++++++++++++++ .../InteractionRollerskateField.java | 28 ++++++++++++++++++ 2 files changed, 57 insertions(+) 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 c30fe59e..e89d04fb 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,13 +1,22 @@ 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; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; public class InteractionIceTagField extends InteractionTagField { + private final HashMap stepTimes = new HashMap<>(); + public InteractionIceTagField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, IceTagGame.class); } @@ -15,4 +24,24 @@ public class InteractionIceTagField extends InteractionTagField { public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, IceTagGame.class); } + + @Override + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null) + this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); + } + + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null && this.stepTimes.containsKey(habbo)) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); + this.stepTimes.remove(habbo); + } + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java index b00750d1..29e4f8ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java @@ -1,13 +1,21 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.games.tag.RollerskateGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; public class InteractionRollerskateField extends InteractionTagField { + private final HashMap stepTimes = new HashMap<>(); + public InteractionRollerskateField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, RollerskateGame.class); } @@ -15,4 +23,24 @@ public class InteractionRollerskateField extends InteractionTagField { public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, RollerskateGame.class); } + + @Override + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null) + this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); + } + + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null && this.stepTimes.containsKey(habbo)) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); + this.stepTimes.remove(habbo); + } + } } \ No newline at end of file From 8aae182f6a3131cbd214a1757ed60fa3499fc79d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 00:43:14 +0300 Subject: [PATCH 035/112] Add RbBunnyTag achievement --- .../tag/bunnyrun/InteractionBunnyrunField.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 f0ce6d36..ac996a8b 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,8 +1,13 @@ 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; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; @@ -15,4 +20,15 @@ public class InteractionBunnyrunField extends InteractionTagField { public InteractionBunnyrunField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, BunnyrunGame.class); } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + + if (itemOwner != null) { + AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbBunnyTag")); + } + } } \ No newline at end of file From 944115d12c59acdd8d5c50c86e537d5c608ac5d9 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 00:45:51 +0300 Subject: [PATCH 036/112] Add tag field placement achievements --- .../games/tag/icetag/InteractionIceTagField.java | 11 +++++++++++ .../tag/rollerskate/InteractionRollerskateField.java | 11 +++++++++++ 2 files changed, 22 insertions(+) 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 e89d04fb..f83c64fa 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 @@ -44,4 +44,15 @@ public class InteractionIceTagField extends InteractionTagField { this.stepTimes.remove(habbo); } } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + + if (itemOwner != null) { + AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagA")); + } + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java index 29e4f8ec..c25374c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java @@ -43,4 +43,15 @@ public class InteractionRollerskateField extends InteractionTagField { this.stepTimes.remove(habbo); } } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + + if (itemOwner != null) { + AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagA")); + } + } } \ No newline at end of file From ef84be59d0e91d6cb4e4745a1c5a620c0e34b780 Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 23:20:27 +0100 Subject: [PATCH 037/112] Refactor --- src/main/java/com/eu/habbo/habbohotel/pets/Pet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 559a1e4b..2c812849 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -535,7 +535,7 @@ public class Pet implements ISerialize, Runnable { this.level++; this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); this.addHappyness(100); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); + this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LVLUP.getKey()); this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); From 61d7b0e66d6b2a88979c5fe61379b1a876ab038c Mon Sep 17 00:00:00 2001 From: Beny Date: Sun, 26 May 2019 23:44:10 +0100 Subject: [PATCH 038/112] Fixed pet action ActionPlayFootball --- .../pets/actions/ActionPlayFootball.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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 7f8cc949..3f11cdc1 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 @@ -1,9 +1,12 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.habbohotel.items.interactions.InteractionPushable; 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.Room; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; public class ActionPlayFootball extends PetAction { public ActionPlayFootball() { @@ -12,6 +15,25 @@ public class ActionPlayFootball extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { + + Room room = pet.getRoom(); + + if(room == null || room.getLayout() == null) + return false; + + HabboItem foundBall = null; + + for(HabboItem item : room.getFloorItems()) { + if(item instanceof InteractionPushable) { + foundBall = item; + } + } + + if(foundBall == null) + return false; + + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getX(), foundBall.getY())); + if (pet.getHappyness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); else From 798da6d85ae774c7c48581f9db8daed1955a8eef Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 27 May 2019 00:02:55 +0100 Subject: [PATCH 039/112] Added missing statuses to RoomUnitStatus --- .../habbohotel/rooms/RoomUnitStatus.java | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) 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 7ca637b4..73191762 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -2,8 +2,15 @@ package com.eu.habbo.habbohotel.rooms; public enum RoomUnitStatus { MOVE("mv", true), + + SIT_IN("sit-in"), SIT("sit", true), + SIT_OUT("sit-out"), + + LAY_IN("lay-in"), LAY("lay", true), + LAY_OUT("lay-out"), + FLAT_CONTROL("flatctrl"), SIGN("sign"), GESTURE("gst"), @@ -11,11 +18,25 @@ public enum RoomUnitStatus { TRADING("trd"), DIP("dip"), + + EAT_IN("eat-in"), EAT("eat"), + EAT_OUT("eat-out"), + BEG("beg", true), + + DEAD_IN("ded-in"), DEAD("ded", true), + DEAD_OUT("ded-out"), + + JUMP_IN("jmp-in"), JUMP("jmp", true), + JUMP_OUT("jmp-out"), + + PLAY_IN("pla-in"), PLAY("pla", true), + PLAY_OUT("pla-out"), + SPEAK("spk"), CROAK("crk"), RELAX("rlx"), @@ -30,12 +51,20 @@ public enum RoomUnitStatus { GROW_5("grw5"), GROW_6("grw6"), GROW_7("grw7"), - LAY_IN("lay-in"), - LAY_OUT("lay-out"), + KICK("kck"), WAG_TAIL("wag"), - JUMP_IN("jmp-in"), - JUMP_OUT("jmp-out"); + DANCE("dan"), + AMS("ams"), + SWIM("swm"), + TURN("trn"), + + SRP("srp"), + SRP_IN("srp-in"), + + SLEEP_IN("slp-in"), + SLEEP("slp", true), + SLEEP_OUT("slp-out"); public final String key; public final boolean removeWhenWalking; From f5869158e4853288ac0b7235fca190a4a32658af Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 27 May 2019 01:02:30 +0100 Subject: [PATCH 040/112] Pets can swim! --- .../items/interactions/InteractionWater.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 0c10f69f..a7df3c6d 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 @@ -144,14 +144,31 @@ public class InteractionWater extends InteractionDefault { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + Pet pet = room.getPet(roomUnit); - if (pet != null) { - pet.getRoomUnit().setStatus(RoomUnitStatus.DIP, "0"); + if(pet == null) + return; + + if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM)) { + pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, ""); } } + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Pet pet = room.getPet(roomUnit); + + if(pet == null) + return; + + pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM); + } + private void recalculate(Room room) { THashMap tiles = new THashMap<>(); From 9554b969c636b79a9c1191f65b7e5a4a7a30b591 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 12:12:36 +0300 Subject: [PATCH 041/112] Make user walk to correct tile on beds --- .../rooms/users/RoomUserWalkEvent.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index a31b9b15..ea675a1c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -2,13 +2,16 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; 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; public class RoomUserWalkEvent extends MessageHandler { @Override @@ -37,6 +40,7 @@ public class RoomUserWalkEvent extends MessageHandler { } roomUnit = habbo.getRoomUnit(); + Room room = habbo.getHabboInfo().getCurrentRoom(); try { if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) { @@ -47,7 +51,7 @@ public class RoomUserWalkEvent extends MessageHandler { if (x == roomUnit.getX() && y == roomUnit.getY()) return; - if (habbo.getHabboInfo().getCurrentRoom() == null || habbo.getHabboInfo().getCurrentRoom().getLayout() == null) + if (room == null || room.getLayout() == null) return; if (roomUnit.isIdle()) { @@ -62,25 +66,47 @@ public class RoomUserWalkEvent extends MessageHandler { } } - RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); + RoomTile tile = room.getLayout().getTile((short) x, (short) y); if (tile == null) { return; } if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { - if (habbo.getHabboInfo().getCurrentRoom().getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) + if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) return; } - if (tile.isWalkable() || habbo.getHabboInfo().getCurrentRoom().canSitOrLayAt(tile.x, tile.y)) { + if (room.canLayAt(tile.x, tile.y)) { + HabboItem bed = room.getTopItemAt(tile.x, tile.y); + + 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; + } + + if (pillow != null && room.canLayAt(pillow.x, pillow.y)) { + roomUnit.setGoalLocation(pillow); + return; + } + } + } + if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { roomUnit.setGoalLocation(tile); } } else { - RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, habbo.getHabboInfo().getCurrentRoom()).compose()); + RoomTile t = room.getLayout().getTile((short) x, (short) y); + room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose()); if (habbo.getHabboInfo().getRiding() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, habbo.getHabboInfo().getCurrentRoom()).compose()); + room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose()); } } } From 540d401838ab131ee0a35e74445feb0a5b86a70f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 13:39:50 +0300 Subject: [PATCH 042/112] Fix NoSuchElementException in Room cycle --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 2 ++ 1 file changed, 2 insertions(+) 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 b3ed92e6..a9e66571 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -173,6 +173,8 @@ public class RoomUnit { Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); if (peekPath.size() >= 3) { + if (path.isEmpty()) return true; + path.pop(); //peekPath.pop(); //Start peekPath.removeLast(); //End From 381f62eb63796d27a31d9535829546a66abde21c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 13:41:28 +0300 Subject: [PATCH 043/112] Fix NullPointerException in TagGame --- src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java | 2 ++ 1 file changed, 2 insertions(+) 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 fe6afd9d..ff5a8d52 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 @@ -31,6 +31,8 @@ public abstract class TagGame extends Game { @EventHandler public static void onUserLookAtPoint(RoomUnitLookAtPointEvent event) { + if (event.room == null || event.roomUnit == null || event.location == null) return; + if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentLocation(), event.location)) { Habbo habbo = event.room.getHabbo(event.roomUnit); From 8d63982a28142cb4fd77f2a36bcd770bb8876992 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 13:50:42 +0300 Subject: [PATCH 044/112] Fix MysqlDataTruncation in HabboItem --- src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ff027dd2..523b7ddf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -245,7 +245,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setString(3, this.wallPosition); statement.setInt(4, this.x); statement.setInt(5, this.y); - statement.setDouble(6, this.z); + statement.setDouble(6, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)); statement.setInt(7, this.rotation); statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); statement.setString(9, this.limitedStack + ":" + this.limitedSells); From 4dbe78c4ad0c8182055c023d3941d5bd3ed1f797 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 16:00:22 +0300 Subject: [PATCH 045/112] Add saved searches --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 7 ++ .../navigation/NavigatorSavedSearch.java | 34 ++++++++++ .../eu/habbo/habbohotel/users/HabboInfo.java | 64 +++++++++++++++++-- .../com/eu/habbo/messages/PacketManager.java | 2 + .../eu/habbo/messages/incoming/Incoming.java | 2 + .../incoming/handshake/SecureLoginEvent.java | 2 +- .../handshake/SecureLoginEvent_BACKUP.java | 2 +- .../navigator/AddSavedSearchEvent.java | 20 ++++++ .../navigator/DeleteSavedSearchEvent.java | 26 ++++++++ .../RequestNewNavigatorDataEvent.java | 2 +- .../RequestNewNavigatorRoomsEvent.java | 6 +- .../NewNavigatorSavedSearchesComposer.java | 35 +++++----- .../outgoing/rooms/RoomDataComposer.java | 20 +++--- 13 files changed, 185 insertions(+), 37 deletions(-) create mode 100644 sqlupdates/2_0_0_TO_2_1_0-RC-1.sql create mode 100644 src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/navigator/AddSavedSearchEvent.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteSavedSearchEvent.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql new file mode 100644 index 00000000..4625f0a7 --- /dev/null +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -0,0 +1,7 @@ +CREATE TABLE `users_saved_searches` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `search_code` varchar(255) NOT NULL, + `filter` varchar(255) NULL, + `user_id` int(11) NOT NULL, + PRIMARY KEY (`id`) +); \ 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 new file mode 100644 index 00000000..8bcbc62c --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorSavedSearch.java @@ -0,0 +1,34 @@ +package com.eu.habbo.habbohotel.navigation; + +public class NavigatorSavedSearch { + private String searchCode; + private String filter; + 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/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index 609b487a..f8238ca5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; +import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Rank; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -14,11 +15,9 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.procedure.TIntIntProcedure; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; public class HabboInfo implements Runnable { @@ -51,6 +50,7 @@ public class HabboInfo implements Runnable { private String photoJSON; private int webPublishTimestamp; private String machineID; + private HashSet savedSearches = new HashSet<>(); public HabboInfo(ResultSet set) { try { @@ -83,6 +83,7 @@ public class HabboInfo implements Runnable { } this.loadCurrencies(); + this.loadSavedSearches(); } private void loadCurrencies() { @@ -123,6 +124,57 @@ public class HabboInfo implements Runnable { } } + private void loadSavedSearches() { + this.savedSearches = new HashSet<>(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_saved_searches WHERE user_id = ?")) { + statement.setInt(1, this.id); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.savedSearches.add(new NavigatorSavedSearch(set.getString("search_code"), set.getString("filter"), set.getInt("id"))); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void addSavedSearch(NavigatorSavedSearch search) { + this.savedSearches.add(search); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_saved_searches (search_code, filter, user_id) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + statement.setString(1, search.getSearchCode()); + statement.setString(2, search.getFilter()); + statement.setInt(3, this.id); + int affectedRows = statement.executeUpdate(); + + if (affectedRows == 0) { + throw new SQLException("Creating saved search failed, no rows affected."); + } + + try (ResultSet generatedKeys = statement.getGeneratedKeys()) { + if (generatedKeys.next()) { + search.setId(generatedKeys.getInt(1)); + } else { + throw new SQLException("Creating saved search failed, no ID found."); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void deleteSavedSearch(NavigatorSavedSearch search) { + this.savedSearches.remove(search); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_saved_searches WHERE id = ?")) { + statement.setInt(1, search.getId()); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + public int getCurrencyAmount(int type) { return this.currencies.get(type); } @@ -418,6 +470,10 @@ public class HabboInfo implements Runnable { this.machineID = machineID; } + public HashSet getSavedSearches() { + return this.savedSearches; + } + @Override public void run() { this.saveCurrencies(); diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 42901521..b64e7481 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -316,6 +316,8 @@ public class PacketManager { this.registerHandler(Incoming.NavigatorCategoryListModeEvent, NavigatorCategoryListModeEvent.class); this.registerHandler(Incoming.NavigatorCollapseCategoryEvent, NavigatorCollapseCategoryEvent.class); this.registerHandler(Incoming.NavigatorUncollapseCategoryEvent, NavigatorUncollapseCategoryEvent.class); + this.registerHandler(Incoming.AddSavedSearchEvent, AddSavedSearchEvent.class); + this.registerHandler(Incoming.DeleteSavedSearchEvent, DeleteSavedSearchEvent.class); } private void registerHotelview() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index bf3e7b01..1d961b8b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -285,6 +285,8 @@ public class Incoming { public static final int UnbanRoomUserEvent = 992; public static final int RoomUserBanEvent = 1477; public static final int RequestNavigatorSettingsEvent = 1782; + public static final int AddSavedSearchEvent = 2226; + public static final int DeleteSavedSearchEvent = 1954; public static final int SaveWindowSettingsEvent = 3159; public static final int GetHabboGuildBadgesMessageEvent = 21; diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 0ee81ead..b146d0e1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -124,7 +124,7 @@ public class SecureLoginEvent extends MessageHandler { this.client.sendResponse(new NewNavigatorMetaDataComposer()); this.client.sendResponse(new NewNavigatorLiftedRoomsComposer()); this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer()); - this.client.sendResponse(new NewNavigatorSavedSearchesComposer()); + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); this.client.sendResponse(new NewNavigatorEventCategoriesComposer()); this.client.sendResponse(new InventoryRefreshComposer()); //this.client.sendResponse(new ForumsTestComposer()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java index a4d85b53..881579ba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java @@ -70,7 +70,7 @@ public class SecureLoginEvent_BACKUP extends MessageHandler { this.client.sendResponse(new NewNavigatorMetaDataComposer()); this.client.sendResponse(new NewNavigatorLiftedRoomsComposer()); this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer()); - this.client.sendResponse(new NewNavigatorSavedSearchesComposer()); + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); this.client.sendResponse(new NewNavigatorEventCategoriesComposer()); //this.client.sendResponse(new HotelViewComposer()); //this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/AddSavedSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/AddSavedSearchEvent.java new file mode 100644 index 00000000..78be5765 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/AddSavedSearchEvent.java @@ -0,0 +1,20 @@ +package com.eu.habbo.messages.incoming.navigator; + +import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer; + +public class AddSavedSearchEvent extends MessageHandler { + @Override + public void handle() throws Exception { + String searchCode = this.packet.readString(); + String filter = this.packet.readString(); + + if (searchCode.length() > 255) searchCode = searchCode.substring(0, 255); + if (filter.length() > 255) filter = filter.substring(0, 255); + + this.client.getHabbo().getHabboInfo().addSavedSearch(new NavigatorSavedSearch(searchCode, filter)); + + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteSavedSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteSavedSearchEvent.java new file mode 100644 index 00000000..8429ffe3 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteSavedSearchEvent.java @@ -0,0 +1,26 @@ +package com.eu.habbo.messages.incoming.navigator; + +import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSavedSearchesComposer; + +public class DeleteSavedSearchEvent extends MessageHandler { + @Override + public void handle() throws Exception { + int searchId = this.packet.readInt(); + + NavigatorSavedSearch search = null; + for (NavigatorSavedSearch savedSearch : this.client.getHabbo().getHabboInfo().getSavedSearches()) { + if (savedSearch.getId() == searchId) { + search = savedSearch; + break; + } + } + + if (search == null) return; + + this.client.getHabbo().getHabboInfo().deleteSavedSearch(search); + + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); + } +} 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 index fd9a1b09..05442efe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java @@ -10,7 +10,7 @@ public class RequestNewNavigatorDataEvent extends MessageHandler { this.client.sendResponse(new NewNavigatorMetaDataComposer()); this.client.sendResponse(new NewNavigatorLiftedRoomsComposer()); this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer()); - this.client.sendResponse(new NewNavigatorSavedSearchesComposer()); + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); this.client.sendResponse(new NewNavigatorEventCategoriesComposer()); this.client.sendResponse(new NewNavigatorSettingsComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 93c5e7c5..04bc1fa6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -58,10 +58,14 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { return; } - if (filter == null && category != null) { + if (filter == null) { filter = Emulator.getGameEnvironment().getNavigatorManager().filters.get("hotel_view"); } + if (category == null) { + category = Emulator.getGameEnvironment().getRoomManager().getCategoryBySafeCaption("hotel_view"); + } + if (filter == null) return; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java index ff153a7f..5fbe97bc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java @@ -1,34 +1,31 @@ package com.eu.habbo.messages.outgoing.navigator; +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 java.util.HashSet; + public class NewNavigatorSavedSearchesComposer extends MessageComposer { + private final HashSet searches; + + public NewNavigatorSavedSearchesComposer(HashSet searches) { + this.searches = searches; + } + @Override public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorSavedSearchesComposer); - this.response.appendInt(4); + this.response.appendInt(this.searches.size()); - this.response.appendInt(1); - this.response.appendString("official"); - this.response.appendString(""); - this.response.appendString(""); + for (NavigatorSavedSearch search : this.searches) { + this.response.appendInt(search.getId()); + this.response.appendString(search.getSearchCode()); + this.response.appendString(search.getFilter() == null ? "" : search.getFilter()); + this.response.appendString(""); + } - this.response.appendInt(2); - this.response.appendString("recommended"); - this.response.appendString(""); - this.response.appendString(""); - - this.response.appendInt(3); - this.response.appendString("my"); - this.response.appendString(""); - this.response.appendString(""); - - this.response.appendInt(4); - this.response.appendString("favorites"); - this.response.appendString(""); - this.response.appendString(""); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java index fca5fe97..7d3c455c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java @@ -11,20 +11,20 @@ import com.eu.habbo.messages.outgoing.Outgoing; public class RoomDataComposer extends MessageComposer { private final Room room; private final Habbo habbo; - private final boolean publicRoom; - private final boolean unknown; + private final boolean roomForward; + private final boolean enterRoom; - public RoomDataComposer(Room room, Habbo habbo, boolean boolA, boolean boolB) { + public RoomDataComposer(Room room, Habbo habbo, boolean roomForward, boolean enterRoom) { this.room = room; this.habbo = habbo; - this.publicRoom = boolA; - this.unknown = boolB; + this.roomForward = roomForward; + this.enterRoom = enterRoom; } @Override public ServerMessage compose() { this.response.init(Outgoing.RoomDataComposer); - this.response.appendBoolean(this.unknown); + this.response.appendBoolean(this.enterRoom); this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); if (this.room.isPublicRoom()) { @@ -92,10 +92,10 @@ public class RoomDataComposer extends MessageComposer { this.response.appendInt((this.room.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); } - this.response.appendBoolean(this.publicRoom); - this.response.appendBoolean(this.room.isStaffPromotedRoom()); //staffpicked - this.response.appendBoolean(this.room.isPublicRoom()); //ispublicroom - this.response.appendBoolean(this.room.isMuted()); //isroommuted + this.response.appendBoolean(this.roomForward); + this.response.appendBoolean(this.room.isStaffPromotedRoom()); // staffpicked + this.response.appendBoolean(this.room.hasGuild() && Emulator.getGameEnvironment().getGuildManager().getGuildMember(this.room.getGuildId(), this.habbo.getHabboInfo().getId()) != null); // is group member + this.response.appendBoolean(this.room.isMuted()); // isroommuted this.response.appendInt(this.room.getMuteOption()); this.response.appendInt(this.room.getKickOption()); From 48b4c4a9ebbfabebcd1e3baa3dd4d69a914ce883 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 16:05:56 +0300 Subject: [PATCH 046/112] Make bots wave when greeting --- src/main/java/com/eu/habbo/habbohotel/bots/Bot.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 aa5078cf..e6a5d900 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -6,10 +6,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserShoutComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; +import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.plugin.events.bots.BotChatEvent; import com.eu.habbo.plugin.events.bots.BotShoutEvent; import com.eu.habbo.plugin.events.bots.BotTalkEvent; @@ -206,6 +203,10 @@ public class Bot implements Runnable { this.chatTimestamp = Emulator.getIntUnixTimestamp(); this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); + + if (message.equals("o/") || message.equals("_o/")) { + this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose()); + } } } @@ -217,6 +218,10 @@ public class Bot implements Runnable { this.chatTimestamp = Emulator.getIntUnixTimestamp(); this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); + + if (message.equals("o/") || message.equals("_o/")) { + this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose()); + } } } From b6a7668f2575500e6f8cd3b5571b3f2c230ebe76 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 16:14:10 +0300 Subject: [PATCH 047/112] Do not unidle when turning --- .../incoming/rooms/users/RoomUserLookAtPoint.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java index 817c7ef7..e93bf2d5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java @@ -40,6 +40,9 @@ public class RoomUserLookAtPoint extends MessageHandler { if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY)) return; + if (roomUnit.isIdle()) + return; + int x = this.packet.readInt(); int y = this.packet.readInt(); @@ -50,17 +53,6 @@ public class RoomUserLookAtPoint extends MessageHandler { if (tile != null) { roomUnit.lookAtPoint(tile); - - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled()) { - if (!event.idle) { - room.unIdle(habbo); - } - } - - room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } } } From 661fe4879ed00149cb17c779b6cc71ff3777407c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 16:18:36 +0300 Subject: [PATCH 048/112] Fix GuildConfirmRemoveMemberEvent NullPointerException --- .../messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java index 1424241b..5d12d01d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java @@ -18,7 +18,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.ADMIN)) || this.client.getHabbo().hasPermission("acc_guild_admin")) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); int count = 0; if (room != null) { From 00408eeaafb4fddc31f4cc790219ddcfdb9d0cc0 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 16:26:01 +0300 Subject: [PATCH 049/112] Fix NullPointerException in getLowestChair --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 ++ 1 file changed, 2 insertions(+) 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 5077d99a..aaeb9f3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3426,6 +3426,8 @@ public class Room implements Comparable, ISerialize, Runnable { @Deprecated public HabboItem getLowestChair(int x, int y) { + if (this.layout == null) return null; + RoomTile tile = this.layout.getTile((short) x, (short) y); if (tile != null) { From 860e20ce1238b972adaeb9f435cd71ca2e66d8ac Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 22:28:30 +0300 Subject: [PATCH 050/112] Fix saved searches --- .../navigation/NavigatorFavoriteFilter.java | 3 +- .../navigation/NavigatorFilter.java | 1 + .../navigation/NavigatorHotelFilter.java | 3 +- .../navigation/NavigatorManager.java | 40 +++++++++++++++++++ .../navigation/NavigatorPublicFilter.java | 4 +- .../navigation/NavigatorRoomAdsFilter.java | 2 +- .../navigation/NavigatorUserFilter.java | 14 +++---- .../RequestNewNavigatorRoomsEvent.java | 13 ++++++ 8 files changed, 67 insertions(+), 13 deletions(-) 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 942860b5..71225cd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFavoriteFilter.java @@ -18,8 +18,7 @@ public class NavigatorFavoriteFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo) { List resultLists = new ArrayList<>(); - List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo); - Collections.sort(rooms); + 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)); return resultLists; } 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 bcc9767e..52475d0f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorFilter.java @@ -7,6 +7,7 @@ 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 { 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 a5f171e3..ff1b74b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java @@ -21,8 +21,9 @@ public class NavigatorHotelFilter extends NavigatorFilter { public List getResult(Habbo habbo) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); 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().getRoomManager().getPopularRooms(Emulator.getConfig().getInt("hotel.navigator.popular.amount")), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); + 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)); i++; for (Map.Entry> set : Emulator.getGameEnvironment().getRoomManager().getPopularRoomsByCategory(Emulator.getConfig().getInt("hotel.navigator.popular.category.maxresults")).entrySet()) { 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 db49d051..2767a48f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.navigation; 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 java.lang.reflect.Method; @@ -9,6 +10,8 @@ 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; @@ -121,4 +124,41 @@ public class NavigatorManager { return null; } + + public List getRoomsForCategory(String category, Habbo habbo) { + List rooms = new ArrayList<>(); + + switch (category) { + case "my": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo); + break; + case "favorites": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo); + break; + case "history_freq": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsVisited(habbo, false, 10); + break; + case "my_groups": + rooms = Emulator.getGameEnvironment().getRoomManager().getGroupRooms(habbo, 25); + break; + case "with_rights": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(habbo); + break; + case "official-root": + rooms = Emulator.getGameEnvironment().getRoomManager().getPublicRooms(); + break; + case "popular": + rooms = Emulator.getGameEnvironment().getRoomManager().getPopularRooms(Emulator.getConfig().getInt("hotel.navigator.popular.amount")); + break; + case "categories": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsPromoted(); + break; + default: + return null; + } + + Collections.sort(rooms); + + return rooms; + } } 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 7f59ac12..49be285d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java @@ -18,9 +18,11 @@ public class NavigatorPublicFilter extends NavigatorFilter { public List getResult(Habbo habbo) { boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER); 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().getRoomManager().getPublicRooms(), false, showInvisible, DisplayOrder.ORDER_NUM, -1)); + 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)); 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.ACTIVITY, category.order)); 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 d11ec3f1..2e98a9c3 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("acc_enter_anyroom") || 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().getRoomManager().getRoomsPromoted(), false, showInvisible, DisplayOrder.ACTIVITY, 0)); + resultList.add(new SearchResultList(0, "categories", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("categories", ListMode.LIST), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("official-root", DisplayMode.VISIBLE), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("categories", habbo), false, showInvisible, DisplayOrder.ACTIVITY, 0)); return resultList; } } \ No newline at end of file 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 2c4e9416..997a1e5f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java @@ -19,32 +19,30 @@ public class NavigatorUserFilter extends NavigatorFilter { public List getResult(Habbo habbo) { int i = 0; List resultLists = new ArrayList<>(); - List rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo); - Collections.sort(rooms); + + 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)); i++; - List favoriteRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo); - + List favoriteRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("favorites", habbo); if (!favoriteRooms.isEmpty()) { - Collections.sort(favoriteRooms); 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)); i++; } - List frequentlyVisited = Emulator.getGameEnvironment().getRoomManager().getRoomsVisited(habbo, false, 10); + 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)); i++; } - List groupRooms = Emulator.getGameEnvironment().getRoomManager().getGroupRooms(habbo, 25); + 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)); i++; } - List rightRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(habbo); + 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)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 04bc1fa6..8db7fbe4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -17,9 +17,22 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { String view = this.packet.readString(); String query = this.packet.readString(); + if (view.equals("query")) view = "hotel_view"; + NavigatorFilter filter = Emulator.getGameEnvironment().getNavigatorManager().filters.get(view); RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategoryBySafeCaption(view); + if (filter == null) { + List rooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory(view, this.client.getHabbo()); + + 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)); + this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists)); + return; + } + } + String filterField = "anything"; String part = query; NavigatorFilterField field = Emulator.getGameEnvironment().getNavigatorManager().filterSettings.get(filterField); From 3ec3a6aca6bfedd247f9bf52c00abd15f7ead5df Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 22:32:47 +0300 Subject: [PATCH 051/112] Save room settings with password-locked rooms --- .../habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java index 4adf71b4..db338bf2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java @@ -38,7 +38,7 @@ public class RoomSettingsSaveEvent extends MessageHandler { RoomState state = RoomState.values()[this.packet.readInt() % RoomState.values().length]; String password = this.packet.readString(); - if (state == RoomState.PASSWORD && password.isEmpty()) { + if (state == RoomState.PASSWORD && password.isEmpty() && (room.getPassword() == null || room.getPassword().isEmpty())) { this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.PASSWORD_REQUIRED, "")); return; } @@ -75,7 +75,7 @@ public class RoomSettingsSaveEvent extends MessageHandler { room.setName(name); room.setDescription(description); room.setState(state); - room.setPassword(password); + if (!password.isEmpty()) room.setPassword(password); room.setUsersMax(usersMax); From 5943d1f060ab48555017b8e6be98c8672908eda7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 22:55:23 +0300 Subject: [PATCH 052/112] Save UI flags in database --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 5 ++++- .../com/eu/habbo/habbohotel/users/HabboStats.java | 8 ++++++-- .../java/com/eu/habbo/messages/PacketManager.java | 1 + .../com/eu/habbo/messages/incoming/Incoming.java | 1 + .../messages/incoming/users/UpdateUIFlagsEvent.java | 13 +++++++++++++ .../outgoing/users/MeMenuSettingsComposer.java | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index 4625f0a7..a1c78768 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -4,4 +4,7 @@ CREATE TABLE `users_saved_searches` ( `filter` varchar(255) NULL, `user_id` int(11) NOT NULL, PRIMARY KEY (`id`) -); \ No newline at end of file +); + +ALTER TABLE `users_settings` +ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; \ No newline at end of file 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 edca1192..2e180bfc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -80,6 +80,7 @@ public class HabboStats implements Runnable { public long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); + public int uiFlags; private HabboInfo habboInfo; private boolean allowTrade; private int clubExpireTimestamp; @@ -131,6 +132,7 @@ public class HabboStats implements Runnable { this.allowNameChange = set.getString("allow_name_change").equalsIgnoreCase("1"); this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1"); this.forumPostsCount = set.getInt("forums_post_count"); + this.uiFlags = set.getInt("ui_flags"); this.nuxReward = this.nux; try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { @@ -290,7 +292,7 @@ public class HabboStats implements Runnable { @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ? WHERE user_id = ? LIMIT 1")) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -323,7 +325,9 @@ public class HabboStats implements Runnable { statement.setString(30, this.perkTrade ? "1" : "0"); statement.setString(31, this.allowTrade ? "1" : "0"); statement.setInt(32, this.forumPostsCount); - statement.setInt(33, this.habboInfo.getId()); + statement.setInt(33, this.uiFlags); + + statement.setInt(34, this.habboInfo.getId()); statement.executeUpdate(); } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index b64e7481..96dfbb30 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -288,6 +288,7 @@ public class PacketManager { this.registerHandler(Incoming.ChangeNameCheckUsernameEvent, ChangeNameCheckUsernameEvent.class); this.registerHandler(Incoming.ConfirmChangeNameEvent, ConfirmChangeNameEvent.class); this.registerHandler(Incoming.ChangeChatBubbleEvent, ChangeChatBubbleEvent.class); + this.registerHandler(Incoming.UpdateUIFlagsEvent, UpdateUIFlagsEvent.class); } private void registerNavigator() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 1d961b8b..a47fd162 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -289,6 +289,7 @@ public class Incoming { public static final int DeleteSavedSearchEvent = 1954; public static final int SaveWindowSettingsEvent = 3159; public static final int GetHabboGuildBadgesMessageEvent = 21; + public static final int UpdateUIFlagsEvent = 2313; public static final int RequestCraftingRecipesEvent = 1173; public static final int RequestCraftingRecipesAvailableEvent = 3086; 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 new file mode 100644 index 00000000..8983b29e --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java @@ -0,0 +1,13 @@ +package com.eu.habbo.messages.incoming.users; + +import com.eu.habbo.messages.incoming.MessageHandler; + +public class UpdateUIFlagsEvent extends MessageHandler { + @Override + public void handle() throws Exception { + int flags = this.packet.readInt(); + + this.client.getHabbo().getHabboStats().uiFlags = flags; + this.client.getHabbo().getHabboStats().run(); + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java index de1d10b0..48319066 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java @@ -21,7 +21,7 @@ public class MeMenuSettingsComposer extends MessageComposer { this.response.appendBoolean(this.habbo.getHabboStats().preferOldChat); this.response.appendBoolean(this.habbo.getHabboStats().blockRoomInvites); this.response.appendBoolean(this.habbo.getHabboStats().blockCameraFollow); - this.response.appendInt(1); + this.response.appendInt(this.habbo.getHabboStats().uiFlags); this.response.appendInt(this.habbo.getHabboStats().chatColor.getType()); return this.response; } From ae555d29fb982e5f6531365e2bfb0b04ba82ca03 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 23:17:54 +0300 Subject: [PATCH 053/112] Add my friends category to my world in navigator --- .../navigation/NavigatorManager.java | 3 +++ .../navigation/NavigatorUserFilter.java | 6 ++++++ .../habbo/habbohotel/rooms/RoomManager.java | 20 +++++++++++++++++++ .../eu/habbo/habbohotel/users/HabboStats.java | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) 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 2767a48f..070051e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -153,6 +153,9 @@ public class NavigatorManager { case "categories": rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsPromoted(); break; + case "with_friends": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithFriendsIn(habbo, 25); + break; default: return null; } 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 997a1e5f..38f70200 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java @@ -42,6 +42,12 @@ public class NavigatorUserFilter extends NavigatorFilter { 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)); + 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)); 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 de8e9241..967eb331 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -54,6 +54,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; public class RoomManager { private static final int page = 0; @@ -1271,6 +1272,25 @@ public class RoomManager { return rooms; } + public ArrayList getRoomsWithFriendsIn(Habbo habbo, int limit) { + final ArrayList rooms = new ArrayList<>(); + + for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) { + Habbo friend = Emulator.getGameEnvironment().getHabboManager().getHabbo(buddy.getId()); + + if (friend == null || friend.getHabboInfo() == null) continue; + + Room room = friend.getHabboInfo().getCurrentRoom(); + if (room != null) rooms.add(room); + + if (rooms.size() >= limit) break; + } + + Collections.sort(rooms); + + return rooms; + } + public ArrayList getRoomsWithAdminRights(Habbo habbo) { ArrayList rooms = new ArrayList<>(); 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 2e180bfc..6dc2929d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -326,7 +326,7 @@ public class HabboStats implements Runnable { statement.setString(31, this.allowTrade ? "1" : "0"); statement.setInt(32, this.forumPostsCount); statement.setInt(33, this.uiFlags); - + statement.setInt(34, this.habboInfo.getId()); statement.executeUpdate(); } From ad6e70c4e498d4a21797f5ad1fb386bea6ea3d31 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 23:49:01 +0300 Subject: [PATCH 054/112] Make popular groups show top hotel rooms --- .../incoming/navigator/RequestNewNavigatorRoomsEvent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 8db7fbe4..872db874 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -18,6 +18,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { String query = this.packet.readString(); if (view.equals("query")) view = "hotel_view"; + if (view.equals("groups")) view = "hotel_view"; NavigatorFilter filter = Emulator.getGameEnvironment().getNavigatorManager().filters.get(view); RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategoryBySafeCaption(view); From e1695a4879bb01582689646780fa17c4a365593b Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 27 May 2019 22:18:24 +0100 Subject: [PATCH 055/112] Fixed pet scratch to give happiness instead of experience --- src/main/java/com/eu/habbo/habbohotel/pets/Pet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2c812849..3278c90b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -574,7 +574,7 @@ public class Pet implements ISerialize, Runnable { public void scratched(Habbo habbo) { - this.addExperience(10); + this.addHappyness(10); this.addRespect(); if (habbo != null) { From 55e45f14632e64860315984463365ecaef3268b4 Mon Sep 17 00:00:00 2001 From: Beny Date: Tue, 28 May 2019 01:14:42 +0100 Subject: [PATCH 056/112] Fix user rotation doesn't update on click user --- .../habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java index e93bf2d5..2a50be89 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java @@ -53,6 +53,7 @@ public class RoomUserLookAtPoint extends MessageHandler { if (tile != null) { roomUnit.lookAtPoint(tile); + room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } } } From 820388bb6f080557fcdeb561ef7d61551c2ee8bc Mon Sep 17 00:00:00 2001 From: Beny Date: Tue, 28 May 2019 01:15:07 +0100 Subject: [PATCH 057/112] Fix pet scratch happiness and xp --- src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java | 1 + src/main/java/com/eu/habbo/habbohotel/pets/Pet.java | 1 + 2 files changed, 2 insertions(+) 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 d683fd72..beea7293 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -361,6 +361,7 @@ public class MonsterplantPet extends Pet implements IPetLook { public void scratched(Habbo habbo) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5); this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive); + this.addHappyness(10); this.addExperience(10); this.room.sendComposer(new PetStatusUpdateComposer(this).compose()); this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose()); 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 3278c90b..35275e72 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -575,6 +575,7 @@ public class Pet implements ISerialize, Runnable { public void scratched(Habbo habbo) { this.addHappyness(10); + this.addExperience(10); this.addRespect(); if (habbo != null) { From 795ebb1bbff51609c548aa9d17ef8816165f5015 Mon Sep 17 00:00:00 2001 From: Beny Date: Tue, 28 May 2019 01:27:04 +0100 Subject: [PATCH 058/112] Fix pages on group members --- .../habbo/habbohotel/guilds/GuildManager.java | 19 +++++++++++++++++++ .../guilds/GuildDeclineMembershipEvent.java | 2 +- .../guilds/RequestGuildMembersEvent.java | 2 +- .../outgoing/guilds/GuildMembersComposer.java | 6 ++++-- 4 files changed, 25 insertions(+), 4 deletions(-) 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 8005ebb0..df8a64a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -387,6 +387,25 @@ public class GuildManager { return guildMembers; } + public int getGuildMembersCount(Guild guild, int page, int levelId, String query) { + ArrayList guildMembers = new ArrayList(); + + 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()); + statement.setString(2, "%" + query + "%"); + + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + return set.getInt(1); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return 0; + } + public THashMap getOnlyAdmins(Guild guild) { THashMap guildAdmins = new THashMap(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java index 6c1f5d76..e2aede92 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java @@ -25,7 +25,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler { if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("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)); + 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 GuildRefreshMembersListComposer(guild)); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java index f875d94b..0a449e62 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java @@ -24,7 +24,7 @@ public class RequestGuildMembersEvent extends MessageHandler { isAdmin = member != null && 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)); + 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))); } } } 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 439dc4c7..fea8a93e 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 @@ -19,8 +19,9 @@ public class GuildMembersComposer extends MessageComposer { private final int level; private final String searchValue; private final boolean isAdmin; + private final int totalCount; - public GuildMembersComposer(Guild guild, ArrayList members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin) { + 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; @@ -28,6 +29,7 @@ public class GuildMembersComposer extends MessageComposer { this.level = level; this.searchValue = searchValue; this.isAdmin = isAdmin; + this.totalCount = totalCount; } @Override @@ -37,7 +39,7 @@ public class GuildMembersComposer extends MessageComposer { this.response.appendString(this.guild.getName()); this.response.appendInt(this.guild.getRoomId()); this.response.appendString(this.guild.getBadge()); - this.response.appendInt(this.level == 3 ? this.guild.getRequestCount() : this.guild.getMemberCount()); + this.response.appendInt(this.totalCount); this.response.appendInt(this.members.size()); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); From 0a3877db1b5d4329c956e898661dde313d04de31 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 16:26:11 +0300 Subject: [PATCH 059/112] Fix MysqlDataTruncation exception in HabboItem --- src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 523b7ddf..53711bec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -245,7 +245,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setString(3, this.wallPosition); statement.setInt(4, this.x); statement.setInt(5, this.y); - statement.setDouble(6, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)); + + String zString = String.valueOf(Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)); + if (zString.length() > 10) zString = zString.substring(0, 10); + if (zString.endsWith(".")) zString = zString.substring(0, zString.length() - 1); + + statement.setDouble(6, Double.valueOf(zString)); statement.setInt(7, this.rotation); statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); statement.setString(9, this.limitedStack + ":" + this.limitedSells); From 6d23533abd58e54b5d45b8b82dc6266c515aaec2 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 16:52:07 +0300 Subject: [PATCH 060/112] Load navigator after removing a room --- .../navigation/NavigatorManager.java | 3 ++ .../habbo/habbohotel/rooms/RoomManager.java | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) 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 070051e9..e4fea5b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -156,6 +156,9 @@ public class NavigatorManager { case "with_friends": rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithFriendsIn(habbo, 25); break; + case "highest_score": + rooms = Emulator.getGameEnvironment().getRoomManager().getTopRatedRooms(25); + break; default: return 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 967eb331..1b0e7099 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -1236,14 +1236,20 @@ public class RoomManager { public List getGroupRooms(Habbo habbo, int limit) { final ArrayList rooms = new ArrayList<>(); - for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getGuilds(habbo.getHabboInfo().getId())) { - if (guild.getOwnerId() != habbo.getHabboInfo().getId()) { - Room room = this.getRoom(guild.getRoomId()); - - if (room != null) { - rooms.add(room); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM rooms INNER JOIN guilds_members ON guilds_members.guild_id = rooms.guild_id WHERE guilds_members.user_id = ? AND level_id != 3")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.activeRooms.containsKey(set.getInt("id"))) { + rooms.add(this.activeRooms.get(set.getInt("id"))); + } else { + rooms.add(new Room(set)); + } } } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); } Collections.sort(rooms); @@ -1291,6 +1297,29 @@ public class RoomManager { return rooms; } + public List getTopRatedRooms(int limit) { + final ArrayList rooms = new ArrayList<>(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms ORDER BY score DESC LIMIT ?")) { + statement.setInt(1, limit); + + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.activeRooms.containsKey(set.getInt("id"))) { + rooms.add(this.activeRooms.get(set.getInt("id"))); + } else { + rooms.add(new Room(set)); + } + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return rooms; + } + public ArrayList getRoomsWithAdminRights(Habbo habbo) { ArrayList rooms = new ArrayList<>(); From 79f7a8e434380a2780bdf7c63cd9e0ab067adb94 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 19:53:39 +0300 Subject: [PATCH 061/112] Do not show empty tags in navigator --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 aaeb9f3f..84dfd1ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -956,8 +956,10 @@ public class Room implements Comparable, ISerialize, Runnable { message.appendInt(this.score); message.appendInt(0); message.appendInt(this.category); - message.appendInt(this.tags.split(";").length); - for (String s : this.tags.split(";")) { + + String[] tags = Arrays.stream(this.tags.split(";")).filter(t -> !t.isEmpty()).toArray(String[]::new); + message.appendInt(tags.length); + for (String s : tags) { message.appendString(s); } From 30c2936050f6440e4a42794c70b935971d6898db Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 20:28:44 +0300 Subject: [PATCH 062/112] Make teleporters invalidate room kick at door --- .../items/interactions/InteractionTeleport.java | 5 +++++ .../java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 9 ++++++++- .../java/com/eu/habbo/habbohotel/users/HabboItem.java | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) 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 94f219b8..102af6be 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 @@ -216,4 +216,9 @@ public class InteractionTeleport extends HabboItem { public boolean isUsable() { return true; } + + @Override + public boolean invalidatesToRoomKick() { + return 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 a9e66571..c74236cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; +import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; @@ -332,7 +333,13 @@ public class RoomUnit { this.resetIdleTimer(); if (habbo != null) { - if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"))) { + HabboItem topItem = this.room.getTopItemAt(next.x, next.y); + + boolean isAtDoor = next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY(); + boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); + boolean invalidated = topItem != null && topItem.invalidatesToRoomKick(); + + if (this.canLeaveRoomByDoor && isAtDoor && publicRoomKicks && !invalidated) { Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500); } } 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 53711bec..66cdaf73 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -462,4 +462,6 @@ public abstract class HabboItem implements Runnable, IEventTriggers { public void setFromGift(boolean fromGift) { isFromGift = fromGift; } + + public boolean invalidatesToRoomKick() { return false; } } From 01b1f2029a0338b31a525d85d660a9416ea0a99d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 20:56:45 +0300 Subject: [PATCH 063/112] Trigger onWalkOn for teleport tiles after teleport --- .../runnables/teleport/TeleportActionFive.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 a073b23a..f8abd365 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 @@ -2,9 +2,11 @@ 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.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.HabboItem; import com.eu.habbo.threading.runnables.HabboItemNewState; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -54,5 +56,15 @@ class TeleportActionFive implements Runnable { this.room.updateItem(this.currentTeleport); Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); + + HabboItem teleportTile = this.room.getTopItemAt(unit.getX(), unit.getY()); + + if (teleportTile != null && teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { + try { + teleportTile.onWalkOn(unit, this.room, new Object[]{}); + } catch (Exception e) { + e.printStackTrace(); + } + } } } From 1765a14ac1ee0e7a1fcb881ea65caab77611feb6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 May 2019 21:38:16 +0300 Subject: [PATCH 064/112] Fix bot naming --- .../messages/incoming/rooms/bots/BotSaveSettingsEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java index 8d9fa8e8..a0d13549 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java @@ -129,9 +129,9 @@ public class BotSaveSettingsEvent extends MessageHandler { case 5: String name = this.packet.readString(); - boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH; + boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH || name.contains("<") || name.contains(">"); if (!invalidName) { - String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(Jsoup.parse(name).text(), null); + String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(name, null); invalidName = !name.equalsIgnoreCase(filteredName); if (!invalidName) { BotSavedNameEvent nameEvent = new BotSavedNameEvent(bot, name); From cb88b55d737a2b2d0e85fdb9d93384be1cfe0f48 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 29 May 2019 21:37:43 +0300 Subject: [PATCH 065/112] Prevent too big z positions --- .../java/com/eu/habbo/habbohotel/items/ItemManager.java | 2 +- .../java/com/eu/habbo/habbohotel/users/HabboItem.java | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) 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 16a86a43..26fc65ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -272,7 +272,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_cnd_not_freeze", WiredConditionNotFreezeGameActive.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_rank", WiredConditionHabboHasRank.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_not_rank", WiredConditionHabboNotRank.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_credits", WiredConditionHabboHasCredits.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_duckets", WiredConditionHabboHasDuckets.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_diamonds", WiredConditionNotHabboHasDiamonds.class)); 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 66cdaf73..d7a5c7ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -180,6 +180,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } public void setZ(double z) { + if (z > 9999) return; this.z = z; } @@ -245,12 +246,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setString(3, this.wallPosition); statement.setInt(4, this.x); statement.setInt(5, this.y); - - String zString = String.valueOf(Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)); - if (zString.length() > 10) zString = zString.substring(0, 10); - if (zString.endsWith(".")) zString = zString.substring(0, zString.length() - 1); - - statement.setDouble(6, Double.valueOf(zString)); + statement.setDouble(6, Math.min(9999, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6))); statement.setInt(7, this.rotation); statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); statement.setString(9, this.limitedStack + ":" + this.limitedSells); From 4f541985679b3cf3aa58e62839c30e9272d1c3fe Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 29 May 2019 21:38:28 +0300 Subject: [PATCH 066/112] Remove accidental indentation --- src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 26fc65ec..16a86a43 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -272,7 +272,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_cnd_not_freeze", WiredConditionNotFreezeGameActive.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_rank", WiredConditionHabboHasRank.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_not_rank", WiredConditionHabboNotRank.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_credits", WiredConditionHabboHasCredits.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_duckets", WiredConditionHabboHasDuckets.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_diamonds", WiredConditionNotHabboHasDiamonds.class)); From 53b13b7133dc608bf8c39f37e831270bf23a2733 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 13:43:23 +0300 Subject: [PATCH 067/112] Fix too small z positions --- src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d7a5c7ab..213b3124 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -180,7 +180,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } public void setZ(double z) { - if (z > 9999) return; + if (z > 9999 || z < -9999) return; this.z = z; } @@ -246,7 +246,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setString(3, this.wallPosition); statement.setInt(4, this.x); statement.setInt(5, this.y); - statement.setDouble(6, Math.min(9999, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6))); + statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)))); statement.setInt(7, this.rotation); statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); statement.setString(9, this.limitedStack + ":" + this.limitedSells); From e81722f1c78ab7217c88127d1ebef6d547bd8e15 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 17:32:56 +0300 Subject: [PATCH 068/112] Make allowed username characters configurable --- .../incoming/users/ChangeNameCheckUsernameEvent.java | 7 +++---- src/main/java/com/eu/habbo/plugin/PluginManager.java | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java index e640009d..285f1f97 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.List; public class ChangeNameCheckUsernameEvent extends MessageHandler { - public static final String VALID_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."; + public static String VALID_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."; @Override public void handle() throws Exception { @@ -28,8 +28,7 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler { int errorCode = ChangeNameCheckResultComposer.AVAILABLE; List suggestions = new ArrayList<>(4); - if (false) { - } else if (name.length() < 3) { + if (name.length() < 3) { errorCode = ChangeNameCheckResultComposer.TOO_SHORT; } else if (name.length() > 15) { errorCode = ChangeNameCheckResultComposer.TOO_LONG; @@ -42,7 +41,7 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler { } else if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equalsIgnoreCase(name)) { errorCode = ChangeNameCheckResultComposer.NOT_VALID; } else { - String checkName = name.toUpperCase(); + String checkName = name; for (char c : VALID_CHARACTERS.toCharArray()) { checkName = checkName.replace(c + "", ""); } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 9391fcb3..fcd335e9 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -23,6 +23,7 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; +import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent; import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; @@ -118,6 +119,9 @@ public class PluginManager { AchievementManager.TALENTTRACK_ENABLED = Emulator.getConfig().getBoolean("hotel.talenttrack.enabled"); InteractionRoller.NO_RULES = Emulator.getConfig().getBoolean("hotel.room.rollers.norules"); RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics"); + + ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.usernamename.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."); + if (Emulator.isReady) { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPointsScheduler().reloadConfig(); From d603a9cae6023c99400a44e4b16cbce6fd9b7ae0 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 17:37:26 +0300 Subject: [PATCH 069/112] Fix typo on valid character config key --- src/main/java/com/eu/habbo/plugin/PluginManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index fcd335e9..80f56a9b 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -120,7 +120,7 @@ public class PluginManager { InteractionRoller.NO_RULES = Emulator.getConfig().getBoolean("hotel.room.rollers.norules"); RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics"); - ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.usernamename.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."); + ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.username.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."); if (Emulator.isReady) { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); From e2f67a53ad4cef41fb9f9eb08c38044bfc5db130 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 19:18:48 +0300 Subject: [PATCH 070/112] Add default saved searches --- .../com/eu/habbo/habbohotel/users/HabboStats.java | 7 +++++-- .../incoming/handshake/SecureLoginEvent.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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 6dc2929d..7373b749 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -81,6 +81,7 @@ public class HabboStats implements Runnable { public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); public int uiFlags; + public boolean hasGottenDefaultSavedSearches; private HabboInfo habboInfo; private boolean allowTrade; private int clubExpireTimestamp; @@ -133,6 +134,7 @@ public class HabboStats implements Runnable { this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1"); this.forumPostsCount = set.getInt("forums_post_count"); this.uiFlags = set.getInt("ui_flags"); + this.hasGottenDefaultSavedSearches = set.getInt("has_gotten_default_saved_searches") == 1; this.nuxReward = this.nux; try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { @@ -292,7 +294,7 @@ public class HabboStats implements Runnable { @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ? WHERE user_id = ? LIMIT 1")) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ?, has_gotten_default_saved_searches = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -326,8 +328,9 @@ public class HabboStats implements Runnable { statement.setString(31, this.allowTrade ? "1" : "0"); statement.setInt(32, this.forumPostsCount); statement.setInt(33, this.uiFlags); + statement.setInt(34, this.hasGottenDefaultSavedSearches ? 1 : 0); - statement.setInt(34, this.habboInfo.getId()); + statement.setInt(35, this.habboInfo.getId()); statement.executeUpdate(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index b146d0e1..a899c5b0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; +import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboManager; @@ -148,6 +149,17 @@ public class SecureLoginEvent extends MessageHandler { } Messenger.checkFriendSizeProgress(habbo); + + if (!habbo.getHabboStats().hasGottenDefaultSavedSearches) { + habbo.getHabboStats().hasGottenDefaultSavedSearches = true; + Emulator.getThreading().run(habbo.getHabboStats()); + + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("official-root", "")); + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("my", "")); + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("favorites", "")); + + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); + } } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } From c943cd016de13920c33f684d6c126140fe6221a5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 19:20:53 +0300 Subject: [PATCH 071/112] Add default saved searches SQL --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index a1c78768..f046fdf2 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -7,4 +7,7 @@ CREATE TABLE `users_saved_searches` ( ); ALTER TABLE `users_settings` -ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; \ No newline at end of file +ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; + +ALTER TABLE `users_settings` +ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`; \ No newline at end of file From 775ec869742b8a861f1b717b83d6229656a3d9f5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 19:26:42 +0300 Subject: [PATCH 072/112] Add delay to teleport tiles --- .../habbohotel/items/interactions/InteractionTeleport.java | 6 +++++- .../items/interactions/InteractionTeleportTile.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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 102af6be..0106e1b8 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 @@ -204,12 +204,16 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo) { + this.startTeleport(room, habbo, 500); + } + + public void startTeleport(Room room, Habbo habbo, int delay) { if (habbo.getRoomUnit().isTeleporting) return; this.roomUnitID = -1; habbo.getRoomUnit().isTeleporting = true; - Emulator.getThreading().run(new TeleportActionOne(this, room, habbo.getClient()), 500); + Emulator.getThreading().run(new TeleportActionOne(this, room, habbo.getClient()), delay); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java index 8f283757..fc8e7b51 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java @@ -38,7 +38,7 @@ public class InteractionTeleportTile extends InteractionTeleport { if (!habbo.getRoomUnit().isTeleporting) { habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation()); - this.startTeleport(room, habbo); + this.startTeleport(room, habbo, 1000); } } } From 25d8ffba96aabea9d7d93a1d7975a66f2680f3d5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 21:05:25 +0300 Subject: [PATCH 073/112] Add forum thread/comment reporting --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 7 ++- .../habbohotel/modtool/ModToolChatLog.java | 10 +++++ .../habbohotel/modtool/ModToolIssue.java | 3 ++ .../modtool/ModToolIssueChatlogType.java | 21 +++++++++ .../com/eu/habbo/messages/PacketManager.java | 2 + .../eu/habbo/messages/incoming/Incoming.java | 2 + .../ModToolRequestIssueChatlogEvent.java | 34 ++++++++++++--- .../incoming/modtool/ReportCommentEvent.java | 43 +++++++++++++++++++ .../incoming/modtool/ReportThreadEvent.java | 41 ++++++++++++++++++ .../modtool/ModToolIssueChatlogComposer.java | 43 +++++++++++++------ .../runnables/InsertModToolIssue.java | 5 ++- 11 files changed, 191 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/modtool/ReportCommentEvent.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/modtool/ReportThreadEvent.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index f046fdf2..b751625b 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -10,4 +10,9 @@ ALTER TABLE `users_settings` ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; ALTER TABLE `users_settings` -ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`; \ No newline at end of file +ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`; + +ALTER TABLE `support_tickets` +ADD COLUMN `group_id` int(11) NOT NULL AFTER `category`, +ADD COLUMN `thread_id` int(11) NOT NULL AFTER `group_id`, +ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`; \ No newline at end of file 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 8663e27d..0ba469f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatLog.java @@ -5,12 +5,22 @@ public class ModToolChatLog implements Comparable { public final int habboId; public final String username; public final String message; + public final boolean highlighted; 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 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 5e73e86c..531ffb7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -25,6 +25,9 @@ public class ModToolIssue implements ISerialize { public volatile String modName = ""; public String message; public ArrayList chatLogs = null; + public int groupId = -1; + public int threadId = -1; + public int commentId = -1; public ModToolIssue(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java new file mode 100644 index 00000000..35db44b7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssueChatlogType.java @@ -0,0 +1,21 @@ +package com.eu.habbo.habbohotel.modtool; + +public enum ModToolIssueChatlogType { + NORMAL(0), + CHAT(1), + IM(2), + FORUM_THREAD(3), + FORUM_COMMENT(4), + SELFIE(5), + PHOTO(6); + + private int type; + + ModToolIssueChatlogType(int type) { + this.type = type; + } + + public int getType() { + return type; + } +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 96dfbb30..f92cd743 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -466,6 +466,8 @@ public class PacketManager { this.registerHandler(Incoming.ReportBullyEvent, ReportBullyEvent.class); this.registerHandler(Incoming.ReportEvent, ReportEvent.class); this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); + this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class); + this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class); } void registerTrading() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index a47fd162..ba2e48b7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -290,6 +290,8 @@ public class Incoming { public static final int SaveWindowSettingsEvent = 3159; public static final int GetHabboGuildBadgesMessageEvent = 21; public static final int UpdateUIFlagsEvent = 2313; + public static final int ReportThreadEvent = 534; + public static final int ReportCommentEvent = 1412; public static final int RequestCraftingRecipesEvent = 1173; public static final int RequestCraftingRecipesAvailableEvent = 3086; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java index 2b4b31f0..50757290 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java @@ -1,16 +1,16 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.modtool.ModToolChatLog; -import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import com.eu.habbo.habbohotel.modtool.ModToolTicketType; -import com.eu.habbo.habbohotel.modtool.ScripterManager; +import com.eu.habbo.habbohotel.guilds.forums.ForumThread; +import com.eu.habbo.habbohotel.modtool.*; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueChatlogComposer; import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; public class ModToolRequestIssueChatlogEvent extends MessageHandler { @Override @@ -19,11 +19,33 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler { ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt()); if (issue != null) { - ArrayList chatlog; + List chatlog = new ArrayList<>(); + ModToolIssueChatlogType chatlogType = ModToolIssueChatlogType.CHAT; if (issue.type == ModToolTicketType.IM) { chatlog = Emulator.getGameEnvironment().getModToolManager().getMessengerChatlog(issue.reportedId, issue.senderId); + chatlogType = ModToolIssueChatlogType.IM; + } else if (issue.type == ModToolTicketType.DISCUSSION) { + if (issue.commentId == -1) { + chatlogType = ModToolIssueChatlogType.FORUM_THREAD; + + ForumThread thread = ForumThread.getById(issue.threadId); + + if (thread != null) { + chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage())).collect(Collectors.toList()); + } + } else { + chatlogType = ModToolIssueChatlogType.FORUM_COMMENT; + + ForumThread thread = ForumThread.getById(issue.threadId); + + if (thread != null) { + chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage(), c.getCommentId() == issue.commentId)).collect(Collectors.toList()); + } + } } else { + chatlogType = ModToolIssueChatlogType.CHAT; + if (issue.roomId > 0) { chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId); } else { @@ -39,7 +61,7 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler { if (room != null) { roomName = room.getName(); } - this.client.sendResponse(new ModToolIssueChatlogComposer(issue, chatlog, roomName)); + this.client.sendResponse(new ModToolIssueChatlogComposer(issue, chatlog, roomName, chatlogType)); } } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportCommentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportCommentEvent.java new file mode 100644 index 00000000..b21849ba --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportCommentEvent.java @@ -0,0 +1,43 @@ +package com.eu.habbo.messages.incoming.modtool; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.guilds.forums.ForumThread; +import com.eu.habbo.habbohotel.modtool.CfhTopic; +import com.eu.habbo.habbohotel.modtool.ModToolIssue; +import com.eu.habbo.habbohotel.modtool.ModToolTicketType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer; +import com.eu.habbo.threading.runnables.InsertModToolIssue; + +public class ReportCommentEvent extends MessageHandler { + @Override + public void handle() throws Exception { + int groupId = this.packet.readInt(); + int threadId = this.packet.readInt(); + int commentId = this.packet.readInt(); + int topicId = this.packet.readInt(); + String message = this.packet.readString(); + + CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId); + + if (topic == null) return; + + ForumThread thread = ForumThread.getById(threadId); + + if (thread == null) return; + + Habbo opener = Emulator.getGameEnvironment().getHabboManager().getHabbo(thread.getOpenerId()); + + ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), thread.getOpenerId(), opener == null ? "" : opener.getHabboInfo().getUsername(), 0, message, ModToolTicketType.DISCUSSION); + issue.category = topicId; + issue.groupId = groupId; + issue.threadId = threadId; + issue.commentId = commentId; + new InsertModToolIssue(issue).run(); + + this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message)); + Emulator.getGameEnvironment().getModToolManager().addTicket(issue); + Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportThreadEvent.java new file mode 100644 index 00000000..50bcab89 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportThreadEvent.java @@ -0,0 +1,41 @@ +package com.eu.habbo.messages.incoming.modtool; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.guilds.forums.ForumThread; +import com.eu.habbo.habbohotel.modtool.CfhTopic; +import com.eu.habbo.habbohotel.modtool.ModToolIssue; +import com.eu.habbo.habbohotel.modtool.ModToolTicketType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer; +import com.eu.habbo.threading.runnables.InsertModToolIssue; + +public class ReportThreadEvent extends MessageHandler { + @Override + public void handle() throws Exception { + int groupId = this.packet.readInt(); + int threadId = this.packet.readInt(); + int topicId = this.packet.readInt(); + String message = this.packet.readString(); + + CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId); + + if (topic == null) return; + + ForumThread thread = ForumThread.getById(threadId); + + if (thread == null) return; + + Habbo opener = Emulator.getGameEnvironment().getHabboManager().getHabbo(thread.getOpenerId()); + + ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), thread.getOpenerId(), opener == null ? "" : opener.getHabboInfo().getUsername(), 0, message, ModToolTicketType.DISCUSSION); + issue.category = topicId; + issue.groupId = groupId; + issue.threadId = threadId; + new InsertModToolIssue(issue).run(); + + this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message)); + Emulator.getGameEnvironment().getModToolManager().addTicket(issue); + Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java index 1aac7aea..8eef3dc8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java @@ -1,9 +1,8 @@ package com.eu.habbo.messages.outgoing.modtool; -import com.eu.habbo.habbohotel.modtool.ModToolChatLog; -import com.eu.habbo.habbohotel.modtool.ModToolChatRecordDataContext; -import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import com.eu.habbo.habbohotel.modtool.ModToolTicketType; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.*; +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; @@ -11,19 +10,28 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.List; public class ModToolIssueChatlogComposer extends MessageComposer { public static SimpleDateFormat format = new SimpleDateFormat("HH:mm"); private final ModToolIssue issue; - private final ArrayList chatlog; + private final List chatlog; private final String roomName; + private ModToolIssueChatlogType type = ModToolIssueChatlogType.CHAT; - public ModToolIssueChatlogComposer(ModToolIssue issue, ArrayList chatlog, String roomName) { + public ModToolIssueChatlogComposer(ModToolIssue issue, List chatlog, String roomName) { this.issue = issue; this.chatlog = chatlog; this.roomName = roomName; } + public ModToolIssueChatlogComposer(ModToolIssue issue, List chatlog, String roomName, ModToolIssueChatlogType type) { + this.issue = issue; + this.chatlog = chatlog; + this.roomName = roomName; + this.type = type; + } + @Override public ServerMessage compose() { this.response.init(Outgoing.ModToolIssueChatlogComposer); @@ -37,16 +45,26 @@ public class ModToolIssueChatlogComposer extends MessageComposer { if (this.chatlog.isEmpty()) return null; - //ChatRecordData - //for(ModToolRoomVisit visit : chatlog) - //{ - this.response.appendByte(1); //Report Type + this.response.appendByte(this.type.getType()); //Report Type if (this.issue.type == ModToolTicketType.IM) { this.response.appendShort(1); ModToolChatRecordDataContext.MESSAGE_ID.append(this.response); this.response.appendInt(this.issue.senderId); + } else if (this.issue.type == ModToolTicketType.DISCUSSION) { + this.response.appendShort(this.type == ModToolIssueChatlogType.FORUM_COMMENT ? 3 : 2); + + ModToolChatRecordDataContext.GROUP_ID.append(this.response); + this.response.appendInt(this.issue.groupId); + + ModToolChatRecordDataContext.THREAD_ID.append(this.response); + this.response.appendInt(this.issue.threadId); + + if (this.type == ModToolIssueChatlogType.FORUM_COMMENT) { + ModToolChatRecordDataContext.GROUP_ID.append(this.response); + this.response.appendInt(this.issue.commentId); + } } else { this.response.appendShort(3); //Context Count @@ -57,7 +75,8 @@ public class ModToolIssueChatlogComposer extends MessageComposer { this.response.appendInt(this.issue.roomId); ModToolChatRecordDataContext.GROUP_ID.append(this.response); - this.response.appendInt(12); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.issue.roomId); + this.response.appendInt(room == null ? 0 : room.getGuildId()); } this.response.appendShort(this.chatlog.size()); @@ -66,7 +85,7 @@ public class ModToolIssueChatlogComposer extends MessageComposer { this.response.appendInt(chatLog.habboId); this.response.appendString(chatLog.username); this.response.appendString(chatLog.message); - this.response.appendBoolean(false); + this.response.appendBoolean(chatLog.highlighted); } //} 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 cda020d6..af335844 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -14,7 +14,7 @@ public class InsertModToolIssue implements Runnable { @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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + 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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.issue.state.getState()); statement.setInt(2, this.issue.timestamp); statement.setInt(3, this.issue.priority); @@ -24,6 +24,9 @@ public class InsertModToolIssue implements Runnable { statement.setInt(7, this.issue.modId); statement.setString(8, this.issue.message); statement.setInt(9, this.issue.category); + statement.setInt(10, this.issue.groupId); + statement.setInt(11, this.issue.threadId); + statement.setInt(12, this.issue.commentId); statement.execute(); try (ResultSet key = statement.getGeneratedKeys()) { From e21b4cecedfa04da3b809ce2020a8ac191284eb4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 21:16:43 +0300 Subject: [PATCH 074/112] Make sure that users' RoomUnit is removed upon exiting --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 4 ++-- .../com/eu/habbo/threading/runnables/TeleportInteraction.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 1b0e7099..2e0f7702 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -617,7 +617,7 @@ public class RoomManager { habbo.getRoomUnit().setInRoom(true); if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo); + habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo, true); } else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null) { habbo.getMessenger().connectionChanged(habbo, true, true); } @@ -1503,7 +1503,7 @@ public class RoomManager { if (habbo != null) { if (habbo.getHabboInfo().getCurrentRoom() == room) { - room.removeHabbo(habbo); + room.removeHabbo(habbo, true); habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_BANNED)); } } 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 895dde84..b1a73ad7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -67,7 +67,7 @@ class TeleportInteraction extends Thread { if (this.room != this.targetRoom) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); - this.room.removeHabbo(this.client.getHabbo()); + this.room.removeHabbo(this.client.getHabbo(), true); Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), this.targetRoom); } From d8308a25c1e1ec9d76b44ce7035032bfd0d2b652 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 21:19:53 +0300 Subject: [PATCH 075/112] Remove RoomUnit if one exists already --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 2 ++ 1 file changed, 2 insertions(+) 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 2e0f7702..91bdd885 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -577,6 +577,8 @@ public class RoomManager { if (habbo.getRoomUnit() != null) { habbo.getRoomUnit().setRoom(null); + habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); + habbo.getRoomUnit().getRoom().sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); } habbo.setRoomUnit(new RoomUnit()); From c93ca82d8784de8fd5b01168ca1fded45cc79c61 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:08:09 -0400 Subject: [PATCH 076/112] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4441b151..5e0a2d43 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,10 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -Stable Version: **2.0.0** +![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/STATUS-unstable-critical.svg?style=for-the-badge&logo=appveyor) -Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases - -UnStable Version: **2.1.0** +Compiled Download: Has not yet reached a Release Candidate. Client build: **PRODUCTION-201611291003-338511768** From 4c0ab0de15e6793f9efda476ee0dd35c98825ec4 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:08:47 -0400 Subject: [PATCH 077/112] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e0a2d43..0a3e4bb0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.1.0-orange.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/STATUS-unstable-critical.svg?style=for-the-badge&logo=appveyor) Compiled Download: Has not yet reached a Release Candidate. From 1714f54dc3c4ca7dbfed5c96a65b46365610afe7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 31 May 2019 21:23:34 +0300 Subject: [PATCH 078/112] Fix room enterng --- .../java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 91bdd885..28d28c37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -576,9 +576,13 @@ public class RoomManager { habbo.getClient().sendResponse(new HideDoorbellComposer("")); if (habbo.getRoomUnit() != null) { + Room existingRoom = habbo.getRoomUnit().getRoom(); + if (existingRoom != null) { + if (habbo.getRoomUnit().getCurrentLocation() != null) + habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); + habbo.getRoomUnit().getRoom().sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); + } habbo.getRoomUnit().setRoom(null); - habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); - habbo.getRoomUnit().getRoom().sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); } habbo.setRoomUnit(new RoomUnit()); From 25d5a4e1392b175fbf8b4439ca16340a6c208155 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Mon, 3 Jun 2019 03:09:51 +0100 Subject: [PATCH 079/112] Add Missing SQLS --- pom.xml | 2 +- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 10 +++++++++- .../gamecenter/basejump/BaseJumpLoadGameComposer.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a8a1dc64..51d02e18 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eu.habbo Habbo - 2.0.0 + 2.1.0 UTF-8 diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index a1c78768..b751625b 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -7,4 +7,12 @@ CREATE TABLE `users_saved_searches` ( ); ALTER TABLE `users_settings` -ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; \ No newline at end of file +ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; + +ALTER TABLE `users_settings` +ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`; + +ALTER TABLE `support_tickets` +ADD COLUMN `group_id` int(11) NOT NULL AFTER `category`, +ADD COLUMN `thread_id` int(11) NOT NULL AFTER `group_id`, +ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`; \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java index 0a6a45a8..1a9f998d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/gamecenter/basejump/BaseJumpLoadGameComposer.java @@ -38,7 +38,7 @@ public class BaseJumpLoadGameComposer extends MessageComposer { this.response.appendString("accessToken"); this.response.appendString(Emulator.getConfig().getValue("username") + "\t" + Emulator.version + "\t" + this.client.getHabbo().getHabboInfo().getId() + "\t" + this.client.getHabbo().getHabboInfo().getUsername() + "\t" + this.client.getHabbo().getHabboInfo().getLook() + "\t" + this.client.getHabbo().getHabboInfo().getCredits() + "\t" + FASTFOOD_KEY); this.response.appendString("gameServerHost"); - this.response.appendString("arcturus.pw"); + this.response.appendString("google.com"); this.response.appendString("gameServerPort"); this.response.appendString("3002"); this.response.appendString("socketPolicyPort"); From e264c509578e8228e90bc22f6ba9ed6bc15be1a7 Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 3 Jun 2019 20:18:33 +0100 Subject: [PATCH 080/112] Added can_swim to pets --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 7 ++++++- src/main/java/com/eu/habbo/habbohotel/pets/PetData.java | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index b751625b..224de66c 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -15,4 +15,9 @@ ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFT ALTER TABLE `support_tickets` ADD COLUMN `group_id` int(11) NOT NULL AFTER `category`, ADD COLUMN `thread_id` int(11) NOT NULL AFTER `group_id`, -ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`; \ No newline at end of file +ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`; + +ALTER TABLE `pet_actions` +ADD COLUMN `can_swim` enum('1','0') NULL DEFAULT '0' AFTER `random_actions`; + +UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 14 OR `pet_type` = 23 OR `pet_type` = 24 OR `pet_type` = 25 OR `pet_type` = 28 OR `pet_type` = 29 OR `pet_type` = 30 OR `pet_type` = 32; \ No newline at end of file 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 9479b16d..8771b7b3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -31,6 +31,7 @@ public class PetData implements Comparable { public String[] actionsTired; public String[] actionsRandom; public THashMap> petVocals; + public boolean canSwim; private int type; private String name; private List petCommands; @@ -51,6 +52,7 @@ public class PetData implements Comparable { this.actionsHappy = set.getString("happy_actions").split(";"); this.actionsTired = set.getString("tired_actions").split(";"); this.actionsRandom = set.getString("random_actions").split(";"); + this.canSwim = set.getString("can_swim").equalsIgnoreCase("1"); this.reset(); } From 5b4e7f382a79b056d6781cd83c8e37b3a2d49ebb Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 3 Jun 2019 20:34:09 +0100 Subject: [PATCH 081/112] Fixed nullpointers --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 6 +++--- src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 84dfd1ec..fcf71ec4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4588,19 +4588,19 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet units = new THashSet<>(); for (Habbo habbo : this.currentHabbos.values()) { - if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) { + if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) { units.add(habbo.getRoomUnit()); } } for (Pet pet : this.currentPets.valueCollection()) { - if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) { + if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) { units.add(pet.getRoomUnit()); } } for (Bot bot : this.currentBots.valueCollection()) { - if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) { + if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) { units.add(bot.getRoomUnit()); } } 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 c74236cf..d369d23a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -333,7 +333,7 @@ public class RoomUnit { this.resetIdleTimer(); if (habbo != null) { - HabboItem topItem = this.room.getTopItemAt(next.x, next.y); + HabboItem topItem = room.getTopItemAt(next.x, next.y); boolean isAtDoor = next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY(); boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); From 98b9e6c2f4812e3013c0799f960bd4812f09f942 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 3 Jun 2019 16:49:17 -0400 Subject: [PATCH 082/112] Make game timers work properly --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 4 +- .../com/eu/habbo/habbohotel/games/Game.java | 2 - .../games/battlebanzai/BattleBanzaiGame.java | 7 +- .../com/eu/habbo/habbohotel/items/Item.java | 4 + .../habbo/habbohotel/items/ItemManager.java | 7 +- .../games/InteractionGameTimer.java | 303 +++++++++--------- .../InteractionBattleBanzaiTimer.java | 41 --- .../games/freeze/InteractionFreezeTimer.java | 48 --- .../com/eu/habbo/habbohotel/rooms/Room.java | 4 + 9 files changed, 158 insertions(+), 262 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java delete mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index 224de66c..547b1ada 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -20,4 +20,6 @@ ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`; ALTER TABLE `pet_actions` ADD COLUMN `can_swim` enum('1','0') NULL DEFAULT '0' AFTER `random_actions`; -UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 14 OR `pet_type` = 23 OR `pet_type` = 24 OR `pet_type` = 25 OR `pet_type` = 28 OR `pet_type` = 29 OR `pet_type` = 30 OR `pet_type` = 32; \ No newline at end of file +UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 14 OR `pet_type` = 23 OR `pet_type` = 24 OR `pet_type` = 25 OR `pet_type` = 28 OR `pet_type` = 29 OR `pet_type` = 30 OR `pet_type` = 32; + +UPDATE `items_base` SET `customparams` = '30,60,120,180,300,600', `interaction_type` = 'game_timer', `interaction_modes_count` = 1 WHERE `item_name` IN ('fball_counter','bb_counter','es_counter'); 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 072060e2..c52d5115 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -129,8 +129,6 @@ public abstract class Game implements Runnable { Emulator.getPluginManager().fireEvent(gameStartedEvent); } - WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, new Object[]{this}); - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { item.setExtradata("0"); this.room.updateItem(item); 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 92cc9bf0..a5b31e2b 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 @@ -143,11 +143,10 @@ public class BattleBanzaiGame extends Game { if (total >= this.tileCount && this.tileCount != 0) { for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { - if (timer.isRunning()) - timer.setRunning(false); + if (timer.isRunning()) { + timer.endGame(room); + } } - - InteractionGameTimer.endGames(room, true); } } catch (Exception e) { Emulator.getLogging().logErrorLine(e); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java index 1a28b743..8584e582 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -211,4 +211,8 @@ public class Item { public double[] getMultiHeights() { return this.multiHeights; } + + public String getCustomParams() { + return customParams; + } } 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 16a86a43..b475fb1e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -25,7 +25,6 @@ import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.Int import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; -import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateBlue; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateGreen; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateRed; @@ -168,11 +167,11 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class)); this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class)); this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class)); - this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class)); this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class)); this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class)); + this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class)); this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class)); @@ -292,9 +291,6 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_highscore", InteractionWiredHighscore.class)); - //battlebanzai_pyramid - //battlebanzai_puck extends pushable - this.interactionsList.add(new ItemInteraction("battlebanzai_timer", InteractionBattleBanzaiTimer.class)); this.interactionsList.add(new ItemInteraction("battlebanzai_tile", InteractionBattleBanzaiTile.class)); this.interactionsList.add(new ItemInteraction("battlebanzai_random_teleport", InteractionBattleBanzaiTeleporter.class)); this.interactionsList.add(new ItemInteraction("battlebanzai_sphere", InteractionBattleBanzaiSphere.class)); @@ -316,7 +312,6 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("freeze_block", InteractionFreezeBlock.class)); this.interactionsList.add(new ItemInteraction("freeze_tile", InteractionFreezeTile.class)); this.interactionsList.add(new ItemInteraction("freeze_exit", InteractionFreezeExitTile.class)); - this.interactionsList.add(new ItemInteraction("freeze_timer", InteractionFreezeTimer.class)); this.interactionsList.add(new ItemInteraction("freeze_gate_blue", InteractionFreezeGateBlue.class)); 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 54d90cd8..da2a6c73 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 @@ -17,80 +17,120 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionGameTimer extends HabboItem implements Runnable { +public class InteractionGameTimer extends HabboItem implements Runnable { + private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; + private int baseTime = 0; private int timeNow = 0; private boolean isRunning = false; private boolean isPaused = false; private boolean threadActive = false; + public enum InteractionGameTimerAction { + START_STOP(1), + INCREASE_TIME(2); + + private int action; + + InteractionGameTimerAction(int action) { + this.action = action; + } + + public int getAction() { + return action; + } + + public static InteractionGameTimerAction getByAction(int action) { + if (action == 1) return START_STOP; + if (action == 2) return INCREASE_TIME; + + return START_STOP; + } + } + public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - String[] data = set.getString("extra_data").split("\t"); + parseCustomParams(baseItem); - if (data.length >= 2) { - this.baseTime = Integer.valueOf(data[1]); - this.timeNow = this.baseTime; + try { + String[] data = set.getString("extra_data").split("\t"); + + if (data.length >= 2) { + this.baseTime = Integer.valueOf(data[1]); + this.timeNow = this.baseTime; + } + + if (data.length >= 1) { + this.setExtradata(data[0] + "\t0"); + } } - - if (data.length >= 1) { - this.setExtradata(data[0]); + catch (Exception e) { + this.baseTime = TIMER_INTERVAL_STEPS[0]; + this.timeNow = this.baseTime; } } public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + + parseCustomParams(item); } - public static void endGamesIfLastTimer(Room room) { - boolean gamesActive = false; - for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { - if (timer.isRunning()) - gamesActive = true; + public void parseCustomParams(Item baseItem) { + try { + String[] intervalSteps = baseItem.getCustomParams().split(","); + int[] finalSteps = new int[intervalSteps.length]; + for (int i = 0; i < intervalSteps.length; i++) { + finalSteps[i] = Integer.parseInt(intervalSteps[i]); + } + TIMER_INTERVAL_STEPS = finalSteps; } - - if (!gamesActive) { - endGames(room); + catch (Exception e) { + Emulator.getLogging().logErrorLine(e); } } - public static void endGames(Room room) { - endGames(room, false); - } + public void endGame(Room room) { + this.isRunning = false; + this.isPaused = false; - public static void endGames(Room room, boolean overrideTriggerWired) { - - boolean triggerWired = false; - - //end existing games - for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { - Game game = InteractionGameTimer.getOrCreateGame(room, gameClass); - if (!game.state.equals(GameState.IDLE)) { - triggerWired = true; + for (Game game : room.getGames()) { + if (!game.getState().equals(GameState.IDLE)) { game.onEnd(); game.stop(); } } + } - if (triggerWired) { - WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); + private void createNewGame(Room room) { + for(Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { + Game existingGame = room.getGame(gameClass); + + if (existingGame != null) { + existingGame.initialise(); + } else { + try { + Game game = gameClass.getDeclaredConstructor(Room.class).newInstance(room); + room.addGame(game); + game.initialise(); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } } } - public static Game getOrCreateGame(Room room, Class gameClass) { - Game game = (gameClass.cast(room.getGame(gameClass))); - - if (game == null) { - try { - game = gameClass.getDeclaredConstructor(Room.class).newInstance(room); - room.addGame(game); - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); - } + private void pause(Room room) { + for (Game game : room.getGames()) { + game.pause(); } + } - return game; + private void unpause(Room room) { + for (Game game : room.getGames()) { + game.unpause(); + } } @Override @@ -117,27 +157,31 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable this.timeNow--; room.updateItem(this); } else { - this.isRunning = false; - this.isPaused = false; this.threadActive = false; - endGamesIfLastTimer(room); + this.endGame(room); + WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); } } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.endGame(room); + + this.setExtradata(this.baseTime + "\t" + this.baseTime); + this.needsUpdate(true); } @Override public void onPlace(Room room) { - if (this.baseTime == 0) { - this.baseTime = 30; - this.timeNow = this.baseTime; + if (this.baseTime < this.TIMER_INTERVAL_STEPS[0]) { + this.baseTime = this.TIMER_INTERVAL_STEPS[0]; } + this.timeNow = this.baseTime; + this.setExtradata(this.timeNow + "\t" + this.baseTime); room.updateItem(this); + this.needsUpdate(true); super.onPlace(room); } @@ -163,126 +207,84 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { if (this.getExtradata().isEmpty()) { - this.setExtradata("0"); + this.setExtradata("0\t" + this.TIMER_INTERVAL_STEPS[0]); } // if wired triggered it - if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning) { - endGamesIfLastTimer(room); + if (objects.length >= 2 && objects[1] instanceof WiredEffectType) { + if(!(!this.isRunning || this.isPaused)) + return; - for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { - Game game = getOrCreateGame(room, gameClass); - if (!game.isRunning) { - game.initialise(); - } + boolean wasPaused = this.isPaused; + this.endGame(room); + + if(wasPaused) { + WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); } - timeNow = this.baseTime; + this.createNewGame(room); + + this.timeNow = this.baseTime; this.isRunning = true; + this.isPaused = false; + room.updateItem(this); WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{}); if (!this.threadActive) { this.threadActive = true; - Emulator.getThreading().run(this); + Emulator.getThreading().run(this, 1000); } } else if (client != null) { if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER))) return; - int state = 1; + InteractionGameTimerAction state = InteractionGameTimerAction.START_STOP; if (objects.length >= 1 && objects[0] instanceof Integer) { - state = (Integer) objects[0]; + state = InteractionGameTimerAction.getByAction((int) objects[0]); } switch (state) { - case 1: - if (this.isRunning) { + case START_STOP: + if (this.isRunning) { // a game has been started this.isPaused = !this.isPaused; - - boolean allPaused = this.isPaused; - for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { - if (!timer.isPaused) - allPaused = false; - } - - for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { - Game game = getOrCreateGame(room, gameClass); - if (allPaused) { - game.pause(); - } else { - game.unpause(); - } - } - - if (!this.isPaused) { - this.isRunning = true; - timeNow = this.baseTime; - room.updateItem(this); + if (this.isPaused) { + this.pause(room); + } else { + this.unpause(room); if (!this.threadActive) { this.threadActive = true; Emulator.getThreading().run(this); } } - } - - if (!this.isRunning) { - endGamesIfLastTimer(room); - - for (Class gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) { - Game game = getOrCreateGame(room, gameClass); - game.initialise(); - } - - WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{}); + } else { + this.isPaused = false; this.isRunning = true; - timeNow = this.baseTime; + this.timeNow = this.baseTime; room.updateItem(this); + this.createNewGame(room); + WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{this}); + if (!this.threadActive) { this.threadActive = true; - Emulator.getThreading().run(this); + Emulator.getThreading().run(this, 1000); } } + break; - case 2: + case INCREASE_TIME: if (!this.isRunning) { this.increaseTimer(room); - return; + } else if (this.isPaused) { + this.endGame(room); + this.increaseTimer(room); + WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); } - if (this.isPaused) { - this.isPaused = false; - this.isRunning = false; - - timeNow = this.baseTime; - room.updateItem(this); - - endGamesIfLastTimer(room); - } - - break; - - case 3: - - this.isPaused = false; - this.isRunning = false; - - timeNow = this.baseTime; - room.updateItem(this); - - boolean gamesActive = false; - for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) { - if (timer.isRunning()) - gamesActive = true; - } - - if (!gamesActive) { - endGames(room); - } break; } } @@ -299,33 +301,24 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable if (this.isRunning) return; - this.needsUpdate(true); + int baseTime = -1; - switch (this.baseTime) { - case 0: - this.baseTime = 30; - break; - case 30: - this.baseTime = 60; - break; - case 60: - this.baseTime = 120; - break; - case 120: - this.baseTime = 180; - break; - case 180: - this.baseTime = 300; - break; - case 300: - this.baseTime = 600; - break; - //case 600: this.baseTime = 0; break; + if (this.timeNow != this.baseTime) { + baseTime = this.baseTime; + } else { + for (int step : this.TIMER_INTERVAL_STEPS) { + if (this.timeNow < step) { + baseTime = step; + break; + } + } - default: - this.baseTime = 30; + if (baseTime == -1) baseTime = this.TIMER_INTERVAL_STEPS[0]; } + this.baseTime = baseTime; + this.setExtradata(this.timeNow + "\t" + this.baseTime); + this.timeNow = this.baseTime; room.updateItem(this); this.needsUpdate(true); @@ -333,11 +326,9 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable @Override public String getDatabaseExtraData() { - return this.getExtradata() + "\t" + this.baseTime; + return this.getExtradata(); } - public abstract Class getGameType(); - @Override public boolean allowWiredResetState() { return true; @@ -350,12 +341,4 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable public void setRunning(boolean running) { isRunning = running; } - - public int getTimeNow() { - return timeNow; - } - - public void setTimeNow(int timeNow) { - this.timeNow = timeNow; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java deleted file mode 100644 index e21ff2d3..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTimer.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai; - -import com.eu.habbo.habbohotel.games.Game; -import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class InteractionBattleBanzaiTimer extends InteractionGameTimer { - public InteractionBattleBanzaiTimer(ResultSet set, Item baseItem) throws SQLException { - super(set, baseItem); - } - - public InteractionBattleBanzaiTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - } - - @Override - public Class getGameType() { - return BattleBanzaiGame.class; - } - - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return false; - } - - @Override - public boolean isWalkable() { - return false; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java deleted file mode 100644 index e2e91480..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTimer.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.games.freeze; - -import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.games.Game; -import com.eu.habbo.habbohotel.games.freeze.FreezeGame; -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class InteractionFreezeTimer extends InteractionGameTimer { - public InteractionFreezeTimer(ResultSet set, Item baseItem) throws SQLException { - super(set, baseItem); - } - - public InteractionFreezeTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - } - - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return false; - } - - @Override - public boolean isWalkable() { - return false; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } - - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - } - - - @Override - public Class getGameType() { - return FreezeGame.class; - } -} 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 fcf71ec4..e2960038 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2147,6 +2147,10 @@ public class Room implements Comparable, ISerialize, Runnable { return null; } + public ConcurrentSet getGames() { + return this.games; + } + public int getUserCount() { return this.currentHabbos.size(); } From d1df7b53cb725dd2b661c5868374167e75c97088 Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 3 Jun 2019 22:50:18 +0100 Subject: [PATCH 083/112] Match GameTeamColors with Habbo --- .../habbohotel/games/GameTeamColors.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java index 0a573e3c..1f22eb55 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeamColors.java @@ -2,19 +2,12 @@ package com.eu.habbo.habbohotel.games; public enum GameTeamColors { - RED(0), + NONE(0), - - GREEN(1), - - - BLUE(2), - - - YELLOW(3), - - - NONE(4), + RED(1), + GREEN(2), + BLUE(3), + YELLOW(4), ONE(5), TWO(6), @@ -41,6 +34,6 @@ public enum GameTeamColors { } } - return RED; + return NONE; } } From 46b0e57a50d38024a58a66ca2258aabced488057 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Jun 2019 00:47:18 +0300 Subject: [PATCH 084/112] Fix moodlight turning on/off --- .../incoming/rooms/items/MoodLightTurnOnEvent.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java index 2083c819..eee75a7b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java @@ -16,16 +16,20 @@ public class MoodLightTurnOnEvent extends MessageHandler { return; for (HabboItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { - //Enabled, preset id, background only ? 2 : 1, color, intensity + // enabled ? 2 : 1, preset id, background only ? 2 : 1, color, intensity - - moodLight.setExtradata("2,1,2,#FF00FF,255"); + String extradata = "2,1,2,#FF00FF,255"; for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { if (data.isEnabled()) { - moodLight.setExtradata(data.toString()); + extradata = data.toString(); break; } } + + RoomMoodlightData adjusted = RoomMoodlightData.fromString(extradata); + if (RoomMoodlightData.fromString(moodLight.getExtradata()).isEnabled()) adjusted.disable(); + moodLight.setExtradata(adjusted.toString()); + moodLight.needsUpdate(true); room.updateItem(moodLight); Emulator.getThreading().run(moodLight); From 5fecc3ec12c533d43babfa683e4750ca9caa4375 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:02:22 -0400 Subject: [PATCH 085/112] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a3e4bb0..1df67672 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,12 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.1.0-orange.svg?style=for-the-badge&logo=appveyor) -![image](https://img.shields.io/badge/STATUS-unstable-critical.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) +Stable Version: **2.0.0** -Compiled Download: Has not yet reached a Release Candidate. +Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases + +UnStable Version: **2.1.0** Client build: **PRODUCTION-201611291003-338511768** From 00deb264c085c589deeb3a5433cfb99a74c86098 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:04:24 -0400 Subject: [PATCH 086/112] Update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 1df67672..c145f88e 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,8 @@ Arcturus Morningstar is released under the [GNU General Public License v3](https ## Versions ## ![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) -Stable Version: **2.0.0** - +![image](https://img.shields.io/badge/VERSION-2.0.0-success.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases - -UnStable Version: **2.1.0** - Client build: **PRODUCTION-201611291003-338511768** ## Reporting problems ## From cf175e30468ebe1fe3129308e6cd4d84a56c2f3a Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:04:47 -0400 Subject: [PATCH 087/112] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c145f88e..b294174a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ Arcturus Morningstar is released under the [GNU General Public License v3](https ## Versions ## ![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) + ![image](https://img.shields.io/badge/VERSION-2.0.0-success.svg?style=for-the-badge&logo=appveyor) + Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases Client build: **PRODUCTION-201611291003-338511768** From b05a36a508008f6849a9677ccb0aab128965c7b7 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:05:05 -0400 Subject: [PATCH 088/112] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b294174a..763ac232 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ Arcturus Morningstar is released under the [GNU General Public License v3](https ## Versions ## ![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) - ![image](https://img.shields.io/badge/VERSION-2.0.0-success.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases + Client build: **PRODUCTION-201611291003-338511768** ## Reporting problems ## From 4047d1aa43348a0da333291e4863bade733fe3b2 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 31 May 2019 11:09:42 -0400 Subject: [PATCH 089/112] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 763ac232..b9d405d0 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/VERSION-2.0.0-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From 6eccf01f6ee3c03cfb0af783f9bfb8fb41949d70 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sun, 9 Jun 2019 00:13:23 +0100 Subject: [PATCH 090/112] Fixed Pathfinder. Credits to Quadral. Note this is a test. --- src/main/java/com/eu/habbo/Emulator.java | 12 -- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 110 ++++++------------ .../eu/habbo/habbohotel/rooms/RoomTile.java | 14 +++ .../eu/habbo/habbohotel/rooms/RoomUnit.java | 26 +++-- .../rooms/users/RoomUserWalkEvent.java | 41 +++++-- 5 files changed, 100 insertions(+), 103 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index af521b00..506b10c4 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -97,12 +97,6 @@ public final class Emulator { Emulator.runtime = Runtime.getRuntime(); Emulator.config = new ConfigurationManager("config.ini"); - - if (Emulator.getConfig().getValue("username").isEmpty()) { - Emulator.getLogging().logErrorLine("Please make sure you enter your forum login details!"); - Thread.sleep(2000); - } - Emulator.database = new Database(Emulator.getConfig()); Emulator.config.loaded = true; Emulator.config.loadFromDatabase(); @@ -123,12 +117,6 @@ public final class Emulator { Emulator.rconServer.initializePipeline(); Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - // Removed Wesleys Camera Server lol. - /* if (Emulator.getConfig().getBoolean("camera.enabled")) - { - Emulator.getThreading().run(new CameraClientAutoReconnect()); - } - */ Emulator.getLogging().logStart("Habbo Hotel Emulator has succesfully loaded."); Emulator.getLogging().logStart("You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); 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 7da2e518..258d023b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -253,42 +253,29 @@ public class RoomLayout { return this.roomTiles[x][y].state == RoomTileState.INVALID; } - public RoomTileState getStateAt(short x, short y) { - return this.roomTiles[x][y].state; - } - public String getRelativeMap() { return this.heightmap.replace("\r\n", "\r"); - } + }//re + /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) { + if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) + return new LinkedList<>(); LinkedList openList = new LinkedList<>(); - try { - if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) - return openList; - - List closedList = new LinkedList<>(); - - openList.add(oldTile.copy()); - - long startMillis = System.currentTimeMillis(); - while (true) { - if (System.currentTimeMillis() - startMillis > 50) { - return new LinkedList<>(); - } - - RoomTile current = this.lowestFInOpen(openList); - openList.remove(current); - - if ((current.x == newTile.x) && (current.y == newTile.y)) { - return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); - } - - List adjacentNodes = this.getAdjacent(openList, current, newTile); - - for (RoomTile currentAdj : adjacentNodes) { - if (closedList.contains(currentAdj)) continue; + List closedList = new LinkedList<>(); + RoomTile current; + openList.add(oldTile.copy()); + while (!openList.isEmpty()) { + current = this.lowestFInOpen(openList); + if ((current.x == newTile.x) && (current.y == newTile.y)) { + return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); + } + closedList.add(current); + openList.remove(current); + List adjacentNodes = this.getAdjacent(openList, current, newTile); + for (RoomTile currentAdj : adjacentNodes) { + if (closedList.contains(currentAdj)) continue; if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) { currentAdj.setPrevious(current); currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); @@ -296,50 +283,31 @@ public class RoomLayout { openList.add(currentAdj); continue; } - - //If the tile is sitable or layable and its not our goal tile, we cannot walk over it. - if (!currentAdj.equals(goalLocation) && (currentAdj.state == RoomTileState.BLOCKED || currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY)) { - closedList.add(currentAdj); - openList.remove(currentAdj); - continue; - } - ////if (!room.getLayout().tileWalkable((short) currentAdj.x, (short) currentAdj.y)) continue; - - //Height difference. - double height = currentAdj.getStackHeight() - current.getStackHeight(); - - //If we are not allowed to fall and the height difference is bigger than the maximum stepheight, continue. - if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; - - //If the step difference is bigger than the maximum step height, continue. - if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; - - //Check if the tile has habbos. - if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { - closedList.add(currentAdj); - openList.remove(currentAdj); - continue; - } - - //if (room.hasPetsAt(currentAdj.x, currentAdj.y)) continue; - - if (!openList.contains(currentAdj)) { - currentAdj.setPrevious(current); - currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); - currentAdj.setgCosts(current); - openList.add(currentAdj); - } else if (currentAdj.getgCosts() > currentAdj.calculategCosts(current)) { - currentAdj.setPrevious(current); - currentAdj.setgCosts(current); - } + if ((currentAdj.state == RoomTileState.BLOCKED) || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) { + closedList.add(currentAdj); + openList.remove(currentAdj); + continue; } - if (openList.isEmpty()) { - return new LinkedList<>(); + double height = currentAdj.getStackHeight() - current.getStackHeight(); + if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; + if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; + if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + closedList.add(currentAdj); + openList.remove(currentAdj); + continue; + } + if (!openList.contains(currentAdj)) { + currentAdj.setPrevious(current); + currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); + currentAdj.setgCosts(current); + openList.add(currentAdj); + } else if (currentAdj.getgCosts() > currentAdj.calculategCosts(current)) { + currentAdj.setPrevious(current); + currentAdj.setgCosts(current); } } - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); } + // System.out.println("Invalid Path."); return new LinkedList<>(); } @@ -605,8 +573,6 @@ public class RoomLayout { } public boolean fitsOnMap(RoomTile tile, int width, int length, int rotation) { - THashSet pointList = new THashSet<>(width * length, 0.1f); - if (tile != null) { if (rotation == 0 || rotation == 4) { for (short i = tile.x; i <= (tile.x + (width - 1)); i++) { 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 61d1db47..d3978d8d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -47,6 +47,20 @@ public class RoomTile { this.units = tile.units; } + public RoomTile() + { + x = 0; + y = 0; + z = 0; + this.stackHeight = 0; + this.state = RoomTileState.INVALID; + this.allowStack = false; + this.diagonally = false; + this.gCosts = 0; + this.hCosts = 0; + this.units = null; + } + public double getStackHeight() { return this.stackHeight; } 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 d369d23a..07809406 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -227,17 +227,15 @@ public class RoomUnit { //if(!(this.path.size() == 0 && canSitNextTile)) { - if (!room.tileWalkable(next.x, next.y) && !overrideChecks) { + if (!room.tileWalkable(next)) { this.room = room; this.findPath(); - if (!this.path.isEmpty()) { - next = this.path.pop(); - item = room.getTopItemAt(next.x, next.y); - } else { + if (this.path.isEmpty()) { this.status.remove(RoomUnitStatus.MOVE); return false; } + next = (RoomTile)this.path.pop(); } } @@ -465,14 +463,15 @@ public class RoomUnit { public void setGoalLocation(RoomTile goalLocation) { if (goalLocation != null) { - if (goalLocation.state != RoomTileState.INVALID) { + // if (goalLocation.state != RoomTileState.INVALID) { this.setGoalLocation(goalLocation, false); } - } + //} } public void setGoalLocation(RoomTile goalLocation, boolean noReset) { - if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) { + if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) + { Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation); Emulator.getPluginManager().fireEvent(event); @@ -480,16 +479,18 @@ public class RoomUnit { return; } + /// Set start location this.startLocation = this.currentLocation; if (goalLocation != null && !noReset) { this.goalLocation = goalLocation; - this.findPath(); + this.findPath(); ///< Quadral: this is where we start formulating a path if (!this.path.isEmpty()) { this.tilesWalked = 0; this.cmdSit = false; } else { this.goalLocation = this.currentLocation; + } } } @@ -524,8 +525,11 @@ public class RoomUnit { this.room = room; } - 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))) { + 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))) + { + this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index ea675a1c..08966a11 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -15,20 +15,28 @@ import gnu.trove.set.hash.THashSet; public class RoomUserWalkEvent extends MessageHandler { @Override - public void handle() throws Exception { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - int x = this.packet.readInt(); - int y = this.packet.readInt(); + public void handle() throws Exception + { + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) + { + int x = this.packet.readInt(); ///< Position X + int y = this.packet.readInt(); /// Date: Mon, 10 Jun 2019 18:47:39 +0300 Subject: [PATCH 091/112] Make YTTVs work properly --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 46 ++++ .../UpdateYoutubePlaylistsCommand.java | 22 ++ .../habbohotel/items/YoutubeManager.java | 209 ++++++++++++------ .../interactions/InteractionYoutubeTV.java | 49 +++- .../com/eu/habbo/messages/PacketManager.java | 12 +- .../eu/habbo/messages/incoming/Incoming.java | 6 +- .../youtube/YoutubeRequestNextVideoEvent.java | 28 --- .../youtube/YoutubeRequestPlaylistChange.java | 55 +++++ ...vent.java => YoutubeRequestPlaylists.java} | 6 +- .../youtube/YoutubeRequestStateChange.java | 108 +++++++++ .../youtube/YoutubeRequestVideoDataEvent.java | 28 --- .../youtube/YoutubeDisplayListComposer.java | 22 +- .../youtube/YoutubeStateChangeComposer.java | 24 ++ .../items/youtube/YoutubeVideoComposer.java | 20 +- .../runnables/YoutubeAdvanceVideo.java | 33 +++ 15 files changed, 513 insertions(+), 155 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/UpdateYoutubePlaylistsCommand.java delete mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylistChange.java rename src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/{YoutubeRequestPlayListEvent.java => YoutubeRequestPlaylists.java} (79%) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java delete mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java create mode 100644 src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeStateChangeComposer.java create mode 100644 src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index 547b1ada..e65f64fc 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -23,3 +23,49 @@ ADD COLUMN `can_swim` enum('1','0') NULL DEFAULT '0' AFTER `random_actions`; UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 14 OR `pet_type` = 23 OR `pet_type` = 24 OR `pet_type` = 25 OR `pet_type` = 28 OR `pet_type` = 29 OR `pet_type` = 30 OR `pet_type` = 32; UPDATE `items_base` SET `customparams` = '30,60,120,180,300,600', `interaction_type` = 'game_timer', `interaction_modes_count` = 1 WHERE `item_name` IN ('fball_counter','bb_counter','es_counter'); + +ALTER TABLE `youtube_playlists` +DROP COLUMN `order`, +CHANGE COLUMN `video_id` `playlist_id` varchar(255) NOT NULL COMMENT 'YouTube playlist ID' AFTER `item_id`; + +DROP TABLE `youtube_items`; + +TRUNCATE TABLE `youtube_playlists`; + +DROP PROCEDURE IF EXISTS DEFAULT_YTTV_PLAYLISTS; +DELIMITER ;; + +CREATE PROCEDURE DEFAULT_YTTV_PLAYLISTS() +BEGIN + DECLARE n INT DEFAULT 0; + DECLARE i INT DEFAULT 0; + DECLARE a INT DEFAULT 0; + DECLARE itemId INT default 0; + SELECT COUNT(*) FROM `items_base` WHERE `interaction_type` = 'youtube' INTO n; + SET i=0; + + SET @defaultPlaylistIds = '["PL4YfV2mXS8WXOkxFly7YsGL8cKtqp873p","PL4F5KzcUTpEdux38c8CYunT9uNh_k2NPt","PL4F5KzcUTpEcO-1iw3P6gavJ_ALTxqNHn","PL4F5KzcUTpEfpHad_B7j_MulB3-cwtLFh","PL4F5KzcUTpEekJPbcVOaNYVV6VLSo9zRB","PL80F08DAE1B614BA9","PL4F5KzcUTpEfeS5t7EiEIYbpplZivDZTL","PL4ACB18CA629E650A","PL4F5KzcUTpEfyRBCOVKQ4qxlSoHsGDZ82","PL4F5KzcUTpEet7EMwhw0ge5n2oNMr7JY8","PL4F5KzcUTpEfTW4fkX9vrt497MEvWorwK","PL4F5KzcUTpEcit3i1q55-IFFndmo_dsR8","PL4F5KzcUTpEeJleVUhO1MWRJyYDWWp9Do","PL4F5KzcUTpEcFzCpH2_EXtwzKQH8mJGd9","PL4F5KzcUTpEcIiSOH2x3sg2jwACNbSIm9","PL4F5KzcUTpEfRxBiXwTBA7oiybPqoZD_j","PL4YfV2mXS8WUo09aevZX-b47k4PD08-i8","PL4F5KzcUTpEcFzCpH2_EXtwzKQH8mJGd9"]'; + + WHILE i < n DO + SET itemId = (SELECT id FROM `items_base` WHERE `interaction_type` = 'youtube' LIMIT i, 1); + + WHILE a> playLists = new THashMap<>(); - public THashMap videos = new THashMap<>(); + public 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; + } + } + + public 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 THashMap> playlists = new THashMap<>(); + private THashMap playlistCache = new THashMap<>(); public void load() { - this.videos.clear(); - this.playLists.clear(); + this.playlists.clear(); + this.playlistCache.clear(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (Statement statement = connection.createStatement()) { - try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_items")) { - while (set.next()) { - this.videos.put(set.getInt("id"), new YoutubeItem(set)); - } - } + long millis = System.currentTimeMillis(); - try (ResultSet set = statement.executeQuery("SELECT * FROM youtube_playlists ORDER BY `order` ASC")) { - while (set.next()) { - if (!this.playLists.containsKey(set.getInt("item_id"))) { - this.playLists.put(set.getInt("item_id"), new ArrayList<>()); + ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); + + Emulator.getLogging().logStart("YouTube Manager -> Loading..."); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + final int itemId = set.getInt("item_id"); + final String playlistId = set.getString("playlist_id"); + + youtubeDataLoaderPool.submit(() -> { + ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); + + YoutubePlaylist playlist = this.playlistCache.containsKey(playlistId) ? this.playlistCache.get(playlistId) : this.getPlaylistDataById(playlistId); + if (playlist != null) { + playlists.add(playlist); + + this.playlistCache.put(playlistId, playlist); + } else { + Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); } - YoutubeItem item = this.videos.get(set.getInt("video_id")); - - if (item != null) { - this.playLists.get(set.getInt("item_id")).add(item); - } - } + this.playlists.put(itemId, playlists); + }); } } } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - } - public ArrayList getPlaylist(Item item) { - if (this.playLists.containsKey(item.getId())) { - return this.playLists.get(item.getId()); + youtubeDataLoaderPool.shutdown(); + try { + youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); } - return new ArrayList<>(); + Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - public YoutubeItem getVideo(Item item, String video) { - if (this.playLists.contains(item.getId())) { - for (YoutubeItem v : this.playLists.get(item.getId())) { - if (v.video.equalsIgnoreCase(video)) { - return v; + private YoutubePlaylist getPlaylistDataById(String playlistId) { + try { + URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId); + + HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection(); + conn.setRequestProperty("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"); + conn.setRequestProperty("accept-language", "en-GB,en-US;q=0.9,en;q=0.8"); + conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3731.0 Safari/537.36"); + + InputStream is = conn.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + + YoutubePlaylist playlist = null; + + String inputLine; + while ((inputLine = br.readLine()) != null) { + if (inputLine.contains("window[\"ytInitialData\"]")) { + JsonObject obj = new JsonParser().parse(inputLine.substring(inputLine.indexOf("{")).replace(";", "")).getAsJsonObject(); + + JsonObject meta = obj.get("microformat").getAsJsonObject().get("microformatDataRenderer").getAsJsonObject(); + String name = meta.get("title").getAsString(); + String description = meta.get("description").getAsString(); + + ArrayList videos = new ArrayList<>(); + + JsonArray rawVideos = obj.get("contents").getAsJsonObject().get("twoColumnBrowseResultsRenderer").getAsJsonObject().get("tabs").getAsJsonArray().get(0).getAsJsonObject().get("tabRenderer").getAsJsonObject().get("content").getAsJsonObject().get("sectionListRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("itemSectionRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("playlistVideoListRenderer").getAsJsonObject().get("contents").getAsJsonArray(); + + for (JsonElement rawVideo : rawVideos) { + JsonObject videoData = rawVideo.getAsJsonObject().get("playlistVideoRenderer").getAsJsonObject(); + if (!videoData.has("lengthSeconds")) continue; // removed videos + videos.add(new YoutubeVideo(videoData.get("videoId").getAsString(), Integer.valueOf(videoData.get("lengthSeconds").getAsString()))); + } + + playlist = new YoutubePlaylist(playlistId, name, description, videos); + + break; } } + + br.close(); + + return playlist; + } catch (java.io.IOException e) { + e.printStackTrace(); } return null; } - public String getPreviewImage(Item item) { - if (this.playLists.contains(item.getId())) { - if (!this.playLists.get(item.getId()).isEmpty()) { - return this.playLists.get(item.getId()).get(0).video; - } - } - - return ""; - } - - public YoutubeItem getVideo(Item item, int index) { - if (this.playLists.containsKey(item.getId())) { - return this.playLists.get(item.getId()).get(index); - } - - return null; - } - - public class YoutubeItem { - public final int id; - public final String video; - public final String title; - public final String description; - public final int startTime; - public final int endTime; - - public YoutubeItem(ResultSet set) throws SQLException { - this.id = set.getInt("id"); - this.video = set.getString("video"); - this.title = set.getString("title"); - this.description = set.getString("description"); - this.startTime = set.getInt("start_time"); - this.endTime = set.getInt("end_time"); - } + public ArrayList getPlaylistsForItemId(int itemId) { + return this.playlists.get(itemId); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java index 438025a0..47bbbb10 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java @@ -1,16 +1,27 @@ 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.YoutubeManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.concurrent.ScheduledFuture; public class InteractionYoutubeTV extends HabboItem { + public YoutubeManager.YoutubePlaylist currentPlaylist = null; + public YoutubeManager.YoutubeVideo currentVideo = null; + public int startedWatchingAt = 0; + public int offset = 0; + public boolean playing = true; + public ScheduledFuture autoAdvance = null; + public InteractionYoutubeTV(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -42,8 +53,44 @@ public class InteractionYoutubeTV extends HabboItem { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(1); serverMessage.appendString("THUMBNAIL_URL"); - serverMessage.appendString(Emulator.getConfig().getValue("imager.url.youtube").replace("%video%", Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPreviewImage(this.getBaseItem()))); + if (this.currentVideo == null) { + serverMessage.appendString(""); + } else { + serverMessage.appendString(Emulator.getConfig().getValue("imager.url.youtube").replace("%video%", this.currentVideo.getId())); + } super.serializeExtradata(serverMessage); } + + @Override + public void onPickUp(Room room) { + super.onPickUp(room); + + if (this.autoAdvance != null) { + this.cancelAdvancement(); + } + + this.currentVideo = null; + this.currentPlaylist = null; + this.startedWatchingAt = 0; + this.offset = 0; + } + + public void cancelAdvancement() { + if (this.autoAdvance == null) return; + + this.autoAdvance.cancel(true); + this.autoAdvance = null; + } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + super.onClick(client, room, objects); + + if (this.currentVideo != null) { + int startTime = this.offset; + if (this.playing) startTime += Emulator.getIntUnixTimestamp() - this.startedWatchingAt; + client.sendResponse(new YoutubeVideoComposer(this.getId(), this.currentVideo, this.playing, startTime)); + } + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index f92cd743..c49fe1b3 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -52,9 +52,9 @@ import com.eu.habbo.messages.incoming.rooms.items.jukebox.*; import com.eu.habbo.messages.incoming.rooms.items.lovelock.LoveLockStartConfirmEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentSpaceCancelEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentSpaceEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestNextVideoEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlayListEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestVideoDataEvent; +import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestStateChange; +import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlaylists; +import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlaylistChange; import com.eu.habbo.messages.incoming.rooms.pets.*; import com.eu.habbo.messages.incoming.rooms.promotions.BuyRoomPromotionEvent; import com.eu.habbo.messages.incoming.rooms.promotions.RequestPromotionRoomsEvent; @@ -424,9 +424,9 @@ public class PacketManager { this.registerHandler(Incoming.RoomUserBanEvent, RoomUserBanEvent.class); this.registerHandler(Incoming.UnbanRoomUserEvent, UnbanRoomUserEvent.class); this.registerHandler(Incoming.RequestRoomUserTagsEvent, RequestRoomUserTagsEvent.class); - this.registerHandler(Incoming.YoutubeRequestPlayListEvent, YoutubeRequestPlayListEvent.class); - this.registerHandler(Incoming.YoutubeRequestNextVideoEvent, YoutubeRequestNextVideoEvent.class); - this.registerHandler(Incoming.YoutubeRequestVideoDataEvent, YoutubeRequestVideoDataEvent.class); + this.registerHandler(Incoming.YoutubeRequestPlaylists, YoutubeRequestPlaylists.class); + this.registerHandler(Incoming.YoutubeRequestStateChange, YoutubeRequestStateChange.class); + this.registerHandler(Incoming.YoutubeRequestPlaylistChange, YoutubeRequestPlaylistChange.class); this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class); this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class); this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class); diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index ba2e48b7..ee4ed6d5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -305,9 +305,9 @@ public class Incoming { public static final int RoomFavoriteEvent = 3817; public static final int RoomUnFavoriteEvent = 309; - public static final int YoutubeRequestPlayListEvent = 336; - public static final int YoutubeRequestNextVideoEvent = 3005; - public static final int YoutubeRequestVideoDataEvent = 2069; + public static final int YoutubeRequestPlaylists = 336; + public static final int YoutubeRequestStateChange = 3005; + public static final int YoutubeRequestPlaylistChange = 2069; public static final int EditRoomPromotionMessageEvent = 3707; public static final int HotelViewRequestBadgeRewardEvent = 2318; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java deleted file mode 100644 index 3a3d505a..00000000 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestNextVideoEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.eu.habbo.messages.incoming.rooms.items.youtube; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.YoutubeManager; -import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; - -public class YoutubeRequestNextVideoEvent extends MessageHandler { - @Override - public void handle() throws Exception { - int itemId = this.packet.readInt(); - int next = this.packet.readInt(); - - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - - if (item instanceof InteractionYoutubeTV) { - YoutubeManager.YoutubeItem video = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getVideo(item.getBaseItem(), next); - - if (video != null) { - this.client.sendResponse(new YoutubeVideoComposer(itemId, video)); - } - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylistChange.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylistChange.java new file mode 100644 index 00000000..3a367dfe --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylistChange.java @@ -0,0 +1,55 @@ +package com.eu.habbo.messages.incoming.rooms.items.youtube; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.YoutubeManager; +import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; +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.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; +import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; + +import java.util.Optional; + +public class YoutubeRequestPlaylistChange extends MessageHandler { + @Override + public void handle() throws Exception { + int itemId = this.packet.readInt(); + String playlistId = this.packet.readString(); + + Habbo habbo = this.client.getHabbo(); + + if (habbo == null) return; + + + Room room = habbo.getHabboInfo().getCurrentRoom(); + + if (room == null) return; + if (!room.isOwner(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) return; + + + HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + + if (item == null || !(item instanceof InteractionYoutubeTV)) return; + + Optional playlist = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()).stream().filter(p -> p.getId().equals(playlistId)).findAny(); + + if (playlist.isPresent()) { + YoutubeManager.YoutubeVideo video = playlist.get().getVideos().get(0); + if (video == null) return; + + ((InteractionYoutubeTV) item).currentVideo = video; + ((InteractionYoutubeTV) item).currentPlaylist = playlist.get(); + + ((InteractionYoutubeTV) item).cancelAdvancement(); + + room.updateItem(item); + room.sendComposer(new YoutubeVideoComposer(itemId, video, true, 0).compose()); + ((InteractionYoutubeTV) item).autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo((InteractionYoutubeTV) item), video.getDuration() * 1000); + + item.needsUpdate(true); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java similarity index 79% rename from src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java rename to src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java index d997a683..469861d0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayListComposer; -public class YoutubeRequestPlayListEvent extends MessageHandler { +public class YoutubeRequestPlaylists extends MessageHandler { @Override public void handle() throws Exception { int itemId = this.packet.readInt(); @@ -15,7 +15,9 @@ public class YoutubeRequestPlayListEvent extends MessageHandler { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); if (item instanceof InteractionYoutubeTV) { - this.client.sendResponse(new YoutubeDisplayListComposer(itemId, Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylist(item.getBaseItem()))); + InteractionYoutubeTV tv = (InteractionYoutubeTV) item; + + this.client.sendResponse(new YoutubeDisplayListComposer(itemId, Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()), tv.currentPlaylist)); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java new file mode 100644 index 00000000..c0f23ebf --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java @@ -0,0 +1,108 @@ +package com.eu.habbo.messages.incoming.rooms.items.youtube; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.YoutubeManager; +import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; +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.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeStateChangeComposer; +import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; +import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; + +public class YoutubeRequestStateChange extends MessageHandler { + public enum YoutubeState { + PREVIOUS(0), + NEXT(1), + PAUSE(2), + RESUME(3); + + private 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; + } + } + } + + @Override + public void handle() throws Exception { + int itemId = this.packet.readInt(); + YoutubeState state = YoutubeState.getByState(this.packet.readInt()); + + if (state == null) return; + + Habbo habbo = this.client.getHabbo(); + + if (habbo == null) return; + + + Room room = habbo.getHabboInfo().getCurrentRoom(); + + if (room == null) return; + if (!room.isOwner(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) return; + + + HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + + if (item == null || !(item instanceof InteractionYoutubeTV)) return; + + InteractionYoutubeTV tv = (InteractionYoutubeTV) item; + + switch (state) { + case PAUSE: + tv.playing = false; + tv.offset += Emulator.getIntUnixTimestamp() - tv.startedWatchingAt; + if (tv.autoAdvance != null) tv.autoAdvance.cancel(true); + room.sendComposer(new YoutubeStateChangeComposer(tv.getId(), 2).compose()); + break; + case RESUME: + tv.playing = true; + tv.startedWatchingAt = Emulator.getIntUnixTimestamp(); + tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), (tv.currentVideo.getDuration() - tv.offset) * 1000); + room.sendComposer(new YoutubeStateChangeComposer(tv.getId(), 1).compose()); + break; + 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: + 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) { + room.sendComposer(new YoutubeVideoComposer(tv.getId(), tv.currentVideo, true, 0).compose()); + + tv.cancelAdvancement(); + tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), tv.currentVideo.getDuration() * 1000); + tv.startedWatchingAt = Emulator.getIntUnixTimestamp(); + tv.offset = 0; + tv.playing = true; + room.updateItem(tv); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java deleted file mode 100644 index 0e1623c7..00000000 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestVideoDataEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.eu.habbo.messages.incoming.rooms.items.youtube; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.YoutubeManager; -import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeVideoComposer; - -public class YoutubeRequestVideoDataEvent extends MessageHandler { - @Override - public void handle() throws Exception { - int itemId = this.packet.readInt(); - String videoId = this.packet.readString(); - - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - - if (item instanceof InteractionYoutubeTV) { - YoutubeManager.YoutubeItem videoItem = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getVideo(item.getBaseItem(), videoId); - - if (videoItem != null) { - this.client.sendResponse(new YoutubeVideoComposer(itemId, videoItem)); - } - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java index ef92a8dd..9cab7508 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeDisplayListComposer.java @@ -8,27 +8,29 @@ import com.eu.habbo.messages.outgoing.Outgoing; import java.util.ArrayList; public class YoutubeDisplayListComposer extends MessageComposer { - public final int itemId; - public final ArrayList items; + private final int itemId; + private final ArrayList playlists; + private final YoutubeManager.YoutubePlaylist currentPlaylist; - public YoutubeDisplayListComposer(int itemId, ArrayList items) { + public YoutubeDisplayListComposer(int itemId, ArrayList playlists, YoutubeManager.YoutubePlaylist currentPlaylist) { this.itemId = itemId; - this.items = items; + this.playlists = playlists; + this.currentPlaylist = currentPlaylist; } @Override public ServerMessage compose() { this.response.init(Outgoing.YoutubeDisplayListComposer); this.response.appendInt(this.itemId); - this.response.appendInt(this.items.size()); + this.response.appendInt(this.playlists.size()); - for (YoutubeManager.YoutubeItem item : this.items) { - this.response.appendString(item.video); - this.response.appendString(item.title); - this.response.appendString(item.description); + for (YoutubeManager.YoutubePlaylist item : this.playlists) { + this.response.appendString(item.getId()); // playlist ID + this.response.appendString(item.getName()); // playlist title + this.response.appendString(item.getDescription()); // playlist description } - this.response.appendString(""); + this.response.appendString(this.currentPlaylist == null ? "" : this.currentPlaylist.getId()); // current playlist ID return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeStateChangeComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeStateChangeComposer.java new file mode 100644 index 00000000..1014715e --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeStateChangeComposer.java @@ -0,0 +1,24 @@ +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; + +public class YoutubeStateChangeComposer extends MessageComposer { + private final int furniId; + private final int state; + + public YoutubeStateChangeComposer(int furniId, int state) { + this.furniId = furniId; + this.state = state; + } + + @Override + public ServerMessage compose() { + this.response.init(Outgoing.YoutubeMessageComposer3); + this.response.appendInt(this.furniId); + this.response.appendInt(this.state); + + return this.response; + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java index be386b06..62a56781 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/youtube/YoutubeVideoComposer.java @@ -6,22 +6,26 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; public class YoutubeVideoComposer extends MessageComposer { - public final int itemId; - public final YoutubeManager.YoutubeItem item; + private final int itemId; + private final YoutubeManager.YoutubeVideo video; + private final boolean playing; + private final int startTime; - public YoutubeVideoComposer(int itemId, YoutubeManager.YoutubeItem item) { + public YoutubeVideoComposer(int itemId, YoutubeManager.YoutubeVideo video, boolean playing, int startTime) { this.itemId = itemId; - this.item = item; + this.video = video; + this.playing = playing; + this.startTime = startTime; } @Override public ServerMessage compose() { this.response.init(Outgoing.YoutubeMessageComposer2); this.response.appendInt(this.itemId); - this.response.appendString(this.item.video); - this.response.appendInt(this.item.startTime); - this.response.appendInt(this.item.endTime); - this.response.appendInt(0); + this.response.appendString(this.video.getId()); + this.response.appendInt(this.startTime); + this.response.appendInt(this.video.getDuration()); + this.response.appendInt(this.playing ? 1 : 2); return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java new file mode 100644 index 00000000..0a140643 --- /dev/null +++ b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java @@ -0,0 +1,33 @@ +package com.eu.habbo.threading.runnables; + +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.YoutubeVideoComposer; + +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; + + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.tv.getRoomId()); + + if (room == null) return; + + int nextIndex = tv.currentPlaylist.getVideos().indexOf(tv.currentVideo) + 1; + if (nextIndex >= tv.currentPlaylist.getVideos().size()) nextIndex = 0; + tv.currentVideo = tv.currentPlaylist.getVideos().get(nextIndex); + tv.startedWatchingAt = Emulator.getIntUnixTimestamp(); + tv.offset = 0; + room.updateItem(this.tv); + room.sendComposer(new YoutubeVideoComposer(tv.getId(), tv.currentVideo, true, 0).compose()); + + tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(this.tv), tv.currentVideo.getDuration() * 1000); + } +} From 8908e601d3cafb0cceeb57fe041c37931efc6ead Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 10 Jun 2019 19:06:22 +0300 Subject: [PATCH 092/112] Fix game teams --- .../games/battlebanzai/BattleBanzaiGame.java | 12 ++++++------ .../eu/habbo/habbohotel/games/freeze/FreezeGame.java | 2 +- .../habbohotel/games/freeze/FreezeGamePlayer.java | 2 +- .../battlebanzai/InteractionBattleBanzaiPuck.java | 2 +- .../wired/conditions/WiredConditionNotInTeam.java | 2 +- .../wired/conditions/WiredConditionTeamMember.java | 2 +- .../wired/effects/WiredEffectGiveScoreToTeam.java | 2 +- .../wired/effects/WiredEffectJoinTeam.java | 2 +- .../runnables/BattleBanzaiTilesFlicker.java | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) 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 a5b31e2b..3b390138 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 @@ -24,7 +24,7 @@ import java.util.concurrent.ThreadPoolExecutor; public class BattleBanzaiGame extends Game { - public static final int effectId = 33; + public static final int effectId = 32; public static final int POINTS_HIJACK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.steal", 0); @@ -136,7 +136,7 @@ public class BattleBanzaiGame extends Game { if (highestScore != null) { for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata((highestScore.teamColor.type + 3) + ""); + item.setExtradata((highestScore.teamColor.type + 2) + ""); this.room.updateItemState(item); } } @@ -179,7 +179,7 @@ public class BattleBanzaiGame extends Game { } for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata((7 + winningTeam.teamColor.type) + ""); + item.setExtradata((6 + winningTeam.teamColor.type) + ""); this.room.updateItemState(item); } @@ -263,7 +263,7 @@ public class BattleBanzaiGame extends Game { tileItem.ifPresent(habboItem -> { this.tileLocked(teamColor, habboItem, habbo, true); - habboItem.setExtradata((2 + (teamColor.type * 3) + 3) + ""); + habboItem.setExtradata((2 + (teamColor.type * 3)) + ""); this.room.updateItem(habboItem); }); } @@ -373,7 +373,7 @@ public class BattleBanzaiGame extends Game { if (!this.gameTiles.contains(tile.getId())) return; int check = state - (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3); - if (check == 3 || check == 4) { + if (check == 0 || check == 1) { state++; if (state % 3 == 2) { @@ -383,7 +383,7 @@ public class BattleBanzaiGame extends Game { habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_FILL_TILE); } } else { - state = (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3) + 3; + state = habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3; habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_HIJACK_TILE); } 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 8fc3f9c7..24b0a64c 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 @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; public class FreezeGame extends Game { - public static final int effectId = 40; + public static final int effectId = 39; public static int POWER_UP_POINTS; public static int POWER_UP_CHANCE; 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 4f7ea528..d425a612 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 @@ -195,7 +195,7 @@ public class FreezeGamePlayer extends GamePlayer { return 0; if (!this.isFrozen()) { - int effectId = 40; + int effectId = FreezeGame.effectId; effectId += super.getTeamColor().type; 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 ca9ecee2..d8ec242c 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 @@ -165,7 +165,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } } - this.setExtradata(team.teamColor.type + 1 + ""); + this.setExtradata(team.teamColor.type + ""); room.updateItemState(this); } } 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 73994362..1f97a4cc 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 @@ -75,7 +75,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { message.appendInt(this.getId()); message.appendString(""); message.appendInt(1); - message.appendInt(this.teamColor.type + 1); + message.appendInt(this.teamColor.type); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); 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 21abe9f3..0d29e6d0 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 @@ -75,7 +75,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { message.appendInt(this.getId()); message.appendString(""); message.appendInt(1); - message.appendInt(this.teamColor.type + 1); + message.appendInt(this.teamColor.type); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); 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 160e7eb1..2a094d98 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 @@ -107,7 +107,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { message.appendInt(3); message.appendInt(this.points); message.appendInt(this.count); - message.appendInt(this.teamColor.type + 1); + message.appendInt(this.teamColor.type); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(this.getDelay()); 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 bebaad81..f114baf6 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 @@ -90,7 +90,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { message.appendInt(this.getId()); message.appendString(""); message.appendInt(1); - message.appendInt(this.teamColor.type + 1); + message.appendInt(this.teamColor.type); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(this.getDelay()); 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 331cf787..345c45be 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -28,7 +28,7 @@ public class BattleBanzaiTilesFlicker implements Runnable { int state = 0; if (this.on) { - state = (this.color.type * 3) + 5; + state = (this.color.type * 3) + 2; this.on = false; } else { this.on = true; From 53e35096d80d86dd5f72a051f723e5fa48c22327 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 10 Jun 2019 19:36:33 +0300 Subject: [PATCH 093/112] Update wired data to be consistent with new teams --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 58 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index e65f64fc..8d2c7349 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -68,4 +68,60 @@ DROP PROCEDURE IF EXISTS DEFAULT_YTTV_PLAYLISTS; ALTER TABLE `permissions` ADD COLUMN `cmd_update_youtube_playlists` enum('0','1') NOT NULL DEFAULT '0'; INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_update_youtube_playlists', 'update_youtube;update_youtube_playlists') -INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_update_youtube_playlists', 'YouTube playlists have been refreshed!') \ No newline at end of file +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_update_youtube_playlists', 'YouTube playlists have been refreshed!'); + +DROP PROCEDURE IF EXISTS UPDATE_TEAM_WIREDS; +DELIMITER ;; + +CREATE PROCEDURE UPDATE_TEAM_WIREDS() +BEGIN + IF (SELECT COUNT(*) FROM emulator_settings WHERE `key` = 'team.wired.update.rc-1') = 0 THEN + INSERT INTO emulator_settings (`key`, `value`) VALUES ('team.wired.update.rc-1', 'DO NOT REMOVE THIS SETTING!'); + + UPDATE + items + INNER JOIN + items_base + ON + items.item_id = items_base.id + SET items.wired_data = CONCAT( + SUBSTRING_INDEX(items.wired_data, ';', 2), + ';', + CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(items.wired_data, ';', 3), ';', -1) AS SIGNED INTEGER) + 1, + ';', + SUBSTRING_INDEX(SUBSTRING_INDEX(items.wired_data, ';', 4), ';', -1) + ) + WHERE + items_base.interaction_type = 'wf_act_give_score_tm'; + + + UPDATE + items + INNER JOIN + items_base + ON + items.item_id = items_base.id + SET items.wired_data = CONCAT( + SUBSTRING_INDEX(items.wired_data, '\t', 1), + '\t', + CAST(SUBSTRING_INDEX(items.wired_data, '\t', -1) AS SIGNED INTEGER) + 1 + ) + WHERE + items_base.interaction_type = 'wf_act_join_team'; + + UPDATE + items + INNER JOIN + items_base + ON + items.item_id = items_base.id + SET items.wired_data = CAST(items.wired_data AS SIGNED INTEGER) + 1 + WHERE + items_base.interaction_type = 'wf_cnd_actor_in_team' OR items_base.interaction_type = 'wf_cnd_not_in_team'; + END IF; +END; +;; +DELIMITER ; + +CALL UPDATE_TEAM_WIREDS(); +DROP PROCEDURE IF EXISTS UPDATE_TEAM_WIREDS; From 6a2334ee896c9c80991c90da48316dd9f3b2bf5a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 11 Jun 2019 17:07:15 +0300 Subject: [PATCH 094/112] Fix NullPointerException in WiredConditionHabboIsDancing --- .../wired/conditions/WiredConditionHabboIsDancing.java | 2 +- .../wired/conditions/WiredConditionNotHabboIsDancing.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java index ac048fd9..0c706e6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java @@ -20,7 +20,7 @@ public class WiredConditionHabboIsDancing extends WiredConditionGroupMember { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return roomUnit.getDanceType() != DanceType.NONE; + return roomUnit != null && roomUnit.getDanceType() != DanceType.NONE; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java index 3a921e6a..81f1d7f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java @@ -20,7 +20,7 @@ public class WiredConditionNotHabboIsDancing extends WiredConditionGroupMember { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return roomUnit.getDanceType() == DanceType.NONE; + return roomUnit != null && roomUnit.getDanceType() == DanceType.NONE; } @Override From 7697765a5c153ea9c0a4a308e6c23ace5a0b4154 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 11 Jun 2019 17:08:36 +0300 Subject: [PATCH 095/112] Fix NullPointerException in Room.java --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e2960038..2cade797 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3633,7 +3633,7 @@ public class Room implements Comparable, ISerialize, Runnable { public RoomTile getRandomWalkableTile() { for (int i = 0; i < 10; i++) { RoomTile tile = this.layout.getTile((short) (Math.random() * this.layout.getMapSizeX()), (short) (Math.random() * this.layout.getMapSizeY())); - if (tile.isWalkable()) { + if (tile != null && tile.isWalkable()) { return tile; } } From 40888f091c2e69eb31a7414a117eefa83a241085 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 13 Jun 2019 17:17:20 +0300 Subject: [PATCH 096/112] Fix NullPointerException in Room.java --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 ++ 1 file changed, 2 insertions(+) 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 2cade797..92463f3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3994,6 +3994,8 @@ public class Room implements Comparable, ISerialize, Runnable { } if (item.getBaseItem().getType() == FurnitureType.FLOOR) { + if (this.layout == null) return; + this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } } From b6aeaa9f3740259e2cca8bd20945b49ec80f15f7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 13:46:27 +0300 Subject: [PATCH 097/112] Fix NullPointerException when creating a room bundle --- .../habbohotel/catalog/CatalogManager.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) 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 2658c248..a248256c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -589,24 +589,8 @@ public class CatalogManager { return this.catalogPages.get(pageId); } - public CatalogPage getCatalogPage(final String captionSafe) { - final CatalogPage[] page = {null}; - - synchronized (this.catalogPages) { - this.catalogPages.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogPage object) { - if (object.getPageName().equalsIgnoreCase(captionSafe)) { - page[0] = object; - return false; - } - - return true; - } - }); - - return page[0]; - } + public CatalogPage getCatalogPage(String captionSafe) { + return this.catalogPages.valueCollection().stream().filter(p -> p.getPageName().equalsIgnoreCase(captionSafe)).findAny().orElse(null); } From c2b72c067fada47bd8b4315ee01cc65ced98ad1a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 13:52:27 +0300 Subject: [PATCH 098/112] Disable posture overriding when on a water item --- .../com/eu/habbo/habbohotel/commands/LayCommand.java | 3 +++ src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 5 +++-- .../java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java index 4a186528..abc534bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/LayCommand.java @@ -14,6 +14,9 @@ public class LayCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getRoomUnit() == null || !gameClient.getHabbo().getRoomUnit().canForcePosture()) + return true; + gameClient.getHabbo().getRoomUnit().cmdLay = true; gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); gameClient.getHabbo().getRoomUnit().cmdSit = true; 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 92463f3b..5ca538ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3931,11 +3931,12 @@ public class Room implements Comparable, ISerialize, Runnable { } public void makeSit(Habbo habbo) { - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { + if (habbo.getRoomUnit() == null) return; + + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) || !habbo.getRoomUnit().canForcePosture()) { return; } - this.dance(habbo, DanceType.NONE); habbo.getRoomUnit().cmdSit = true; habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); 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 07809406..d1c6aa6c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; +import com.eu.habbo.habbohotel.items.interactions.InteractionWater; +import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; @@ -722,4 +724,12 @@ public class RoomUnit { public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) { this.canLeaveRoomByDoor = canLeaveRoomByDoor; } + + public boolean canForcePosture() { + if (this.room == null) return false; + + HabboItem topItem = this.room.getTopItemAt(this.getX(), this.getY()); + + return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); + } } From 240dedf2e7dd13eec44048153d2f83a1a929b5e5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 14:06:04 +0300 Subject: [PATCH 099/112] Fix NullPointerException --- .../java/com/eu/habbo/habbohotel/catalog/CatalogManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 a248256c..99296bb2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -590,7 +590,9 @@ public class CatalogManager { } public CatalogPage getCatalogPage(String captionSafe) { - return this.catalogPages.valueCollection().stream().filter(p -> p.getPageName().equalsIgnoreCase(captionSafe)).findAny().orElse(null); + return this.catalogPages.valueCollection().stream() + .filter(p -> p != null && p.getPageName() != null && p.getPageName().equalsIgnoreCase(captionSafe)) + .findAny().orElse(null); } From 166a4cd77bbe11b22b25fe03a7a8a1e9178f9d2b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 14:09:19 +0300 Subject: [PATCH 100/112] Fix team wireds --- .../interactions/wired/conditions/WiredConditionNotInTeam.java | 2 +- .../interactions/wired/conditions/WiredConditionTeamMember.java | 2 +- .../items/interactions/wired/effects/WiredEffectJoinTeam.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 1f97a4cc..8258e6fa 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 @@ -86,7 +86,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { public boolean saveData(ClientMessage packet) { packet.readInt(); - this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; + this.teamColor = GameTeamColors.values()[packet.readInt()]; return true; } 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 0d29e6d0..9349cbb2 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 @@ -86,7 +86,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { public boolean saveData(ClientMessage packet) { packet.readInt(); - this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; + this.teamColor = GameTeamColors.values()[packet.readInt()]; return true; } 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 f114baf6..3285865a 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 @@ -118,7 +118,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { @Override public boolean saveData(ClientMessage packet, GameClient gameClient) { packet.readInt(); - this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; + this.teamColor = GameTeamColors.values()[packet.readInt()]; int unknownInt = packet.readInt(); packet.readString(); this.setDelay(packet.readInt()); From 86ef27f742419e8e85fbbbd58c4cef3953c40218 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 14:44:20 +0300 Subject: [PATCH 101/112] Add add youtube playlist command and fix update command --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 2 +- sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql | 8 +++ .../commands/AddYoutubePlaylistCommand.java | 59 +++++++++++++++++++ .../habbohotel/commands/CommandHandler.java | 2 + .../habbohotel/items/YoutubeManager.java | 14 +++-- 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index 8d2c7349..be6dc99c 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -67,7 +67,7 @@ DROP PROCEDURE IF EXISTS DEFAULT_YTTV_PLAYLISTS; ALTER TABLE `permissions` ADD COLUMN `cmd_update_youtube_playlists` enum('0','1') NOT NULL DEFAULT '0'; -INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_update_youtube_playlists', 'update_youtube;update_youtube_playlists') +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_update_youtube_playlists', 'update_youtube;update_youtube_playlists'); INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_update_youtube_playlists', 'YouTube playlists have been refreshed!'); DROP PROCEDURE IF EXISTS UPDATE_TEAM_WIREDS; diff --git a/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql b/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql new file mode 100644 index 00000000..c3781754 --- /dev/null +++ b/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql @@ -0,0 +1,8 @@ +ALTER TABLE `permissions` +ADD COLUMN `cmd_add_youtube_playlist` enum('0','1') NOT NULL DEFAULT '0'; + +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_add_youtube_playlist', 'add_youtube;add_playlist;add_youtube_playlist'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.usage', 'Usage: base_item_id youtube_playlist_id'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.no_base_item', 'A base item with that ID could not be found.'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.failed_playlist', 'Error: unable to fetch the given YouTube playlist.'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_add_youtube_playlist', 'The playlist has been added successfully!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java new file mode 100644 index 00000000..5318102b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -0,0 +1,59 @@ +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 java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class AddYoutubePlaylistCommand extends Command { + public AddYoutubePlaylistCommand() { + super("cmd_add_youtube_playlist", Emulator.getTexts().getValue("commands.keys.cmd_add_youtube_playlist").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (params.length < 3) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.usage")); + return true; + } + + int itemId; + + try { + itemId = Integer.valueOf(params[1]); + } catch (NumberFormatException e) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item")); + return true; + } + + if (Emulator.getGameEnvironment().getItemManager().getItem(itemId) == null) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item")); + return true; + } + + YoutubeManager.YoutubePlaylist playlist = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistDataById(params[2]); + + if (playlist == null) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.failed_playlist")); + return true; + } + + Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.valueOf(params[1]), playlist); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `youtube_playlists` (`item_id`, `playlist_id`) VALUES (?, ?)")) { + statement.setInt(1, itemId); + statement.setString(2, params[2]); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist")); + + return true; + } +} 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 1ba4be67..d51eb126 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -276,6 +276,8 @@ public class CommandHandler { addCommand(new UpdateWordFilterCommand()); addCommand(new UserInfoCommand()); addCommand(new WordQuizCommand()); + addCommand(new UpdateYoutubePlaylistsCommand()); + addCommand(new AddYoutubePlaylistCommand()); addCommand(new TestCommand()); } 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 7e6ece37..631f15d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -90,11 +90,9 @@ public class YoutubeManager { youtubeDataLoaderPool.submit(() -> { ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); - YoutubePlaylist playlist = this.playlistCache.containsKey(playlistId) ? this.playlistCache.get(playlistId) : this.getPlaylistDataById(playlistId); + YoutubePlaylist playlist = this.getPlaylistDataById(playlistId); if (playlist != null) { playlists.add(playlist); - - this.playlistCache.put(playlistId, playlist); } else { Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); } @@ -117,7 +115,9 @@ public class YoutubeManager { Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } - private YoutubePlaylist getPlaylistDataById(String playlistId) { + public YoutubePlaylist getPlaylistDataById(String playlistId) { + if (this.playlistCache.containsKey(playlistId)) return this.playlistCache.get(playlistId); + try { URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId); @@ -159,6 +159,8 @@ public class YoutubeManager { br.close(); + this.playlistCache.put(playlistId, playlist); + return playlist; } catch (java.io.IOException e) { e.printStackTrace(); @@ -170,4 +172,8 @@ public class YoutubeManager { public ArrayList getPlaylistsForItemId(int itemId) { return this.playlists.get(itemId); } + + public void addPlaylistToItem(int itemId, YoutubePlaylist playlist) { + this.playlists.computeIfAbsent(itemId, k -> new ArrayList<>()).add(playlist); + } } \ No newline at end of file From 4c17a9a6f4bd1d779216c77154444e3059e3d9d4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 17:12:59 +0300 Subject: [PATCH 102/112] Fix reward wired message messing up subsequent chats --- sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql b/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql index c3781754..0890d959 100644 --- a/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql +++ b/sqlupdates/2_1_0-RC-1_TO_2_1_0-RC-2.sql @@ -5,4 +5,6 @@ INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_add_yout INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.usage', 'Usage: base_item_id youtube_playlist_id'); INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.no_base_item', 'A base item with that ID could not be found.'); INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_add_youtube_playlist.failed_playlist', 'Error: unable to fetch the given YouTube playlist.'); -INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_add_youtube_playlist', 'The playlist has been added successfully!'); \ No newline at end of file +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_add_youtube_playlist', 'The playlist has been added successfully!'); + +UPDATE `emulator_texts` SET `value` = 'Superwired Usage Information. Possible reward types:
badge: BADGE CODE
Credits: credits#amount
Pixels: pixels#amount
Points: points#amount
Respect: respect#amount
Furniture: furni#FurnitureID
Catalog Item: cata#CatalogItemID' WHERE `key` = 'hotel.wired.superwired.info'; \ No newline at end of file From c7b83fbc9d02977651e8a7aacc52085cd04a0e98 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sun, 16 Jun 2019 15:14:46 +0100 Subject: [PATCH 103/112] Fixed the config option for public rooms. --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 28d28c37..0d8e5da1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -988,9 +988,7 @@ public class RoomManager { for (Room room : this.activeRooms.values()) { if (room.getUserCount() > 0) { - if (!RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB && room.isPublicRoom()) continue; - - rooms.add(room); + if (!room.isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB) rooms.add(room); } } From 7ec6c20c5d67b83e1629fe4ec686935ee4597df4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 17:23:46 +0300 Subject: [PATCH 104/112] Fix gift buying --- .../incoming/catalog/CatalogBuyItemAsGiftEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index c3e375e5..5703549d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.catalog.CatalogPage; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; +import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboItem; @@ -258,6 +259,11 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { return; } else { if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) { + if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) { + ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData)); + extraData = "UMAD"; + } + extraData = this.client.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 + extraData; } From e06814b25969ee89b4a44202b3d67c617f4a7e37 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 16 Jun 2019 17:31:50 +0300 Subject: [PATCH 105/112] Fix room moderation achievements --- src/main/java/com/eu/habbo/Emulator.java | 2 +- .../eu/habbo/habbohotel/commands/TestCommand.java | 1 - .../items/interactions/InteractionWater.java | 11 ++++++++++- .../java/com/eu/habbo/habbohotel/rooms/Room.java | 4 +++- .../incoming/rooms/RequestRoomSettingsEvent.java | 7 ------- .../incoming/users/UserActivityEvent.java | 15 +++++++++++++++ 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 506b10c4..501ebab4 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -149,7 +149,7 @@ public final class Emulator { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - while (!isShuttingDown && isReady) { + while (!isShuttingDown && isReady && reader.ready()) { try { String line = reader.readLine(); 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 16e15769..0a1ae289 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java @@ -53,7 +53,6 @@ public class TestCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - if (true) return true; if (params[1].equalsIgnoreCase("ut")) { RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); 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 a7df3c6d..9af96347 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 @@ -152,7 +152,7 @@ public class InteractionWater extends InteractionDefault { if(pet == null) return; - if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM)) { + if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) { pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, ""); } } @@ -213,4 +213,13 @@ public class InteractionWater extends InteractionDefault { return super.canStackAt(room, itemsAtLocation); } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + if (!super.canWalkOn(roomUnit, room, objects)) return false; + + Pet pet = room.getPet(roomUnit); + + return pet == null || pet.getPetData().canSwim; + } } 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 5ca538ea..246d9372 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -558,7 +558,9 @@ public class Room implements Comparable, ISerialize, Runnable { RoomTileState result = RoomTileState.OPEN; HabboItem lowestItem = null; HabboItem lowestChair = this.getLowestChair(tile); - for (HabboItem item : this.getItemsAt(tile)) { + THashSet items = this.getItemsAt(tile); + if (items == null) return RoomTileState.INVALID; + for (HabboItem item : items) { if (exclude != null && item == exclude) continue; if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java index 5a9ad183..e025d33f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomSettingsEvent.java @@ -15,12 +15,5 @@ public class RequestRoomSettingsEvent extends MessageHandler { if (room != null) this.client.sendResponse(new RoomSettingsComposer(room)); - - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatFloodFilterSeen")); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatHearRangeSeen")); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModChatScrollSpeedSeen")); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModDoorModeSeen")); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModWalkthroughSeen")); - } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java index 42f5c746..4afb28fe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserActivityEvent.java @@ -31,6 +31,21 @@ public class UserActivityEvent extends MessageHandler { 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; } } } \ No newline at end of file From 236c4adc0a07bac191ca9f244ff571f140bcb49d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Jun 2019 23:08:29 +0300 Subject: [PATCH 106/112] Refactor test command --- .../habbohotel/commands/TestCommand.java | 435 +----------------- 1 file changed, 20 insertions(+), 415 deletions(-) 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 0a1ae289..9caaa41d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java @@ -1,441 +1,46 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.pets.MonsterplantPet; -import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetManager; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomTile; -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.incoming.Incoming; -import com.eu.habbo.messages.incoming.gamecenter.GameCenterRequestAccountStatusEvent; -import com.eu.habbo.messages.incoming.gamecenter.GameCenterRequestGamesEvent; -import com.eu.habbo.messages.incoming.rooms.pets.MovePetEvent; -import com.eu.habbo.messages.outgoing.MessageComposer; -import com.eu.habbo.messages.outgoing.Outgoing; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; -import com.eu.habbo.messages.outgoing.rooms.RoomQueueStatusMessage; -import com.eu.habbo.messages.outgoing.rooms.pets.PetInformationComposer; -import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; -import com.eu.habbo.messages.outgoing.users.UserDataComposer; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import gnu.trove.procedure.TObjectProcedure; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.text.Normalizer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; public class TestCommand extends Command { - public static boolean stopThreads = true; - public TestCommand() { super("acc_debug", new String[]{"test"}); } @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - if (params[1].equalsIgnoreCase("ut")) { - RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); - return true; - } + if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasPermission("acc_supporttool") || !Emulator.debugging) + return false; - if (params[1].equalsIgnoreCase("clients")) { - System.out.println(Emulator.getGameServer().getGameClientManager().getSessions().size()); - } + int header = Integer.valueOf(params[1]); - if (params[1].equalsIgnoreCase("queue")) { - gameClient.sendResponse(new RoomQueueStatusMessage()); - return true; - } - if (params[1].equalsIgnoreCase("public")) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPublicRoom(true); - return true; - } + ServerMessage message = new ServerMessage(header); - if (params[1].equalsIgnoreCase("randtel")) { - RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getRandomWalkableTile(); - gameClient.getHabbo().getRoomUnit().setCurrentLocation(tile); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserStatusComposer(gameClient.getHabbo().getRoomUnit()).compose()); - return true; - } + for (int i = 1; i < params.length; i++) { + String[] data = params[i].split(":"); - if (params[1].equals("ach")) { - AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Jogger"), 1000); - return true; - } - - if (params[1].equals("asddsa")) { - gameClient.getHabbo().getHabboStats().addAchievementScore(1000); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(gameClient.getHabbo()).compose()); - return true; - } - - if (params[1].equals("gc")) { - - Emulator.getGameServer().getPacketManager().registerHandler(Incoming.GameCenterRequestGamesEvent, GameCenterRequestGamesEvent.class); - Emulator.getGameServer().getPacketManager().registerHandler(Incoming.GameCenterRequestAccountStatusEvent, GameCenterRequestAccountStatusEvent.class); - return true; - } - - if (params[1].equals("namechange")) { - gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo())); - return true; - } - //Emulator.getGameEnvironment().getRoomManager().clearInactiveRooms(); - //gameClient.sendResponse(new RoomDataComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false)); - - if (params[1].equals("uach")) { - Emulator.getGameEnvironment().getAchievementManager().reload(); - } - - if (params[1].equals("units")) { - StringBuilder s = new StringBuilder(); - - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { - s.append("Habbo ID: ").append(habbo.getHabboInfo().getId()).append(", RoomUnit ID: ").append(habbo.getRoomUnit().getId()).append("\r"); - } - - for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) { - s.append("Pet ID: ").append(pet.getId()).append(", RoomUnit ID: ").append(pet.getRoomUnit().getId()).append(", Name: ").append(pet.getName()); - - if (pet instanceof MonsterplantPet) { - s.append(", B:").append(((MonsterplantPet) pet).canBreed() ? "Y" : "N").append(", PB: ").append(((MonsterplantPet) pet).isPubliclyBreedable() ? "Y" : "N").append(", D: ").append(((MonsterplantPet) pet).isDead() ? "Y" : "N"); + if (data[0].equalsIgnoreCase("b")) { + message.appendBoolean(data[1].equalsIgnoreCase("1")); + } else if (data[0].equalsIgnoreCase("s")) { + if (data.length > 1) { + message.appendString(data[1]); + } else { + message.appendString(""); } - - s.append("\r"); - } - - gameClient.sendResponse(new MessagesForYouComposer(new String[]{s.toString()})); - return true; - } - - if (params[1].equalsIgnoreCase("rebr")) { - for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) { - if (pet instanceof MonsterplantPet) { - ((MonsterplantPet) pet).setPubliclyBreedable(false); - ((MonsterplantPet) pet).setCanBreed(true); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetInformationComposer(pet, gameClient.getHabbo().getHabboInfo().getCurrentRoom(), gameClient.getHabbo()).compose()); - } - } - - return true; - } - - if (params[1].equalsIgnoreCase("bots")) { - StringBuilder message = new StringBuilder(); - - for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) { - message.append("Name: ").append(bot.getName()).append(", ID: ").append(bot.getId()).append(", RID: ").append(bot.getRoomUnit().getId()).append(", Rot: ").append(bot.getRoomUnit().getBodyRotation()).append("\r"); - } - - gameClient.sendResponse(new MessagesForYouComposer(new String[]{message.toString()})); - return true; - } - - if (params[1].equalsIgnoreCase("packu")) { - Emulator.getGameServer().getPacketManager().registerHandler(Incoming.MovePetEvent, MovePetEvent.class); - return true; - } - - if (params[1].equals("a")) { - int count = Integer.valueOf(params[2]); - - for (int i = 0; i < count; i++) { - gameClient.getHabbo().whisper("" + i, RoomChatMessageBubbles.getBubble(i)); - } - - return true; - } else if (params[1].equals("b")) { - try { - int itemId = Integer.valueOf(params[2]); - - HabboItem item = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - - if (item != null) { - item.setExtradata(params[3]); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); - } - } catch (Exception e) { - - } - return true; - } else if (params[1].equalsIgnoreCase("pet")) { - Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2])); - - if (pet != null) { - String a; - String b = ""; - String c = ""; - if (params[3] != null) { - a = params[3]; - if (params.length > 4) { - b = params[4]; - } - if (params.length > 5) { - c = params[5]; - } - pet.getRoomUnit().setStatus(RoomUnitStatus.fromString(a), b + " " + c); - gameClient.sendResponse(new RoomUserStatusComposer(pet.getRoomUnit())); - } - } - } else if (params[1].equalsIgnoreCase("petc")) { - Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2])); - - if (pet != null) { - pet.getRoomUnit().clearStatus(); - gameClient.sendResponse(new RoomUserStatusComposer(pet.getRoomUnit())); - } - } else if (params[1].equalsIgnoreCase("rand")) { - Map results = new HashMap<>(); - - for (int i = 0; i < Integer.valueOf(params[2]); i++) { - int random = PetManager.random(0, 12, Double.valueOf(params[3])); - - if (!results.containsKey(random)) { - results.put(random, 0); - } - - results.put(random, results.get(random) + 1); - } - - StringBuilder result = new StringBuilder("Results : " + params[2] + "

"); - - for (Map.Entry set : results.entrySet()) { - result.append(set.getKey()).append(" -> ").append(set.getValue()).append("
"); - } - - gameClient.sendResponse(new GenericAlertComposer(result.toString())); - } else if (params[1].equalsIgnoreCase("threads")) { - if (stopThreads) { - stopThreads = false; - for (int i = 0; i < 30; i++) { - final int finalI = i; - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(500); - Emulator.getLogging().logStart("Started " + finalI + " on " + Thread.currentThread().getName()); - if (!TestCommand.stopThreads) { - Emulator.getThreading().run(this); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }, i * 10); - } - } else { - stopThreads = true; - } - } else if (params[1].equalsIgnoreCase("pethere")) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - List tiles = room.getLayout().getTilesAround(gameClient.getHabbo().getRoomUnit().getCurrentLocation()); - - room.getCurrentPets().forEachValue(new TObjectProcedure() { - @Override - public boolean execute(Pet object) { - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - object.getRoomUnit().setGoalLocation(tiles.get(Emulator.getRandom().nextInt(tiles.size()))); - } - }); - return true; - } - }); - } else if (params[1].equalsIgnoreCase("st")) { - gameClient.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.fromString(params[2]), params[3]); - gameClient.sendResponse(new RoomUserStatusComposer(gameClient.getHabbo().getRoomUnit())); - } else if (params[1].equalsIgnoreCase("filt")) { - gameClient.sendResponse(new GenericAlertComposer(Normalizer.normalize(params[2], Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").replaceAll("\\p{M}", ""))); - } else if (params[1].equalsIgnoreCase("nux")) { - gameClient.sendResponse(new MessageComposer() { - @Override - public ServerMessage compose() { - this.response.init(Outgoing.NewUserGiftComposer); - - this.response.appendInt(1); //? - this.response.appendInt(1); - this.response.appendInt(2); - this.response.appendInt(6); - - String[] gift1 = {"throne.png", "throne"}; //Emulator.getConfig().getValue("nux.gift.1").split(";"); - String[] gift2 = {"throne.png", "throne"}; //Emulator.getConfig().getValue("nux.gift.2").split(";"); - String[] gift3 = {"throne.png", "throne"}; //Emulator.getConfig().getValue("nux.gift.3").split(";"); - - this.response.appendString(gift1[0]); - this.response.appendInt(2); - this.response.appendString(gift1[1]); - this.response.appendString(""); - this.response.appendString("typewriter"); - this.response.appendString(""); - - this.response.appendString(gift2[0]); - this.response.appendInt(1); - this.response.appendString(gift2[1]); - this.response.appendString(""); - - this.response.appendString(gift3[0]); - this.response.appendInt(1); - this.response.appendString(gift3[1]); - this.response.appendString(""); - - this.response.appendString(gift1[0]); - this.response.appendInt(2); - this.response.appendString(gift1[1]); - this.response.appendString(""); - this.response.appendString("typewriter"); - this.response.appendString(""); - - this.response.appendString(gift2[0]); - this.response.appendInt(1); - this.response.appendString(gift2[1]); - this.response.appendString(""); - - this.response.appendString(gift3[0]); - this.response.appendInt(1); - this.response.appendString(gift3[1]); - this.response.appendString(""); - - return this.response; - } - }); - } else if (params[1].equals("adv")) { - } else if (params[1].equals("datb")) { - long millis; - long diff = 1; - try (Connection conn = Emulator.getDatabase().getDataSource().getConnection()) { - millis = System.currentTimeMillis(); - for (long i = 0; i < 1000000; i++) { - try (PreparedStatement stmt = conn.prepareStatement("SELECT 1")) { - //PreparedStatement stmt2 = conn.prepareStatement("SELECT 2"); - stmt.close(); - } - //stmt2.close(); - } - diff = System.currentTimeMillis() - millis; - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("Difference " + (diff) + "MS. ops: " + ((long) 1000000 / diff) + " ops/MS"); - - } else { - try { - int header = Integer.valueOf(params[1]); - - ServerMessage message = new ServerMessage(header); - - for (int i = 1; i < params.length; i++) { - String[] data = params[i].split(":"); - - if (data[0].equalsIgnoreCase("b")) { - message.appendBoolean(data[1].equalsIgnoreCase("1")); - } else if (data[0].equalsIgnoreCase("s")) { - if (data.length > 1) { - message.appendString(data[1].replace("%http%", "http://")); - } else { - message.appendString(""); - } - } else if (data[0].equals("i")) { - message.appendInt(Integer.valueOf(data[1])); - } else if (data[0].equalsIgnoreCase("by")) { - message.appendByte(Integer.valueOf(data[1])); - } else if (data[0].equalsIgnoreCase("sh")) { - message.appendShort(Integer.valueOf(data[1])); - } - } - - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo("Admin"); - - if (habbo != null) { - habbo.getClient().sendResponse(message); - } - } catch (Exception e) { - gameClient.sendResponse(new GenericAlertComposer("Hey, what u doing m8.")); - - return false; + } else if (data[0].equals("i")) { + message.appendInt(Integer.valueOf(data[1])); + } else if (data[0].equalsIgnoreCase("by")) { + message.appendByte(Integer.valueOf(data[1])); + } else if (data[0].equalsIgnoreCase("sh")) { + message.appendShort(Integer.valueOf(data[1])); } } - - //if(params.length >= 2) - //{ - - //} - - - //} - - //int header = Integer.valueOf(params[1]); - - //2823 - //913 - //1604 - //gameClient.sendResponse(new SnowWarsCompose1(913)); - //gameClient.sendResponse(new SnowWarsStartLobbyCounter()); - //gameClient.sendResponse(new SnowWarsQuePositionComposer()); - //gameClient.sendResponse(new SnowWarsCompose1(1604)); - //gameClient.sendResponse(new SnowWarsLevelDataComposer()); - + gameClient.sendResponse(message); return true; } - - public void testConcurrentClose() throws Exception { - HikariConfig config = new HikariConfig(); - config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource"); - - try (HikariDataSource ds = new HikariDataSource(config); - final Connection connection = ds.getConnection()) { - - ExecutorService executorService = Executors.newFixedThreadPool(10); - - List> futures = new ArrayList<>(); - - for (int i = 0; i < 500; i++) { - final PreparedStatement preparedStatement = - connection.prepareStatement(""); - - futures.add(executorService.submit(new Callable() { - - @Override - public Void call() throws Exception { - preparedStatement.close(); - - return null; - } - - })); - } - - executorService.shutdown(); - - for (Future future : futures) { - future.get(); - } - } - } } From 634c2cbfc3ef3058e66e506dbcaa2b18fb1c0cbe Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Jun 2019 23:15:25 +0300 Subject: [PATCH 107/112] Add max length to PM messages --- .../messages/incoming/friends/FriendPrivateMessageEvent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java index 3a472fcb..6145e722 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendPrivateMessageEvent.java @@ -25,6 +25,8 @@ public class FriendPrivateMessageEvent extends MessageHandler { if (buddy == null) return; + if (message.length() > 255) message = message.substring(0, 255); + UserFriendChatEvent event = new UserFriendChatEvent(this.client.getHabbo(), buddy, message); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; From 18db0016438143d74d1a6069715fcfea5934713c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Jun 2019 23:20:25 +0300 Subject: [PATCH 108/112] Trim extra spaces from chat --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 ++ 1 file changed, 2 insertions(+) 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 246d9372..38555728 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3065,6 +3065,8 @@ public class Room implements Comparable, ISerialize, Runnable { Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); + roomChatMessage.setMessage(roomChatMessage.getMessage().trim()); + if (chatType == RoomChatType.WHISPER) { if (roomChatMessage.getTargetHabbo() == null) { return; From c8b4848f49463fcc3c20a9a1b8939df970ad7a5b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Jun 2019 23:33:43 +0300 Subject: [PATCH 109/112] Remove bot's effect after teleportation --- .../interactions/wired/effects/WiredEffectBotTeleport.java | 2 ++ 1 file changed, 2 insertions(+) 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 68a9feb6..a5662610 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 @@ -13,6 +13,7 @@ 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.RoomUnitTeleport; +import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -106,6 +107,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { int currentEffect = bot.getRoomUnit().getEffectId(); room.giveEffect(bot.getRoomUnit(), 4, -1); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, bot.getRoomUnit()), WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY); break; } else { From 1638dcb75853bad83dfb940b13810ac7afc0acb6 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sun, 30 Jun 2019 21:05:03 +0100 Subject: [PATCH 110/112] Fixed Pet Levelling. --- .../com/eu/habbo/habbohotel/pets/Pet.java | 26 +++++++++---------- .../eu/habbo/habbohotel/pets/PetManager.java | 3 ++- 2 files changed, 15 insertions(+), 14 deletions(-) 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 35275e72..29240ad9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -518,7 +518,7 @@ public class Pet implements ISerialize, Runnable { if (this.room != null) { this.room.sendComposer(new RoomPetExperienceComposer(this, amount).compose()); - if (this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) { + if(this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) { this.levelUp(); } } @@ -526,20 +526,20 @@ public class Pet implements ISerialize, Runnable { protected void levelUp() { - if (this.level >= PetManager.experiences.length) - return; + if (this.level >= PetManager.experiences.length + 1) + return; - if (this.experience < PetManager.experiences[this.level]) { - this.experience = PetManager.experiences[this.level]; + if (this.experience > PetManager.experiences[this.level - 1]) { + this.experience = PetManager.experiences[this.level - 1]; + } + this.level++; + this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); + this.addHappyness(100); + this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); + this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); + AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); + this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); } - this.level++; - this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); - this.addHappyness(100); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LVLUP.getKey()); - this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); - AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); - this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); - } public void addThirst(int amount) { 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 82301279..d4079923 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -83,7 +83,7 @@ public class PetManager { } public static int getLevel(int experience) { - int index = 0; + int index = -1; for (int i = 0; i < experiences.length; i++) { if (experiences[i] > experience) { @@ -92,6 +92,7 @@ public class PetManager { } } + if(index == -1) { index = experiences.length; } return index + 1; } From f77866146b52e49eb8c00b48c70bef1f7b7b9687 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 2 Jul 2019 18:33:47 +0100 Subject: [PATCH 111/112] Made Banzai Pucks work on all flooring, not just banzai tiles (LIKE HABBO) --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 1 - .../games/battlebanzai/InteractionBattleBanzaiPuck.java | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index be6dc99c..2b1215f1 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -25,7 +25,6 @@ UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 1 UPDATE `items_base` SET `customparams` = '30,60,120,180,300,600', `interaction_type` = 'game_timer', `interaction_modes_count` = 1 WHERE `item_name` IN ('fball_counter','bb_counter','es_counter'); ALTER TABLE `youtube_playlists` -DROP COLUMN `order`, CHANGE COLUMN `video_id` `playlist_id` varchar(255) NOT NULL COMMENT 'YouTube playlist ID' AFTER `item_id`; DROP TABLE `youtube_items`; 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 d8ec242c..1ff4c3c7 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 @@ -127,7 +127,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { if (room == null || from == null || to == null) return false; HabboItem topItem = room.getTopItemAt(to.x, to.y, this); - return topItem != null && topItem instanceof InteractionBattleBanzaiTile; + return topItem != null; //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); } @@ -156,15 +156,11 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { GameTeam team = game.getTeamForHabbo(habbo); if (team != null) { HabboItem item = room.getTopItemAt(to.x, to.y); - - if (item instanceof InteractionBattleBanzaiTile) { try { item.onWalkOn(kicker, room, null); } catch (Exception e) { return; } - } - this.setExtradata(team.teamColor.type + ""); room.updateItemState(this); } @@ -185,7 +181,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) { - HabboItem topItem = room.getTopItemAt(to.x, to.y); - return to.state == RoomTileState.OPEN && to.isWalkable() && topItem instanceof InteractionBattleBanzaiTile; + return to.state == RoomTileState.OPEN && to.isWalkable(); } } From 4cfcdb379e5f95877dc2a61485314fb06507561d Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 2 Jul 2019 18:37:22 +0100 Subject: [PATCH 112/112] Pushed Version 2.1.0 Stable, ready for release. --- src/main/java/com/eu/habbo/Emulator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 501ebab4..48a63e9f 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -40,7 +40,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-1"; + public final static String PREVIEW = "Stable"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -140,7 +140,7 @@ public final class Emulator { Emulator.getThreading().run(new Runnable() { @Override public void run() { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a Release Candidate for 2.1.0, if you find any bugs please place them on our git repository."); + Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a stable 2.1.0 build, it should be more than stable for daily use on hotels, if you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); System.out.println("Waiting for commands: ");