From a8bc9841f4b58cbb96e27c18d4320d9f47cac5d4 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Fri, 18 Dec 2020 01:51:56 +0000 Subject: [PATCH 01/80] Furniture Toggle Event --- .../incoming/rooms/items/ToggleFloorItemEvent.java | 9 +++++++++ .../incoming/rooms/items/ToggleWallItemEvent.java | 8 ++++++++ .../events/furniture/FurnitureToggleEvent.java | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java 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 5b665d79..50376ae8 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 @@ -11,6 +11,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent; +import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +37,12 @@ public class ToggleFloorItemEvent extends MessageHandler { if (item == null || item instanceof InteractionDice) return; + Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state); + Emulator.getPluginManager().fireEvent(furnitureToggleEvent); + + if (furnitureToggleEvent.isCancelled()) + return; + /* if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) { THashSet items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY())); 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 8700940c..d4020edf 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 @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; 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.plugin.Event; +import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; public class ToggleWallItemEvent extends MessageHandler { @Override @@ -21,6 +23,12 @@ public class ToggleWallItemEvent extends MessageHandler { if (item == null) return; + Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state); + Emulator.getPluginManager().fireEvent(furnitureToggleEvent); + + if (furnitureToggleEvent.isCancelled()) + return; + if (item.getBaseItem().getName().equalsIgnoreCase("poster")) return; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java new file mode 100644 index 00000000..01dd9c92 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java @@ -0,0 +1,14 @@ +package com.eu.habbo.plugin.events.furniture; + +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +public class FurnitureToggleEvent extends FurnitureUserEvent { + public int state; + + public FurnitureToggleEvent(HabboItem furniture, Habbo habbo, int state) { + super(furniture, habbo); + + this.state = state; + } +} From ed869c4ef9c75f41a0d59f00d8729136125f685e Mon Sep 17 00:00:00 2001 From: MartenM Date: Thu, 24 Dec 2020 17:25:53 +0100 Subject: [PATCH 02/80] Update 'respect' of pets to the database when scratched. --- .../habbo/messages/incoming/rooms/pets/ScratchPetEvent.java | 5 +++++ 1 file changed, 5 insertions(+) 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 4621c044..3da982a0 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 @@ -1,5 +1,6 @@ package com.eu.habbo.messages.incoming.rooms.pets; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; @@ -22,6 +23,10 @@ public class ScratchPetEvent extends MessageHandler { if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) { pet.scratched(this.client.getHabbo()); + + // Update the stats to the database. + pet.needsUpdate = true; + Emulator.getThreading().run(pet); } } } From 4092b87cb1ea78f71e4c4df368667b74ee73b952 Mon Sep 17 00:00:00 2001 From: MartenM Date: Thu, 24 Dec 2020 17:34:28 +0100 Subject: [PATCH 03/80] Moved the .needsUpdate inside for better encapsulation. --- src/main/java/com/eu/habbo/habbohotel/pets/Pet.java | 1 + .../eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java | 1 - 2 files 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 d5e13742..afd7e035 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -578,6 +578,7 @@ public class Pet implements ISerialize, Runnable { this.addHappyness(10); this.addExperience(10); this.addRespect(); + this.needsUpdate = true; if (habbo != null) { habbo.getHabboStats().petRespectPointsToGive--; 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 3da982a0..501b6901 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 @@ -25,7 +25,6 @@ public class ScratchPetEvent extends MessageHandler { pet.scratched(this.client.getHabbo()); // Update the stats to the database. - pet.needsUpdate = true; Emulator.getThreading().run(pet); } } From 3f07f3f546b93b81c1b464178ed19946159b7740 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sat, 26 Dec 2020 04:25:54 +0000 Subject: [PATCH 04/80] Fix achievement RoomEntry --- .../eu/habbo/habbohotel/rooms/RoomManager.java | 5 ++++- .../com/eu/habbo/habbohotel/users/HabboStats.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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 102ca77d..113736f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -672,7 +672,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null)); } - if (room.getOwnerId() != habbo.getHabboInfo().getId()) { + if (room.getOwnerId() != habbo.getHabboInfo().getId() && !habbo.getHabboStats().visitedRoom(room.getId())) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); } } @@ -916,6 +916,9 @@ public class RoomManager { statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp)); statement.execute(); + + if (!habbo.getHabboStats().visitedRoom(room.getId())) + habbo.getHabboStats().addVisitRoom(room.getId()); } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 603e9b9e..4463148f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -41,6 +41,7 @@ public class HabboStats implements Runnable { private final THashMap recentPurchases; private final TIntArrayList favoriteRooms; private final TIntArrayList ignoredUsers; + private TIntArrayList roomsVists; public int achievementScore; public int respectPointsReceived; public int respectPointsGiven; @@ -106,6 +107,7 @@ public class HabboStats implements Runnable { this.recentPurchases = new THashMap<>(0); this.favoriteRooms = new TIntArrayList(0); this.ignoredUsers = new TIntArrayList(0); + this.roomsVists = new TIntArrayList(0); this.secretRecipes = new TIntArrayList(0); this.calendarRewardsClaimed = new TIntArrayList(0); @@ -236,6 +238,15 @@ public class HabboStats implements Runnable { } } } + + try (PreparedStatement loadRoomsVisit = set.getStatement().getConnection().prepareStatement("SELECT DISTINCT room_id FROM room_enter_log WHERE user_id = ?")) { + loadRoomsVisit.setInt(1, this.habboInfo.getId()); + try (ResultSet roomSet = loadRoomsVisit.executeQuery()) { + while (roomSet.next()) { + this.roomsVists.add(roomSet.getInt("room_id")); + } + } + } } private static HabboStats createNewStats(HabboInfo habboInfo) { @@ -622,6 +633,10 @@ public class HabboStats implements Runnable { return this.favoriteRooms.contains(roomId); } + public boolean visitedRoom(int roomId) { return this.roomsVists.contains(roomId); } + + public void addVisitRoom(int roomId) { this.roomsVists.add(roomId); } + public TIntArrayList getFavoriteRooms() { return this.favoriteRooms; } From 02752eb72e1afe144e44ee7e4fc03d196b7a33a3 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 27 Dec 2020 13:00:08 -0500 Subject: [PATCH 05/80] Fix update favorite group (users) #746 #488 --- .../messages/incoming/guilds/GuildDeleteEvent.java | 13 +++++++++++++ .../incoming/guilds/GuildRemoveFavoriteEvent.java | 2 +- .../incoming/guilds/GuildRemoveMemberEvent.java | 8 ++++++-- .../guilds/GuildFavoriteRoomUserUpdateComposer.java | 6 +++--- 4 files changed, 23 insertions(+), 6 deletions(-) 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 03e9bd2a..739eabc9 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 @@ -2,11 +2,15 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; +import com.eu.habbo.habbohotel.guilds.GuildMember; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer; import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent; +import gnu.trove.set.hash.THashSet; public class GuildDeleteEvent extends MessageHandler { @Override @@ -18,6 +22,15 @@ public class GuildDeleteEvent extends MessageHandler { if (guild != null) { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override. { + THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); + + for (GuildMember member : members) { + Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(member.getUserId()); + if (habbo != null) + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) + habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose()); + } + 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()); 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 cd97c727..6f64afac 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 @@ -22,7 +22,7 @@ public class GuildRemoveFavoriteEvent extends MessageHandler { this.client.getHabbo().getHabboStats().guild = 0; if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), null).compose()); } this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client)); 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 7652c0da..7ee21067 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent; @@ -44,8 +45,11 @@ public class GuildRemoveMemberEvent extends MessageHandler { if (habbo.getHabboStats().guild == guildId) habbo.getHabboStats().guild = 0; - if (room != null && habbo.getHabboInfo().getCurrentRoom() == room) { - room.refreshRightsForHabbo(habbo); + if (room != null) { + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) + habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose()); + if (habbo.getHabboInfo().getCurrentRoom() == room) + room.refreshRightsForHabbo(habbo); } habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null)); 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 48d9c556..37df2118 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 @@ -19,9 +19,9 @@ public class GuildFavoriteRoomUserUpdateComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.GuildFavoriteRoomUserUpdateComposer); this.response.appendInt(this.roomUnit.getId()); - this.response.appendInt(this.guild.getId()); - this.response.appendInt(this.guild.getState().state); - this.response.appendString(this.guild.getName()); + this.response.appendInt(this.guild != null ? this.guild.getId() : 0); + this.response.appendInt(this.guild != null ? this.guild.getState().state : 3); + this.response.appendString(this.guild != null ? this.guild.getName() : ""); return this.response; } } From 4fc5a484aef013573f181b00cd46cc27f9a93abb Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 27 Dec 2020 13:13:26 -0500 Subject: [PATCH 06/80] Fix #923 room host achievement Fixes issue #923 --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 2 ++ .../java/com/eu/habbo/habbohotel/rooms/Room.java | 14 ++++++++++++++ .../com/eu/habbo/habbohotel/rooms/RoomUnit.java | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index cbd02a7b..b8fc2d61 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -104,6 +104,8 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.m -- OPTIONAL HC MIGRATION -- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP(); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.rooms.deco_hosting', '1'); + INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('easter_eggs.enabled', '1'); ALTER TABLE `bots` 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 4b30a0e3..d0704c82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.VisitorBot; import com.eu.habbo.habbohotel.commands.CommandHandler; @@ -1221,6 +1222,19 @@ public class Room implements Comparable, ISerialize, Runnable { } } + if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting")) { + //Check if the user isn't the owner id + if (this.ownerId != habbo.getHabboInfo().getId()) { + //Check if the time already have 1 minute (120 / 2 = 60s) + if (habbo.getRoomUnit().getTimeInRoom() >= 120) { + AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting")); + habbo.getRoomUnit().resetTimeInRoom(); + } else { + habbo.getRoomUnit().increaseTimeInRoom(); + } + } + } + if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().mutedBubbleTracker = false; this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose()); 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 bb078268..972030b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -73,6 +73,7 @@ public class RoomUnit { private int effectId; private int effectEndTimestamp; private ScheduledFuture moveBlockingTask; + private int timeInRoom; private int idleTimer; private Room room; @@ -93,6 +94,7 @@ public class RoomUnit { this.effectId = 0; this.isKicked = false; this.overridableTiles = new THashSet<>(); + this.timeInRoom = 0; } public void clearWalking() { @@ -639,6 +641,18 @@ public class RoomUnit { this.walkTimeOut = walkTimeOut; } + public void increaseTimeInRoom() { + this.timeInRoom++; + } + + public int getTimeInRoom() { + return this.timeInRoom; + } + + public void resetTimeInRoom() { + this.timeInRoom = 0; + } + public void increaseIdleTimer() { this.idleTimer++; } From a8c57394f4909d59b42fda847867745ff7dc5afa Mon Sep 17 00:00:00 2001 From: Harmonic Date: Mon, 28 Dec 2020 11:48:09 -0800 Subject: [PATCH 07/80] Updated Credits for MS Contributors in a new about window. --- .../eu/habbo/habbohotel/commands/AboutCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 ab4ece28..d5c7bfce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java @@ -3,7 +3,10 @@ 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.habbohotel.users.HabboManager; +import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; +import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -11,9 +14,12 @@ public class AboutCommand extends Command { public AboutCommand() { super(null, new String[]{"about", "info", "online", "server"}); } - + public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" + + "The Following people have all contributed to this emulator:\n" + + " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Harmony \n Swirny \n ArpyAge \n Mikkel \n Rodolfo \n Kitt Mustang \n Snaiker \n nttzx \n necmi \n Dome \n Jose Flores \n Cam \n Oliver \n Narzo \n Tenshie \n MartenM \n Ridge \n SenpaiDipper"; @Override public boolean handle(GameClient gameClient, String[] params) { + Emulator.getRuntime().gc(); int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted(); @@ -42,9 +48,8 @@ public class AboutCommand extends Command { "Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" + " - The General"; - gameClient.getHabbo().alert(message); - + gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(credits))); return true; } } From 28feb9e0b92b26fe430e638ddd6f8ee111a2943a Mon Sep 17 00:00:00 2001 From: Harmonic Date: Mon, 28 Dec 2020 11:53:31 -0800 Subject: [PATCH 08/80] Missed Quadral from Credits. --- .../java/com/eu/habbo/habbohotel/commands/AboutCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d5c7bfce..c38796ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java @@ -16,7 +16,7 @@ public class AboutCommand extends Command { } public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" + "The Following people have all contributed to this emulator:\n" + - " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Harmony \n Swirny \n ArpyAge \n Mikkel \n Rodolfo \n Kitt Mustang \n Snaiker \n nttzx \n necmi \n Dome \n Jose Flores \n Cam \n Oliver \n Narzo \n Tenshie \n MartenM \n Ridge \n SenpaiDipper"; + " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper"; @Override public boolean handle(GameClient gameClient, String[] params) { From 02cb78f710025e5e4cdab2652f534777c64afe47 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 29 Dec 2020 21:54:03 +0100 Subject: [PATCH 09/80] Effect_tile interaction now keeps the effect after walkoff --- .../items/interactions/InteractionEffectTile.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 cb8eb2ab..ac10dcc7 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 @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; @@ -7,6 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitType; 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 java.sql.ResultSet; import java.sql.SQLException; @@ -32,7 +35,11 @@ public class InteractionEffectTile extends InteractionPressurePlate { @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - super.onWalkOff(roomUnit, room, objects); + Emulator.getThreading().run(() -> updateState(room), 100); + + if(objects != null && objects.length > 0) { + WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this}); + } } @Override From 82d456a630b678fa28c24b5d29abd2871f7b37b0 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 30 Dec 2020 19:07:56 +0100 Subject: [PATCH 10/80] Fixed trading untradable items --- .../eu/habbo/messages/incoming/trading/TradeOfferItemEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 25fb39cb..85b521d3 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 @@ -17,7 +17,7 @@ public class TradeOfferItemEvent extends MessageHandler { HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if (item == null) + if (item == null || !item.getBaseItem().allowTrade()) return; trade.offerItem(this.client.getHabbo(), item); From 909047010062389a0fae67f46ea238bc64d46590 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 17:33:27 +0100 Subject: [PATCH 11/80] Fireworks working like Habbo --- .../interactions/InteractionFireworks.java | 132 ++++++++++++++---- .../com/eu/habbo/habbohotel/rooms/Room.java | 8 ++ 2 files changed, 115 insertions(+), 25 deletions(-) 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 645c0d4e..bc8385c5 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 @@ -5,14 +5,28 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +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.users.HabboItem; -import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class InteractionFireworks extends InteractionDefault { + + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class); + + private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels + private static final String STATE_CHARGED = "1"; + private static final String STATE_EXPLOSION = "2"; -public class InteractionFireworks extends HabboItem { public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -26,35 +40,103 @@ public class InteractionFireworks extends HabboItem { return false; } - @Override - public boolean isWalkable() { - return this.getBaseItem().allowWalk(); - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } - - @Override - public void serializeExtradata(ServerMessage serverMessage) { - serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); - super.serializeExtradata(serverMessage); //Design flaw ;( - } - + /** + * Checked in Habbo on 2021-01-03 + * - Fireworks should be charged to be able to detonate them + * - Habbos with Rights can detonate fireworks from anywhere in a room + * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Iteraction Switch) + * - Wired can always detonate fireworks + */ @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); + if (room == null) + return; - 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")); + // Wireds can always detonate fireworks if charged + if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) { + if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + super.onClick(client, room, objects); + + if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) { + this.reCharge(room); + } + } + + return; + } + + if (client == null) + return; + + // Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks + 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()))) { + closestTile = tile; + } + } + + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + List onSuccess = new ArrayList<>(); + onSuccess.add(() -> { + try { + this.onClick(client, room, objects); + } catch (Exception e) { + e.printStackTrace(); + } + }); + + client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); + } + } + + if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + super.onClick(client, room, objects); + + if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) + { + this.reCharge(room); + AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger")); + } } } @Override public boolean allowWiredResetState() { - return true; + return false; + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + this.setExtradata(STATE_CHARGED); + } + + @Override + public boolean canToggle(Habbo habbo, Room room) { + return room.hasRights(habbo) || RoomLayout.tilesAdjecent( + room.getLayout().getTile(this.getX(), this.getY()), + habbo.getRoomUnit().getCurrentLocation() + ); + } + + private void reCharge(Room room) { + // Default = 5000, Nuclear Firework should have 10000 in its custom params according to Habbo + int explodeDuration = 5000; + if (!this.getBaseItem().getCustomParams().isEmpty()) { + try { + explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams()); + } catch (NumberFormatException e) { + LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); + } + } + + Emulator.getThreading().run(() -> { + this.setExtradata(STATE_CHARGED); + this.needsUpdate(true); + room.updateItemState(this); + }, explodeDuration); } } 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 d0704c82..7a955925 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -383,6 +383,11 @@ public class Room implements Comparable, ISerialize, Runnable { this.updateItem(item); } } + + for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) { + item.setExtradata("1"); + this.updateItem(item); + } } Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this)); @@ -2419,7 +2424,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionSnowboardSlope) { this.roomSpecialTypes.addUndefined(item); + } else if (item instanceof InteractionFireworks) { + this.roomSpecialTypes.addUndefined(item); } + } } From c7bfcf76e5c78f70fbf3c68f636d0c0ae1a0dadb Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 17:38:49 +0100 Subject: [PATCH 12/80] Fix typo --- .../habbohotel/items/interactions/InteractionFireworks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bc8385c5..b2255e2f 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 @@ -44,7 +44,7 @@ public class InteractionFireworks extends InteractionDefault { * Checked in Habbo on 2021-01-03 * - Fireworks should be charged to be able to detonate them * - Habbos with Rights can detonate fireworks from anywhere in a room - * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Iteraction Switch) + * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Interaction Switch) * - Wired can always detonate fireworks */ @Override From 74e631f00a66fa61486f3701baa30c01ec913d3d Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 23:32:10 +0100 Subject: [PATCH 13/80] WiredEffectGiveHotelviewBonusRarePoints now saves as json --- ...redEffectGiveHotelviewBonusRarePoints.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) 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 1a84a14d..c50f7e5b 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer; @@ -70,7 +71,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff packet.readInt(); try { - this.amount = Integer.valueOf(packet.readString()); + this.amount = Integer.parseInt(packet.readString()); } catch (Exception e) { return false; } @@ -103,20 +104,26 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff @Override public String getWiredData() { - return this.getDelay() + "\t" + this.amount; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay(), this.amount)); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String wireData = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); this.amount = 0; - if (wireData.split("\t").length >= 2) { - super.setDelay(Integer.valueOf(wireData.split("\t")[0])); + if(wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + this.amount = data.amount; + } else { + if (wiredData.split("\t").length >= 2) { + super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); - try { - this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]); - } catch (Exception e) { + try { + this.amount = Integer.parseInt(this.getWiredData().split("\t")[1]); + } catch (Exception e) { + } } } } @@ -131,4 +138,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff public boolean requiresTriggeringUser() { return true; } + + static class JsonData { + int delay; + int amount; + + public JsonData(int delay, int amount) { + this.delay = delay; + this.amount = amount; + } + } } From 4afdf1b4b015d3a6dd022db6321d0bb397c10702 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 23:32:52 +0100 Subject: [PATCH 14/80] WiredEffectMoveFurniAway now saves as json --- .../effects/WiredEffectMoveFurniAway.java | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) 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 9efd0a32..3d985d74 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 @@ -21,6 +21,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; public class WiredEffectMoveFurniAway extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.FLEE; @@ -98,32 +99,40 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { @Override 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(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList())) + ); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - 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.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] wiredDataOld = wiredData.split("\t"); - if (item != null) - this.items.add(item); + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.parseInt(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -206,4 +215,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { protected long requiredCooldown() { return 495; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From a17dd00fcb8c2277f48af29a779db6d72d3a8d8b Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 23:47:59 +0100 Subject: [PATCH 15/80] WiredEffectMoveFurniTo now saves as json --- .../effects/WiredEffectMoveFurniAway.java | 4 +- .../wired/effects/WiredEffectMoveFurniTo.java | 75 +++++++++++++------ 2 files changed, 54 insertions(+), 25 deletions(-) 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 3d985d74..76fe1ed9 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 @@ -101,8 +101,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( this.getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList())) - ); + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override 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 bb7853c8..3b9367e2 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 @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class WiredEffectMoveFurniTo extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO; @@ -123,24 +124,23 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { @Override public String getWiredData() { - THashSet items = new THashSet<>(); + THashSet itemsToRemove = 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); + itemsToRemove.add(item); } - for (HabboItem item : items) { + for (HabboItem item : itemsToRemove) { this.items.remove(item); } - StringBuilder data = new StringBuilder(this.direction + "\t" + this.spacing + "\t" + this.getDelay() + "\t"); - - for (HabboItem item : this.items) { - data.append(item.getId()).append("\r"); - } - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.direction, + this.spacing, + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override @@ -176,22 +176,37 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split("\t"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.direction = data.direction; + this.spacing = data.spacing; + this.setDelay(data.delay); - 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)); - - if (item != null) + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { this.items.add(item); + } + } + } else { + String[] data = wiredData.split("\t"); + + if (data.length == 4) { + try { + this.direction = Integer.parseInt(data[0]); + this.spacing = Integer.parseInt(data[1]); + this.setDelay(Integer.parseInt(data[2])); + } catch (Exception e) { + } + + for (String s : data[3].split("\r")) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -209,4 +224,18 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { protected long requiredCooldown() { return 495; } + + static class JsonData { + int direction; + int spacing; + int delay; + List itemIds; + + public JsonData(int direction, int spacing, int delay, List itemIds) { + this.direction = direction; + this.spacing = spacing; + this.delay = delay; + this.itemIds = itemIds; + } + } } \ No newline at end of file From 8a3361ec5e84ac4d215a861645be5f15d9f8aed6 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 05:30:29 -0500 Subject: [PATCH 16/80] WiredEffectMoveFurniTowards now saves as json --- .../effects/WiredEffectMoveFurniTowards.java | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) 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 454b3216..2a8c62b2 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 @@ -233,32 +233,41 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { @Override 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(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - if (wiredData.length >= 1) { - this.setDelay(Integer.parseInt(wiredData[0])); - } - if (wiredData.length == 2) { - if (wiredData[1].contains(";")) { - for (String s : wiredData[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); - if (item != null) - this.items.add(item); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] wiredDataOld = wiredData.split("\t"); + + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.parseInt(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -342,4 +351,14 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { protected long requiredCooldown() { return 495; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From 9341d164a96697e43d23e9b4727bd4ffbcfc8a47 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:03:19 -0500 Subject: [PATCH 17/80] WiredEffectMoveRotateFurni now saves as json --- .../effects/WiredEffectMoveRotateFurni.java | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) 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 d933aaae..6b701093 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 @@ -80,50 +80,61 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement @Override public String getWiredData() { - THashSet items = new THashSet<>(this.items.size() / 2); + THashSet itemsToRemove = 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)) - items.add(item); + itemsToRemove.add(item); } - for (HabboItem item : items) { + for (HabboItem item : itemsToRemove) { this.items.remove(item); } - StringBuilder data = new StringBuilder(this.direction + "\t" + - this.rotation + "\t" + - this.getDelay() + "\t"); - - for (HabboItem item : this.items) { - data.append(item.getId()).append("\r"); - } - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.direction, + this.rotation, + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split("\t"); - - if (data.length == 4) { - try { - this.direction = Integer.parseInt(data[0]); - this.rotation = Integer.parseInt(data[1]); - this.setDelay(Integer.parseInt(data[2])); - } catch (Exception e) { - System.out.println(e); - } - - for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + this.direction = data.direction; + this.rotation = data.rotation; + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { this.items.add(item); + } + } + } else { + String[] data = wiredData.split("\t"); + + if (data.length == 4) { + try { + this.direction = Integer.parseInt(data[0]); + this.rotation = Integer.parseInt(data[1]); + this.setDelay(Integer.parseInt(data[2])); + } catch (Exception e) { + System.out.println(e); + } + + for (String s : data[3].split("\r")) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -303,4 +314,18 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement public void cycle(Room room) { this.itemCooldowns.clear(); } -} \ No newline at end of file + + static class JsonData { + int direction; + int rotation; + int delay; + List itemIds; + + public JsonData(int direction, int rotation, int delay, List itemIds) { + this.direction = direction; + this.rotation = rotation; + this.delay = delay; + this.itemIds = itemIds; + } + } +} From b1e9276940195de831692c4aac13d211598b2293 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:12:20 -0500 Subject: [PATCH 18/80] WiredEffectMuteHabbo now saves as json --- .../wired/effects/WiredEffectMuteHabbo.java | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) 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 27a1d2b3..e6f7b020 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 @@ -79,19 +79,32 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { @Override public String getWiredData() { - return this.getDelay() + "\t" + this.length + "\t" + this.message; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.length, + this.message + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - if (data.length >= 3) { - try { - this.setDelay(Integer.valueOf(data[0])); - this.length = Integer.valueOf(data[1]); - this.message = data[2]; - } catch (Exception e) { + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + this.length = data.length; + this.message = data.message; + } else { + String[] data = wiredData.split("\t"); + + if (data.length >= 3) { + try { + this.setDelay(Integer.valueOf(data[0])); + this.length = Integer.valueOf(data[1]); + this.message = data[2]; + } catch (Exception e) { + } } } } @@ -112,4 +125,16 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { public boolean requiresTriggeringUser() { return true; } + + static class JsonData { + int delay; + int length; + String message; + + public JsonData(int delay, int length, String message) { + this.delay = delay; + this.length = length; + this.message = message; + } + } } From 9b6ae05ac3b31ddb379da90199cb844afe7cccb4 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:20:28 -0500 Subject: [PATCH 19/80] WiredEffectResetTimers now saves as json --- .../wired/effects/WiredEffectResetTimers.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) 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 5d6f6cfe..32e167c7 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 @@ -85,17 +85,25 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { @Override public String getWiredData() { - return this.delay + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.delay + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { String data = set.getString("wired_data"); - try { - if (!data.equals("")) - this.delay = Integer.valueOf(data); - } catch (Exception e) { + if (data.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.delay = data.delay; + } else { + try { + if (!data.equals("")) { + this.delay = Integer.valueOf(data); + } + } catch (Exception e) { + } } this.setDelay(this.delay); @@ -111,4 +119,12 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { public WiredEffectType getType() { return type; } + + static class JsonData { + int delay; + + public JsonData(int delay) { + this.delay = delay; + } + } } From e73625806f47b75697815889c9a46f55eef0a37d Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:35:58 -0500 Subject: [PATCH 20/80] WiredEffectTeleport now saves as json --- .../wired/effects/WiredEffectTeleport.java | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 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 bfe0ef15..09e5cbed 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 @@ -181,32 +181,40 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override 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(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.delay, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new ArrayList<>(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - 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.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] wiredDataOld = wiredData.split("\t"); - if (item != null) - this.items.add(item); + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.valueOf(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -232,4 +240,14 @@ public class WiredEffectTeleport extends InteractionWiredEffect { protected long requiredCooldown() { return 50L; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From 39d20520cb9d634a79efca3c89c765fcd65242a0 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:44:08 -0500 Subject: [PATCH 21/80] WiredEffectToggleFurni now saves as json --- .../wired/effects/WiredEffectToggleFurni.java | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) 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 21f2926b..e6191579 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 @@ -212,35 +212,48 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { @Override 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(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - 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.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); - 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); + } + } + } else { + String[] wiredDataOld = wiredData.split("\t"); + + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.valueOf(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); + + if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) + continue; + + if (item != null) + this.items.add(item); + } } } } @@ -256,4 +269,14 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public WiredEffectType getType() { return type; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From eb00da28ef5989e77058380b9ff2184f1d9ea9aa Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:55:33 -0500 Subject: [PATCH 22/80] WiredEffectToggleRandom now saves as json --- .../effects/WiredEffectToggleRandom.java | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) 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 3a703929..ba73506d 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 @@ -192,35 +192,46 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { @Override public String getWiredData() { - StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t"); - - if (!this.items.isEmpty()) { - for (HabboItem item : this.items) { - wiredData.append(item.getId()).append(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - 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.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + + if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) + continue; - if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) - continue; + if (item != null) + this.items.add(item); + } + } else { + String[] wiredDataOld = wiredData.split("\t"); - if (item != null) - this.items.add(item); + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.valueOf(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); + + if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) + continue; + + if (item != null) + this.items.add(item); + } } } } @@ -236,4 +247,14 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { public WiredEffectType getType() { return type; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From a849328412a554814b7fe3b10e9fd85d41f22eb9 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 07:09:37 -0500 Subject: [PATCH 23/80] WiredEffectTriggerStacks now saves as json --- .../effects/WiredEffectTriggerStacks.java | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) 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 da811cd6..79ea7f9c 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 @@ -156,32 +156,40 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { @Override 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(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); - String[] wiredData = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - 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.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] wiredDataOld = wiredData.split("\t"); - if (item != null) - this.items.add(item); + if (wiredDataOld.length >= 1) { + this.setDelay(Integer.valueOf(wiredDataOld[0])); + } + if (wiredDataOld.length == 2) { + if (wiredDataOld[1].contains(";")) { + for (String s : wiredDataOld[1].split(";")) { + HabboItem item = room.getHabboItem(Integer.valueOf(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -202,4 +210,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { protected long requiredCooldown() { return 250; } + + static class JsonData { + int delay; + List itemIds; + + public JsonData(int delay, List itemIds) { + this.delay = delay; + this.itemIds = itemIds; + } + } } From 7c8789a1246599715d0bf0ce87a05a11b485d0fb Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 07:53:32 -0500 Subject: [PATCH 24/80] WiredTriggerAtSetTime now saves as json --- .../wired/triggers/WiredTriggerAtSetTime.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 414412eb..08ecd7a2 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 @@ -39,13 +39,22 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public String getWiredData() { - return this.executeTime + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.executeTime + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - if (set.getString("wired_data").length() >= 1) { - this.executeTime = (Integer.valueOf(set.getString("wired_data"))); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.executeTime = data.executeTime; + } else { + if (wiredData.length() >= 1) { + this.executeTime = (Integer.valueOf(wiredData)); + } } if (this.executeTime < 500) { @@ -115,4 +124,12 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); } + + static class JsonData { + int executeTime; + + public JsonData(int executeTime) { + this.executeTime = executeTime; + } + } } From abe70991a0765e0e88de2182eef69bcb93f06f86 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 07:57:18 -0500 Subject: [PATCH 25/80] WiredTriggerAtTimeLong now saves as json --- .../triggers/WiredTriggerAtTimeLong.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 4bcec897..f7779c7a 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 @@ -38,13 +38,22 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W @Override public String getWiredData() { - return this.executeTime + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.executeTime + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - if (set.getString("wired_data").length() >= 1) { - this.executeTime = (Integer.valueOf(set.getString("wired_data"))); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.executeTime = data.executeTime; + } else { + if (wiredData.length() >= 1) { + this.executeTime = (Integer.valueOf(wiredData)); + } } if (this.executeTime < 500) { @@ -113,4 +122,12 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); } + + static class JsonData { + int executeTime; + + public JsonData(int executeTime) { + this.executeTime = executeTime; + } + } } From fd90c23a3a56e913c484bb1de616da615ac2eb07 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 08:14:51 -0500 Subject: [PATCH 26/80] WiredTriggerBotReachedFurni now saves as json --- .../triggers/WiredTriggerBotReachedFurni.java | 60 ++++++++++++------- 1 file changed, 38 insertions(+), 22 deletions(-) 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 36c266b9..a991c23f 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 @@ -124,38 +124,45 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { @Override public String getWiredData() { - StringBuilder wiredData = new StringBuilder(this.botName + ":"); - - if (!this.items.isEmpty()) { - for (HabboItem item : this.items) { - wiredData.append(item.getId()).append(";"); - } - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.botName, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(":"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.botName = data.botName; + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(":"); - if (data.length == 1) { - this.botName = data[0]; - } else if (data.length == 2) { - this.botName = data[0]; + if (data.length == 1) { + this.botName = data[0]; + } else if (data.length == 2) { + this.botName = data[0]; - String[] items = data[1].split(";"); + String[] items = data[1].split(";"); - for (int i = 0; i < items.length; i++) { - try { - HabboItem item = room.getHabboItem(Integer.valueOf(items[i])); + 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) { - LOGGER.error("Caught exception", e); + if (item != null) + this.items.add(item); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } } } } @@ -166,4 +173,13 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { this.items.clear(); this.botName = ""; } + + static class JsonData { + String botName; + List itemIds; + + public JsonData(String botName, List itemIds) { + this.executeTime = executeTime; + } + } } From b781f1d731f9d712e903fd26d4a796954a8e1dfb Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 08:19:56 -0500 Subject: [PATCH 27/80] WiredTriggerBotReachedHabbo now saves as json --- .../triggers/WiredTriggerBotReachedHabbo.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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 161f2acf..2174d868 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 @@ -62,12 +62,21 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { @Override public String getWiredData() { - return this.botName; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.botName + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.botName = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.botName = data.botName; + } else { + this.botName = wiredData; + } } @Override @@ -79,4 +88,12 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + String botName; + + public JsonData(String botName) { + this.botName = botName; + } + } } From 0cdadfab8baa38c0af8aba764be84c5dc1d9c502 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 08:20:37 -0500 Subject: [PATCH 28/80] WiredTriggerBotReachedFurni now saves as json --- .../wired/triggers/WiredTriggerBotReachedFurni.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 a991c23f..3ea953f7 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 @@ -179,7 +179,8 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { List itemIds; public JsonData(String botName, List itemIds) { - this.executeTime = executeTime; + this.botName = botName; + this.itemIds = itemIds; } } } From 412359330895952f52a3fd919ecb6caa7d31432f Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 09:31:11 -0500 Subject: [PATCH 29/80] WiredTriggerHabboEntersRoom now saves as json --- .../triggers/WiredTriggerHabboEntersRoom.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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 69175e52..ddb8f3ec 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 @@ -41,12 +41,21 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { @Override public String getWiredData() { - return this.username; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.username + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.username = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.username = data.username; + } else { + this.username = wiredData; + } } @Override @@ -86,4 +95,12 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + String username; + + public JsonData(String username) { + this.username = username; + } + } } From 4fcf7507634a9b0b6f5f1ffb52d7e549a3dfb26c Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 09:40:53 -0500 Subject: [PATCH 30/80] WiredTriggerHabboSaysKeyword now saves as json --- .../WiredTriggerHabboSaysKeyword.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) 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 341f912a..ef219299 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 @@ -41,16 +41,27 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { @Override public String getWiredData() { - return (this.ownerOnly ? "1" : "0") + "\t" + this.key; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.ownerOnly, + this.key + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - if (data.length == 2) { - this.ownerOnly = data[0].equalsIgnoreCase("1"); - this.key = data[1]; + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.ownerOnly = data.ownerOnly; + this.key = data.key; + } else { + String[] data = wiredData.split("\t"); + + if (data.length == 2) { + this.ownerOnly = data[0].equalsIgnoreCase("1"); + this.key = data[1]; + } } } @@ -93,4 +104,14 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + boolean ownerOnly; + String key; + + public JsonData(boolean ownerOnly, String key) { + this.ownerOnly = ownerOnly; + this.key = key; + } + } } From 9b62b4390739cee20656964ecf100c3ab6d6c7ae Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 10:25:46 -0500 Subject: [PATCH 31/80] WiredTriggerRepeater now saves as json --- .../wired/triggers/WiredTriggerRepeater.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 a0f693c9..36d48b3e 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 @@ -41,13 +41,22 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy @Override public String getWiredData() { - return this.repeatTime + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.repeatTime + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - if (set.getString("wired_data").length() >= 1) { - this.repeatTime = (Integer.valueOf(set.getString("wired_data"))); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.repeatTime = data.repeatTime; + } else { + if (wiredData.length() >= 1) { + this.repeatTime = (Integer.valueOf(wiredData)); + } } if (this.repeatTime < 500) { @@ -136,4 +145,12 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } } } + + static class JsonData { + int repeatTime; + + public JsonData(int repeatTime) { + this.repeatTime = repeatTime; + } + } } From eaeafd21ad236b832701ee8b21aa3b6ee80e1dbd Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 10:27:26 -0500 Subject: [PATCH 32/80] WiredTriggerRepeaterLong now saves as json --- .../triggers/WiredTriggerRepeaterLong.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 ff3f9688..ad93a09d 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 @@ -40,13 +40,22 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override public String getWiredData() { - return this.repeatTime + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.repeatTime + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - if (set.getString("wired_data").length() >= 1) { - this.repeatTime = (Integer.valueOf(set.getString("wired_data"))); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.repeatTime = data.repeatTime; + } else { + if (wiredData.length() >= 1) { + this.repeatTime = (Integer.valueOf(wiredData)); + } } if (this.repeatTime < 5000) { @@ -130,4 +139,12 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } } } + + static class JsonData { + int repeatTime; + + public JsonData(int repeatTime) { + this.repeatTime = repeatTime; + } + } } From 09e29163104ddccccf59075677f355dc2a575d12 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 10:30:19 -0500 Subject: [PATCH 33/80] WiredTriggerScoreAchieved now saves as json --- .../triggers/WiredTriggerScoreAchieved.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) 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 b8fc74dd..e9be6e99 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 @@ -37,14 +37,23 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { @Override public String getWiredData() { - return this.score + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.score + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - try { - this.score = Integer.valueOf(set.getString("wired_data")); - } catch (Exception e) { + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.score = data.score; + } else { + try { + this.score = Integer.valueOf(wiredData); + } catch (Exception e) { + } } } @@ -85,4 +94,12 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + int score; + + public JsonData(int score) { + this.score = score; + } + } } From 5720adf61c7ed426321cbba87755735c484d4049 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 18:54:59 +0100 Subject: [PATCH 34/80] WiredEffectMoveFurniTowards now saves as json import fix --- .../interactions/wired/effects/WiredEffectMoveFurniTowards.java | 1 + 1 file changed, 1 insertion(+) 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 2a8c62b2..c069dc93 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 @@ -22,6 +22,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; /** * Wired effect: move to closest user From 75b61b180910e0e83cfd3bdfe9098d16e12e6331 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 19:03:42 +0100 Subject: [PATCH 35/80] WiredData now saves as JSON import fixes --- .../wired/effects/WiredEffectMoveRotateFurni.java | 2 ++ .../wired/effects/WiredEffectMuteHabbo.java | 1 + .../wired/effects/WiredEffectResetTimers.java | 11 ++++++----- .../wired/effects/WiredEffectTeleport.java | 9 +++++---- .../wired/effects/WiredEffectToggleFurni.java | 7 ++++--- .../wired/effects/WiredEffectToggleRandom.java | 5 +++-- .../wired/effects/WiredEffectTriggerStacks.java | 5 +++-- .../wired/triggers/WiredTriggerAtSetTime.java | 5 +++-- .../wired/triggers/WiredTriggerAtTimeLong.java | 5 +++-- .../wired/triggers/WiredTriggerBotReachedFurni.java | 5 +++-- .../wired/triggers/WiredTriggerBotReachedHabbo.java | 1 + .../wired/triggers/WiredTriggerHabboEntersRoom.java | 1 + .../wired/triggers/WiredTriggerHabboSaysKeyword.java | 1 + .../wired/triggers/WiredTriggerScoreAchieved.java | 3 ++- 14 files changed, 38 insertions(+), 23 deletions(-) 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 6b701093..5928e671 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 @@ -19,6 +19,8 @@ import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable { 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 e6f7b020..39788018 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 @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; 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 32e167c7..583e4f6a 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredResetTimers; @@ -86,21 +87,21 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.delay + this.delay )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); - if (data.startsWith("{")) { + if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); this.delay = data.delay; } else { try { - if (!data.equals("")) { - this.delay = Integer.valueOf(data); + if (!wiredData.equals("")) { + this.delay = Integer.parseInt(wiredData); } } catch (Exception e) { } 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 09e5cbed..304703f1 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 @@ -26,6 +26,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; public class WiredEffectTeleport extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TELEPORT; @@ -182,8 +183,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.delay, - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + this.getDelay(), + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @@ -205,12 +206,12 @@ public class WiredEffectTeleport extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.valueOf(wiredDataOld[0])); + this.setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item != null) this.items.add(item); 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 e6191579..05eef1f3 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 @@ -35,6 +35,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class WiredEffectToggleFurni extends InteractionWiredEffect { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class); @@ -193,7 +194,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { 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. + state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. } catch (NumberFormatException ignored) { } @@ -241,12 +242,12 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.valueOf(wiredDataOld[0])); + this.setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) continue; 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 ba73506d..4fbd9203 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 @@ -32,6 +32,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class WiredEffectToggleRandom extends InteractionWiredEffect { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class); @@ -219,12 +220,12 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.valueOf(wiredDataOld[0])); + this.setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) continue; 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 79ea7f9c..db37872b 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,6 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class WiredEffectTriggerStacks extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.CALL_STACKS; @@ -180,12 +181,12 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.valueOf(wiredDataOld[0])); + this.setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item != null) this.items.add(item); 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 08ecd7a2..f6364641 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -40,7 +41,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.executeTime + this.executeTime )); } @@ -53,7 +54,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi this.executeTime = data.executeTime; } else { if (wiredData.length() >= 1) { - this.executeTime = (Integer.valueOf(wiredData)); + this.executeTime = (Integer.parseInt(wiredData)); } } 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 f7779c7a..751d21c7 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -39,7 +40,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.executeTime + this.executeTime )); } @@ -52,7 +53,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W this.executeTime = data.executeTime; } else { if (wiredData.length() >= 1) { - this.executeTime = (Integer.valueOf(wiredData)); + this.executeTime = (Integer.parseInt(wiredData)); } } 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 3ea953f7..596fbc8f 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 @@ -21,6 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class); @@ -154,9 +155,9 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { String[] items = data[1].split(";"); - for (int i = 0; i < items.length; i++) { + for (String id : items) { try { - HabboItem item = room.getHabboItem(Integer.valueOf(items[i])); + HabboItem item = room.getHabboItem(Integer.parseInt(id)); if (item != null) this.items.add(item); 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 2174d868..0e7b22fd 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; 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 ddb8f3ec..9a1400b2 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; 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 ef219299..f3b90ae3 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; 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 e9be6e99..1f558d88 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 @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -51,7 +52,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { this.score = data.score; } else { try { - this.score = Integer.valueOf(wiredData); + this.score = Integer.parseInt(wiredData); } catch (Exception e) { } } From b8ea8fcd1be2fc95a86103c51f6d8da23f84d535 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 20:59:52 +0100 Subject: [PATCH 36/80] WiredTriggerFurniStateToggled now saves as JSON --- .../WiredTriggerFurniStateToggled.java | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) 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 c31b571a..dd1c0204 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 @@ -16,12 +16,13 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; 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 { super(set, baseItem); @@ -55,34 +56,36 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public String getWiredData() { - StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - - if (this.items != null) { - if (!this.items.isEmpty()) { - for (HabboItem item : this.items) { - wiredData.append(item.getId()).append(";"); - } - } else - wiredData.append("\t"); - } - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); - 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(";")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + super.setDelay(1000); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + if (wiredData.split(":").length >= 3) { + super.setDelay(Integer.parseInt(wiredData.split(":")[0])); - if (item != null) - this.items.add(item); + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -91,7 +94,6 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public void onPickUp() { this.items.clear(); - this.message = ""; } @Override @@ -126,7 +128,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); - message.appendString(this.message); + message.appendString(""); message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); @@ -153,4 +155,12 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From 19b1b187a5e8e2f6d938f22ad3542664cb98bfec Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:07:17 +0100 Subject: [PATCH 37/80] Removed delay since its not used --- .../wired/triggers/WiredTriggerFurniStateToggled.java | 1 - 1 file changed, 1 deletion(-) 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 dd1c0204..f97f332f 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 @@ -68,7 +68,6 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - super.setDelay(1000); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); if (item != null) { From c6af5baa7001e244cba58ffce9f839333fd19c13 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:18:02 +0100 Subject: [PATCH 38/80] WiredTriggerHabboWalkOffFurni now saves as JSON --- .../WiredTriggerHabboWalkOffFurni.java | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) 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 0e05ba01..64e9dae9 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 @@ -14,14 +14,13 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; 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 { super(set, baseItem); @@ -45,55 +44,49 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { @Override public String getWiredData() { - StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - - if (!this.items.isEmpty()) { - List toRemove = new ArrayList<>(0); - for (HabboItem item : this.items) { - if (item.getRoomId() == this.getRoomId()) { - wiredData.append(item.getId()).append(";"); - } else { - toRemove.add(item); - } - } - - this.items.removeAll(toRemove); - } else - wiredData.append("\t"); - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new WiredTriggerFurniStateToggled.JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); - 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()) - continue; + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + if (wiredData.split(":").length >= 3) { + super.setDelay(Integer.parseInt(wiredData.split(":")[0])); - try { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) + continue; - if (item != null) - this.items.add(item); - } catch (Exception e) { + try { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } catch (Exception e) { + } } } } } - } @Override public void onPickUp() { this.items.clear(); - this.message = ""; } @Override @@ -126,7 +119,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); - message.appendString(this.message); + message.appendString(""); message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); @@ -154,4 +147,12 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From 069bffb9076a3aec29c6f64ebabc59a20b34805a Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:23:59 +0100 Subject: [PATCH 39/80] WiredTriggerHabboWalkOnFurni now saves as JSON --- .../WiredTriggerHabboWalkOnFurni.java | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) 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 1ebad4c9..257f23bb 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 @@ -16,12 +16,12 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; 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 { super(set, baseItem); @@ -73,7 +73,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); - message.appendString(this.message); + message.appendString(""); message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); @@ -99,44 +99,40 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { @Override public String getWiredData() { - StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:"); - - if (!this.items.isEmpty()) { - List toRemove = new ArrayList<>(0); - for (HabboItem item : this.items) { - if (item.getRoomId() == this.getRoomId()) { - wiredData.append(item.getId()).append(";"); - } else { - toRemove.add(item); - } - } - - this.items.removeAll(toRemove); - } else - wiredData.append("\t"); - - return wiredData.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); - 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()) - continue; + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + for (Integer id: data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + if (wiredData.split(":").length >= 3) { + super.setDelay(Integer.parseInt(wiredData.split(":")[0])); - try { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) + continue; - if (item != null) - this.items.add(item); - } catch (Exception e) { + try { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } catch (Exception e) { + } } } } @@ -146,11 +142,18 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { @Override public void onPickUp() { this.items.clear(); - this.message = ""; } @Override public boolean isTriggeredByRoomUnit() { return true; } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From 0769e85a270037dbc77408753fc4155d69e91365 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:29:12 +0100 Subject: [PATCH 40/80] WiredConditionDateRangeActive now saves as JSON --- .../WiredConditionDateRangeActive.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) 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 30ba25bd..d4b92964 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -64,18 +65,29 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { @Override public String getWiredData() { - return this.startDate + "\t" + this.endDate; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.startDate, + this.endDate + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - if (data.length == 2) { - try { - this.startDate = Integer.valueOf(data[0]); - this.endDate = Integer.valueOf(data[1]); - } catch (Exception e) { + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.startDate = data.startDate; + this.endDate = data.endDate; + } else { + String[] data = wiredData.split("\t"); + + if (data.length == 2) { + try { + this.startDate = Integer.parseInt(data[0]); + this.endDate = Integer.parseInt(data[1]); + } catch (Exception e) { + } } } } @@ -85,4 +97,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { this.startDate = 0; this.endDate = 0; } + + static class JsonData { + int startDate; + int endDate; + + public JsonData(int startDate, int endDate) { + this.startDate = startDate; + this.endDate = endDate; + } + } } From 3960ee53f5acddbd19b3a604aa7917e366c6d407 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:36:42 +0100 Subject: [PATCH 41/80] WiredConditionFurniHaveFurni now saves as JSON --- .../WiredConditionFurniHaveFurni.java | 57 +++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) 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 d83921c4..ddce19a5 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,6 +15,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI; @@ -58,30 +60,43 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - - for (HabboItem item : this.items) - data.append(item.getId()).append(";"); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.all, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split(":"); + String wiredData = set.getString("wired_data"); - if (data.length >= 1) { - this.all = (data[0].equals("1")); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.all = data.all; - if (data.length == 2) { - String[] items = data[1].split(";"); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (item != null) { + this.items.add(item); + } + } - if (item != null) - this.items.add(item); + } else { + String[] data = wiredData.split(":"); + + if (data.length >= 1) { + this.all = (data[0].equals("1")); + + if (data.length == 2) { + String[] items = data[1].split(";"); + + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -166,4 +181,14 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { this.items.remove(item); } } + + static class JsonData { + boolean all; + List itemIds; + + public JsonData(boolean all, List itemIds) { + this.all = all; + this.itemIds = itemIds; + } + } } From 8fe9cadb76bb4fc49a6cfe6c26ca6b695a20dfab Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:43:14 +0100 Subject: [PATCH 42/80] Fixed wireddata incompatibility issue --- .../wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c50f7e5b..63920ffc 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 @@ -121,7 +121,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); try { - this.amount = Integer.parseInt(this.getWiredData().split("\t")[1]); + this.amount = Integer.parseInt(wiredData.split("\t")[1]); } catch (Exception e) { } } From f8520919ba43c8393f97d47bc1c0073542abc168 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:47:13 +0100 Subject: [PATCH 43/80] WiredConditionFurniHaveHabbo now saves as JSON --- .../WiredConditionFurniHaveHabbo.java | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) 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 3f9033f3..a0d07087 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 @@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; -import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import java.util.Map; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; @@ -66,33 +66,43 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - - for (HabboItem item : this.items) { - data.append(item.getId()).append(";"); - } - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.all, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(":"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.all = data.all; - if (data.length >= 1) { - this.all = (data[0].equals("1")); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - if (data.length == 2) { - String[] items = data[1].split(";"); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(":"); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (data.length >= 1) { + this.all = (data[0].equals("1")); - if (item != null) - this.items.add(item); + if (data.length == 2) { + String[] items = data[1].split(";"); + + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -170,4 +180,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { this.items.remove(item); } } + + static class JsonData { + boolean all; + List itemIds; + + public JsonData(boolean all, List itemIds) { + this.all = all; + this.itemIds = itemIds; + } + } } From da751cca421143736471cc55bf24b38a6aad9815 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 21:52:45 +0100 Subject: [PATCH 44/80] WiredConditionFurniTypeMatch now saves as JSON --- .../WiredConditionFurniTypeMatch.java | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) 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 798054d0..47c42d64 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 @@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.STUFF_IS; @@ -55,23 +57,37 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder(); - - for (HabboItem item : this.items) - data.append(item.getId()).append(";"); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(";"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - for (String s : data) - this.items.add(room.getHabboItem(Integer.valueOf(s))); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); + + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(";"); + + for (String s : data) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) { + this.items.add(item); + } + } + } } @Override @@ -138,4 +154,12 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { this.items.remove(item); } } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From 4d10af2b41cd1492b9f810302bf42680c9dc436d Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:00:18 +0100 Subject: [PATCH 45/80] WiredConditionHabboCount now saves as JSON --- .../conditions/WiredConditionHabboCount.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) 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 b131e517..d5e93e21 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -34,15 +35,26 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { @Override public String getWiredData() { - return this.lowerLimit + ":" + this.upperLimit; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.lowerLimit, + this.upperLimit + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split(":"); + String wiredData = set.getString("wired_data"); - this.lowerLimit = Integer.valueOf(data[0]); - this.upperLimit = Integer.valueOf(data[1]); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.lowerLimit = data.lowerLimit; + this.upperLimit = data.upperLimit; + } else { + String[] data = wiredData.split(":"); + + this.lowerLimit = Integer.parseInt(data[0]); + this.upperLimit = Integer.parseInt(data[1]); + } } @Override @@ -82,4 +94,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { return true; } + + static class JsonData { + int lowerLimit; + int upperLimit; + + public JsonData(int lowerLimit, int upperLimit) { + this.lowerLimit = lowerLimit; + this.upperLimit = upperLimit; + } + } } From 52650abfadbcf096490e53f47052b4be12784df8 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:03:05 +0100 Subject: [PATCH 46/80] WiredConditionHabboHasEffect now saves as JSON --- .../WiredConditionHabboHasEffect.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 fdde8793..7e1580f0 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -32,12 +33,21 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { @Override public String getWiredData() { - return this.effectId + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.effectId + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.effectId = Integer.valueOf(set.getString("wired_data")); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.effectId = data.effectId; + } else { + this.effectId = Integer.parseInt(wiredData); + } } @Override @@ -73,4 +83,12 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { return true; } + + static class JsonData { + int effectId; + + public JsonData(int effectId) { + this.effectId = effectId; + } + } } From b9029cf1f380465af795cb32f763b800d5d2240b Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:06:19 +0100 Subject: [PATCH 47/80] WiredConditionHabboHasHandItem now saves as JSON --- .../WiredConditionHabboHasHandItem.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 e47107c3..0d351e98 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import org.slf4j.Logger; @@ -66,13 +67,22 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { @Override public String getWiredData() { - return this.handItem + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.handItem + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { try { - this.handItem = Integer.valueOf(set.getString("wired_data")); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.handItem = data.handItemId; + } else { + this.handItem = Integer.parseInt(wiredData); + } } catch (Exception e) { LOGGER.error("Caught exception", e); } @@ -82,4 +92,12 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { public void onPickUp() { this.handItem = 0; } + + static class JsonData { + int handItemId; + + public JsonData(int handItemId) { + this.handItemId = handItemId; + } + } } From 7797e7f7cd1da3cb71f9802645044ad5d4e8b4fb Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:09:29 +0100 Subject: [PATCH 48/80] WiredConditionHabboWearsBadge now saves as JSON --- .../WiredConditionHabboWearsBadge.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 d2ddf27c..b4f0df9f 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -44,12 +45,21 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { @Override public String getWiredData() { - return this.badge; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.badge + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.badge = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.badge = data.badge; + } else { + this.badge = wiredData; + } } @Override @@ -85,4 +95,12 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { return true; } + + static class JsonData { + String badge; + + public JsonData(String badge) { + this.badge = badge; + } + } } From fe52ad3458eef9a68da5440d54a0957791455a38 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:12:45 +0100 Subject: [PATCH 49/80] WiredConditionLessTimeElapsed now saves as JSON --- .../WiredConditionLessTimeElapsed.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 95e907ed..b40ee5e7 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -32,16 +33,23 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { @Override public String getWiredData() { - return this.cycles + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.cycles + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); try { - if (!data.equals("")) - this.cycles = Integer.valueOf(data); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.cycles = data.cycles; + } else { + if (!wiredData.equals("")) + this.cycles = Integer.parseInt(wiredData); + } } catch (Exception e) { } } @@ -80,4 +88,12 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { return true; } + + static class JsonData { + int cycles; + + public JsonData(int cycles) { + this.cycles = cycles; + } + } } From e6a5aaa27915320393f1457eb9de09c4cec3eea3 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:28:17 +0100 Subject: [PATCH 50/80] WiredConditionMatchStatePosition now saves as JSON --- .../WiredConditionMatchStatePosition.java | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) 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 27c82d91..e489e781 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 @@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class WiredConditionMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; @@ -138,38 +140,42 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition @Override public String getWiredData() { - StringBuilder data = new StringBuilder(this.settings.size() + ":"); - - if (this.settings.isEmpty()) { - data.append("\t;"); - } else { - for (WiredMatchFurniSetting item : this.settings) - data.append(item.toString()).append(";"); - } - - data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.state, + this.position, + this.direction, + new ArrayList<>(this.settings) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split(":"); + String wiredData = set.getString("wired_data"); - int itemCount = Integer.valueOf(data[0]); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.state = data.state; + this.position = data.position; + this.direction = data.direction; + this.settings.addAll(data.settings); + } else { + String[] data = wiredData.split(":"); - String[] items = data[1].split(";"); + int itemCount = Integer.parseInt(data[0]); - for (int i = 0; i < itemCount; i++) { - String[] stuff = items[i].split("-"); + String[] items = data[1].split(";"); - 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]))); + for (int i = 0; i < itemCount; i++) { + String[] stuff = items[i].split("-"); + + if (stuff.length >= 5) + this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); + } + + this.state = data[2].equals("1"); + this.direction = data[3].equals("1"); + this.position = data[4].equals("1"); } - - this.state = data[2].equals("1"); - this.direction = data[3].equals("1"); - this.position = data[4].equals("1"); } @Override @@ -198,4 +204,18 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } } + + static class JsonData { + boolean state; + boolean position; + boolean direction; + List settings; + + public JsonData(boolean state, boolean position, boolean direction, List settings) { + this.state = state; + this.position = position; + this.direction = direction; + this.settings = settings; + } + } } From 277464b365a84aaeedf11cea0afaabdcf21b3072 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:30:17 +0100 Subject: [PATCH 51/80] WiredConditionMoreTimeElapsed now saves as JSON --- .../WiredConditionMoreTimeElapsed.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 a1fa3c5c..0be6ba15 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { @Override public String getWiredData() { - return this.cycles + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.cycles + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); try { - if (!data.equals("")) - this.cycles = Integer.valueOf(data); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.cycles = data.cycles; + } else { + if (!wiredData.equals("")) + this.cycles = Integer.parseInt(wiredData); + } } catch (Exception e) { } } @@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { return true; } + + static class JsonData { + int cycles; + + public JsonData(int cycles) { + this.cycles = cycles; + } + } } From 3488c8ad36da9bbc768e13b5b16fe3863fa875fe Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:33:33 +0100 Subject: [PATCH 52/80] WiredConditionNotFurniHaveFurni now saves as JSON --- .../WiredConditionNotFurniHaveFurni.java | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) 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 71fbc0b6..279f61bd 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,6 +16,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI; @@ -59,32 +61,43 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - - for (HabboItem item : this.items) - data.append(item.getId()).append(";"); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.all, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(":"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.all = data.all; - if (data.length >= 1) { - this.all = (data[0].equals("1")); + for (int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - if (data.length == 2) { - String[] items = data[1].split(";"); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(":"); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + if (data.length >= 1) { + this.all = (data[0].equals("1")); - if (item != null) - this.items.add(item); + if (data.length == 2) { + String[] items = data[1].split(";"); + + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -175,4 +188,14 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { //return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR; return WiredConditionOperator.AND; } + + static class JsonData { + boolean all; + List itemIds; + + public JsonData(boolean all, List itemIds) { + this.all = all; + this.itemIds = itemIds; + } + } } From 87ff24e40932ab6037aea4463df2c748e1c3fb15 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:38:20 +0100 Subject: [PATCH 53/80] WiredConditionNotFurniHaveHabbo now saves as JSON --- .../WiredConditionNotFurniHaveHabbo.java | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) 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 b85217aa..87f3bc9a 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 @@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; -import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import java.util.Map; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; @@ -66,33 +66,43 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":"); - - for (HabboItem item : this.items) { - data.append(item.getId()).append(";"); - } - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.all, + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(":"); + if (wiredData.startsWith("{")) { + WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class); + this.all = data.all; - if (data.length >= 1) { - this.all = (data[0].equals("1")); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - if (data.length == 2) { - String[] items = data[1].split(";"); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(":"); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + if (data.length >= 1) { + this.all = (data[0].equals("1")); - if (item != null) - this.items.add(item); + if (data.length == 2) { + String[] items = data[1].split(";"); + + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) + this.items.add(item); + } } } } @@ -169,4 +179,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { this.items.remove(item); } } + + static class JsonData { + boolean all; + List itemIds; + + public JsonData(boolean all, List itemIds) { + this.all = all; + this.itemIds = itemIds; + } + } } From b6b4ac936efd7116f36177b163154398beee7c21 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:42:13 +0100 Subject: [PATCH 54/80] WiredConditionNotFurniTypeMatch now saves as JSON --- .../WiredConditionNotFurniTypeMatch.java | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) 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 d9b6d466..30c9ea51 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 @@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS; @@ -50,23 +52,37 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder(); - - for (HabboItem item : this.items) - data.append(item.getId()).append(";"); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(";"); + if (wiredData.startsWith("{")) { + WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class); - for (String s : data) - this.items.add(room.getHabboItem(Integer.valueOf(s))); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); + + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = set.getString("wired_data").split(";"); + + for (String s : data) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) { + this.items.add(item); + } + } + } } @Override @@ -138,4 +154,12 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { this.items.remove(item); } } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From ecfeaa9a5f2534ac390640d7bb07bef94c1eb041 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:45:49 +0100 Subject: [PATCH 55/80] WiredConditionNotHabboCount now saves as JSON --- .../WiredConditionNotHabboCount.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) 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 194d47c1..3075c4ff 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -34,14 +35,25 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { @Override public String getWiredData() { - return this.lowerLimit + ":" + this.upperLimit; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.lowerLimit, + this.upperLimit + )); } @Override 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]); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class); + this.lowerLimit = data.lowerLimit; + this.upperLimit = data.upperLimit; + } else { + String[] data = wiredData.split(":"); + this.lowerLimit = Integer.parseInt(data[0]); + this.upperLimit = Integer.parseInt(data[1]); + } } @Override @@ -81,4 +93,14 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { return true; } + + static class JsonData { + int lowerLimit; + int upperLimit; + + public JsonData(int lowerLimit, int upperLimit) { + this.lowerLimit = lowerLimit; + this.upperLimit = upperLimit; + } + } } From 218cb2f3fbcda17dbc963ec2ce47819af2c5f801 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:48:08 +0100 Subject: [PATCH 56/80] WiredConditionNotHabboHasEffect now saves as JSON --- .../WiredConditionNotHabboHasEffect.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 0994a2a3..ae1c20bb 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -32,12 +33,21 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { @Override public String getWiredData() { - return this.effectId + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.effectId + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.effectId = Integer.valueOf(set.getString("wired_data")); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.effectId = data.effectId; + } else { + this.effectId = Integer.parseInt(wiredData); + } } @Override @@ -73,4 +83,12 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { return true; } + + static class JsonData { + int effectId; + + public JsonData(int effectId) { + this.effectId = effectId; + } + } } From a1bf9d7aa7a56a39b96672a0ace5187f0f0f4a5f Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:49:45 +0100 Subject: [PATCH 57/80] WiredConditionNotHabboWearsBadge now saves as JSON --- .../WiredConditionNotHabboWearsBadge.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 3a30238f..6df96d6b 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -45,12 +46,21 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition @Override public String getWiredData() { - return this.badge; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.badge + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.badge = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.badge = data.badge; + } else { + this.badge = wiredData; + } } @Override @@ -86,4 +96,12 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition return true; } + + static class JsonData { + String badge; + + public JsonData(String badge) { + this.badge = badge; + } + } } From bea21b715edc6129e57c94f0a0944e0055165514 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 23:05:45 +0100 Subject: [PATCH 58/80] WiredConditionNotInTeam now saves as JSON --- .../conditions/WiredConditionNotInTeam.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 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 704921fc..b805c7b1 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -39,16 +40,23 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { @Override public String getWiredData() { - return this.teamColor.type + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.teamColor + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); - try { - if (!data.equals("")) - this.teamColor = GameTeamColors.values()[Integer.valueOf(data)]; + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.teamColor = data.teamColor; + } else { + if (!wiredData.equals("")) + this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)]; + } } catch (Exception e) { this.teamColor = GameTeamColors.RED; } @@ -88,4 +96,12 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { return true; } + + static class JsonData { + GameTeamColors teamColor; + + public JsonData(GameTeamColors teamColor) { + this.teamColor = teamColor; + } + } } From 5617cd3da2194665b6fcb3d6a4ae1a937553ff10 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 23:07:36 +0100 Subject: [PATCH 59/80] WiredConditionTeamMember now saves as JSON --- .../conditions/WiredConditionTeamMember.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) 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 9349cbb2..027db810 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -41,16 +42,23 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { @Override public String getWiredData() { - return this.teamColor.type + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.teamColor + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); - try { - if (!data.equals("")) - this.teamColor = GameTeamColors.values()[Integer.valueOf(data)]; + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.teamColor = data.teamColor; + } else { + if (!wiredData.equals("")) + this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)]; + } } catch (Exception e) { this.teamColor = GameTeamColors.RED; } @@ -90,4 +98,12 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { return true; } + + static class JsonData { + GameTeamColors teamColor; + + public JsonData(GameTeamColors teamColor) { + this.teamColor = teamColor; + } + } } From 190a5cf86033b4df8c7643f670f825ce50e7291e Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 23:10:50 +0100 Subject: [PATCH 60/80] WiredConditionNotMatchStatePosition now saves as JSON --- .../WiredConditionNotMatchStatePosition.java | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) 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 48983cef..11684c93 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 @@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; @@ -68,38 +70,42 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi @Override public String getWiredData() { - StringBuilder data = new StringBuilder(this.settings.size() + ":"); - - if (this.settings.isEmpty()) { - data.append("\t;"); - } else { - for (WiredMatchFurniSetting item : this.settings) - data.append(item.toString()).append(";"); - } - - data.append(":").append(this.state ? 1 : 0).append(":").append(this.rotation ? 1 : 0).append(":").append(this.position ? 1 : 0); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new WiredConditionMatchStatePosition.JsonData( + this.state, + this.position, + this.rotation, + new ArrayList<>(this.settings) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split(":"); + String wiredData = set.getString("wired_data"); - int itemCount = Integer.valueOf(data[0]); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.state = data.state; + this.position = data.position; + this.rotation = data.direction; + this.settings.addAll(data.settings); + } else { + String[] data = wiredData.split(":"); - String[] items = data[1].split(";"); + int itemCount = Integer.parseInt(data[0]); - for (int i = 0; i < itemCount; i++) { - String[] stuff = items[i].split("-"); + String[] items = data[1].split(";"); - 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]))); + for (int i = 0; i < itemCount; i++) { + String[] stuff = items[i].split("-"); + + if (stuff.length >= 5) + this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); + } + + this.state = data[2].equals("1"); + this.rotation = data[3].equals("1"); + this.position = data[4].equals("1"); } - - this.state = data[2].equals("1"); - this.rotation = data[3].equals("1"); - this.position = data[4].equals("1"); } @Override @@ -189,4 +195,18 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } } + + static class JsonData { + boolean state; + boolean position; + boolean direction; + List settings; + + public JsonData(boolean state, boolean position, boolean direction, List settings) { + this.state = state; + this.position = position; + this.direction = direction; + this.settings = settings; + } + } } From ac1c6a3d9bace50df0c34ce259d01cb1da5f6af1 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 23:13:21 +0100 Subject: [PATCH 61/80] WiredConditionNotTriggerOnFurni now saves as JSON --- .../WiredConditionNotTriggerOnFurni.java | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) 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 cf31f254..f80f7df6 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 @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI; @@ -44,26 +45,35 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder(); - - for (HabboItem item : this.items) - data.append(item.getId()).append(";"); - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(";"); + if (wiredData.startsWith("{")) { + WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class); - for (String s : data) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(";"); + + for (String s : data) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) { + this.items.add(item); + } } } } @@ -139,4 +149,12 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition { this.items.removeAll(items); } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From ad84ef423e406f92ca68682ad0fb55714b0de04a Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 23:15:01 +0100 Subject: [PATCH 62/80] WiredConditionTriggerOnFurni now saves as JSON --- .../WiredConditionTriggerOnFurni.java | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) 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 5dcfb9cc..733c8581 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 @@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI; @@ -67,27 +69,35 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { @Override public String getWiredData() { this.refresh(); - - StringBuilder data = new StringBuilder(); - - for (HabboItem item : this.items) { - data.append(item.getId()).append(";"); - } - - return data.toString(); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { this.items.clear(); + String wiredData = set.getString("wired_data"); - String[] data = set.getString("wired_data").split(";"); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - for (String s : data) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + for(int id : data.itemIds) { + HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); + if (item != null) { + this.items.add(item); + } + } + } else { + String[] data = wiredData.split(";"); + + for (String s : data) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) { + this.items.add(item); + } } } } @@ -168,4 +178,12 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { public WiredConditionOperator operator() { return WiredConditionOperator.AND; } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } } From d6ecdbeeecb992bf6cc9aacdb215b091f02e359b Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 5 Jan 2021 21:55:23 +0100 Subject: [PATCH 63/80] Added SQL to expand items.wired_data column --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index b8fc2d61..42a86b26 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -114,3 +114,6 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`; -- Permissions to see tent chat ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent'); + +-- Making items.wired_data column bigger since wired data is saved as JSON now +ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000) \ No newline at end of file From 4937ac298de4f5d029e40da106bd216cab9fe5df Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:24:04 +0100 Subject: [PATCH 64/80] Added roombadge command --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 6 +++ .../habbohotel/commands/RoomBadgeCommand.java | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index b8fc2d61..23f3508b 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -114,3 +114,9 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`; -- Permissions to see tent chat ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent'); + +-- Roombadge command +ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_massbadge', 'roombadge'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_massbadge', ':roombadge '); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java new file mode 100644 index 00000000..a2693217 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java @@ -0,0 +1,54 @@ +package com.eu.habbo.habbohotel.commands; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboBadge; +import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; +import com.eu.habbo.messages.ServerMessage; +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.AddUserBadgeComposer; +import gnu.trove.map.hash.THashMap; + +public class RoomBadgeCommand extends Command { + public RoomBadgeCommand() { + super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient == null) + return true; + + if (params.length == 2) { + String badge; + + badge = params[1]; + + 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 (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) { + if (habbo.isOnline()) { + if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { + HabboBadge b = BadgesComponent.createBadge(badge, habbo); + + habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); + habbo.getClient().sendResponse(message); + } + } + } + } + return true; + } + + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT); + return true; + } +} From 22efb1c925075c2827cbdb5ff9900e283c6f226e Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:34:22 +0100 Subject: [PATCH 65/80] Oop.. --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index 23f3508b..1bc01add 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -118,5 +118,5 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', -- Roombadge command ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_massbadge', 'roombadge'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_massbadge', ':roombadge '); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge '); From 8a89f7ce4d572705f4ff1f67763c616d82a9b3be Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:39:30 +0100 Subject: [PATCH 66/80] Actually added the RoomBadgeCommand --- .../java/com/eu/habbo/habbohotel/commands/CommandHandler.java | 1 + 1 file changed, 1 insertion(+) 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 1ec167c4..a37d9482 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -217,6 +217,7 @@ public class CommandHandler { addCommand(new LayCommand()); addCommand(new MachineBanCommand()); addCommand(new MassBadgeCommand()); + addCommand(new RoomBadgeCommand()); addCommand(new MassCreditsCommand()); addCommand(new MassGiftCommand()); addCommand(new MassPixelsCommand()); From 5981046523bd44ff09dee6e293e40db45a540985 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 10 Jan 2021 02:49:15 +0000 Subject: [PATCH 67/80] Fix issue 936 --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 2 ++ src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index b8fc2d61..21f3064c 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -101,6 +101,8 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscr INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.roomuser.idle.not_dancing.ignore.wired_idle', '0'); + -- OPTIONAL HC MIGRATION -- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP(); 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 d0704c82..512783f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1205,8 +1205,11 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().increaseIdleTimer(); if (habbo.getRoomUnit().isIdle()) { - this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); - WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); + boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE); + if (danceIsNone) + this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); + if (danceIsNone && !Emulator.getConfig().getBoolean("hotel.roomuser.idle.not_dancing.ignore.wired_idle")) + WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } } else { habbo.getRoomUnit().increaseIdleTimer(); From 35ac99b2c6c1f0622a2d09aa4a65fb1b39ebc62e Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:45:44 +0100 Subject: [PATCH 68/80] Added Apply furni to set conditions feature --- .../WiredConditionMatchStatePosition.java | 23 ++++- .../WiredConditionNotMatchStatePosition.java | 23 ++++- .../wired/effects/WiredEffectMatchFurni.java | 23 ++++- .../InteractionWiredMatchFurniSettings.java | 11 +++ .../com/eu/habbo/messages/PacketManager.java | 4 +- .../eu/habbo/messages/incoming/Incoming.java | 2 + .../WiredEffectApplySetConditionsEvent.java | 98 +++++++++++++++++++ 7 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java 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 27c82d91..0fe350dd 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -16,7 +17,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 implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -198,4 +199,24 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } } + + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } } 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 48983cef..b6d7cb5e 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -16,7 +17,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 implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -189,4 +190,24 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } } + + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.rotation; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } } 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 fbd374d4..aa19b878 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -24,7 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -public class WiredEffectMatchFurni extends InteractionWiredEffect { +public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; @@ -241,6 +242,26 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { } } + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } + static class JsonData { boolean state; boolean direction; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java new file mode 100644 index 00000000..6db447f7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java @@ -0,0 +1,11 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; +import gnu.trove.set.hash.THashSet; + +public interface InteractionWiredMatchFurniSettings { + public THashSet getMatchFurniSettings(); + public boolean shouldMatchState(); + public boolean shouldMatchRotation(); + public boolean shouldMatchPosition(); +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 00cdb987..f9b427a3 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,6 +65,7 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; +import com.eu.habbo.messages.incoming.wired.WiredEffectApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -81,7 +82,7 @@ public class PacketManager { private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); private static final List logList = new ArrayList<>(); - public static boolean DEBUG_SHOW_PACKETS = false; + public static boolean DEBUG_SHOW_PACKETS = true; public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; @@ -579,6 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); + this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredEffectApplySetConditionsEvent.class); } void registerUnknown() 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 621a4775..c70b9b88 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,6 +155,8 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; + public static final int WiredEffectApplySetConditionsEvent = 3373; +// public static final int WiredEffectApplySetConditionsEvent = 495; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java new file mode 100644 index 00000000..4e8a40e2 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java @@ -0,0 +1,98 @@ +package com.eu.habbo.messages.incoming.wired; + +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.users.HabboItem; +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.rooms.items.FloorItemOnRollerComposer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class WiredEffectApplySetConditionsEvent extends MessageHandler { + + @Override + public void handle() throws Exception { + int itemId = this.packet.readInt(); + + // Executing Habbo has to be in a Room + 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) { + + // Executing Habbo should be able to edit wireds + if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) { + + List wireds = new ArrayList<>(); + wireds.addAll(room.getRoomSpecialTypes().getConditions()); + wireds.addAll(room.getRoomSpecialTypes().getEffects()); + + // Find the item with the given ID in the room + Optional item = wireds.stream() + .filter(wired -> wired.getId() == itemId) + .findFirst(); + + // If the item exists + if (item.isPresent()) { + HabboItem wiredItem = item.get(); + + // The item should have settings to match furni state, position and rotation + if (wiredItem instanceof InteractionWiredMatchFurniSettings) { + + InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; + + // Try to apply the set settings to each item + wired.getMatchFurniSettings().forEach(setting -> { + HabboItem matchItem = room.getHabboItem(setting.item_id); + + // Match state + if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { + if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { + matchItem.setExtradata(setting.state); + room.updateItemState(matchItem); + } + } + + RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); + double oldZ = matchItem.getZ(); + + // Match Position & Rotation + if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { + if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { + room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); + } + } + else if(wired.shouldMatchPosition()) { + boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; + RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); + int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); + + if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { + if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { + if(slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + } + } + } + } + }); + } + } + } + } + } +} From 32e7c29f84755f9076ff6ef1a58d9e1daebc0b32 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:47:26 +0100 Subject: [PATCH 69/80] Removed commented code --- src/main/java/com/eu/habbo/messages/incoming/Incoming.java | 1 - 1 file changed, 1 deletion(-) 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 c70b9b88..dd19f4a7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -156,7 +156,6 @@ public class Incoming { public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; public static final int WiredEffectApplySetConditionsEvent = 3373; -// public static final int WiredEffectApplySetConditionsEvent = 495; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; From 2313276df067997120819fb106d2010f43c2f295 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:50:03 +0100 Subject: [PATCH 70/80] Removed debugging code --- src/main/java/com/eu/habbo/messages/PacketManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index f9b427a3..16e85a04 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -82,7 +82,7 @@ public class PacketManager { private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); private static final List logList = new ArrayList<>(); - public static boolean DEBUG_SHOW_PACKETS = true; + public static boolean DEBUG_SHOW_PACKETS = false; public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; From 53fc7ece4a34a3b49f6782f23083a0a50fd8e90e Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:55:09 +0100 Subject: [PATCH 71/80] Renamed event since it applies to both conditions and effects --- src/main/java/com/eu/habbo/messages/PacketManager.java | 4 ++-- ...ConditionsEvent.java => WiredApplySetConditionsEvent.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/eu/habbo/messages/incoming/wired/{WiredEffectApplySetConditionsEvent.java => WiredApplySetConditionsEvent.java} (98%) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 16e85a04..f61928d2 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,7 +65,7 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; -import com.eu.habbo.messages.incoming.wired.WiredEffectApplySetConditionsEvent; +import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -580,7 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredEffectApplySetConditionsEvent.class); + this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java similarity index 98% rename from src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java rename to src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 4e8a40e2..12676201 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -public class WiredEffectApplySetConditionsEvent extends MessageHandler { +public class WiredApplySetConditionsEvent extends MessageHandler { @Override public void handle() throws Exception { From de7c51d78a1771465094fa513451a3c178fc5963 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 22:15:20 +0100 Subject: [PATCH 72/80] Added ratelimit --- .../incoming/wired/WiredApplySetConditionsEvent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 12676201..6fac8cab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -17,6 +17,11 @@ import java.util.Optional; public class WiredApplySetConditionsEvent extends MessageHandler { + @Override + public int getRatelimit() { + return 500; + } + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); From 40914b505080add986d31bd8e6642bb5e39474a7 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 23:10:15 +0100 Subject: [PATCH 73/80] Renamed incoming event --- src/main/java/com/eu/habbo/messages/PacketManager.java | 2 +- src/main/java/com/eu/habbo/messages/incoming/Incoming.java | 2 +- .../messages/incoming/wired/WiredApplySetConditionsEvent.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index f61928d2..edf209bb 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -580,7 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredApplySetConditionsEvent.class); + this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() 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 dd19f4a7..75223e4c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,7 +155,7 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; - public static final int WiredEffectApplySetConditionsEvent = 3373; + public static final int WiredApplySetConditionsEvent = 3373; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 6fac8cab..1d9266f3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -21,7 +21,7 @@ public class WiredApplySetConditionsEvent extends MessageHandler { public int getRatelimit() { return 500; } - + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); From f4869a6305370a5bbddc73fed5b85af4e466e0a4 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Jan 2021 18:04:47 -0500 Subject: [PATCH 74/80] Revert "Merge branch 'feature/packet-1094' into 'dev'" This reverts merge request !366 --- .../WiredConditionMatchStatePosition.java | 23 +--- .../WiredConditionNotMatchStatePosition.java | 23 +--- .../wired/effects/WiredEffectMatchFurni.java | 23 +--- .../InteractionWiredMatchFurniSettings.java | 11 -- .../com/eu/habbo/messages/PacketManager.java | 2 - .../eu/habbo/messages/incoming/Incoming.java | 1 - .../wired/WiredApplySetConditionsEvent.java | 103 ------------------ 7 files changed, 3 insertions(+), 183 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java delete mode 100644 src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java 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 0fe350dd..27c82d91 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 @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -17,7 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { +public class WiredConditionMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -199,24 +198,4 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } } - - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.direction; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } } 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 b6d7cb5e..48983cef 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 @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -17,7 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { +public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -190,24 +189,4 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } } - - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.rotation; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } } 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 aa19b878..fbd374d4 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 @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -25,7 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { +public class WiredEffectMatchFurni extends InteractionWiredEffect { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; @@ -242,26 +241,6 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } } - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.direction; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } - static class JsonData { boolean state; boolean direction; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java deleted file mode 100644 index 6db447f7..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; - -import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import gnu.trove.set.hash.THashSet; - -public interface InteractionWiredMatchFurniSettings { - public THashSet getMatchFurniSettings(); - public boolean shouldMatchState(); - public boolean shouldMatchRotation(); - public boolean shouldMatchPosition(); -} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index edf209bb..00cdb987 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,7 +65,6 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; -import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -580,7 +579,6 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() 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 75223e4c..621a4775 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,7 +155,6 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; - public static final int WiredApplySetConditionsEvent = 3373; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java deleted file mode 100644 index 1d9266f3..00000000 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.eu.habbo.messages.incoming.wired; - -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; -import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; -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.users.HabboItem; -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.rooms.items.FloorItemOnRollerComposer; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class WiredApplySetConditionsEvent extends MessageHandler { - - @Override - public int getRatelimit() { - return 500; - } - - @Override - public void handle() throws Exception { - int itemId = this.packet.readInt(); - - // Executing Habbo has to be in a Room - 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) { - - // Executing Habbo should be able to edit wireds - if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) { - - List wireds = new ArrayList<>(); - wireds.addAll(room.getRoomSpecialTypes().getConditions()); - wireds.addAll(room.getRoomSpecialTypes().getEffects()); - - // Find the item with the given ID in the room - Optional item = wireds.stream() - .filter(wired -> wired.getId() == itemId) - .findFirst(); - - // If the item exists - if (item.isPresent()) { - HabboItem wiredItem = item.get(); - - // The item should have settings to match furni state, position and rotation - if (wiredItem instanceof InteractionWiredMatchFurniSettings) { - - InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; - - // Try to apply the set settings to each item - wired.getMatchFurniSettings().forEach(setting -> { - HabboItem matchItem = room.getHabboItem(setting.item_id); - - // Match state - if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { - if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { - matchItem.setExtradata(setting.state); - room.updateItemState(matchItem); - } - } - - RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); - double oldZ = matchItem.getZ(); - - // Match Position & Rotation - if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { - if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { - room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); - } - } - else if(wired.shouldMatchPosition()) { - boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; - RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); - int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); - - if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { - if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - if(slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); - } - } - } - } - }); - } - } - } - } - } -} From 5b1ffa5bee4d4747c353dbd8209f6e4162524778 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Jan 2021 15:30:21 -0800 Subject: [PATCH 75/80] Fixed sql update. Added debug mode check for TooLongFrameException Error. --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 9 ++++++++- .../eu/habbo/habbohotel/commands/AboutCommand.java | 2 +- .../gameserver/decoders/GameMessageHandler.java | 12 ++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index d7f002bd..62e6d755 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -117,5 +117,12 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`; ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent'); +-- Roombadge command +ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge '); + -- Making items.wired_data column bigger since wired data is saved as JSON now -ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000) \ No newline at end of file +ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000) + 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 c38796ec..f7130aff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java @@ -16,7 +16,7 @@ public class AboutCommand extends Command { } public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" + "The Following people have all contributed to this emulator:\n" + - " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper"; + " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper"; @Override public boolean handle(GameClient gameClient, String[] params) { diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index 2da3032e..c85f3315 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -59,13 +59,13 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { ctx.channel().close(); return; } - - if (cause instanceof TooLongFrameException) { - LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); - } else { - LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); + if (Emulator.getConfig().getBoolean("debug.mode")) { + if (cause instanceof TooLongFrameException) { + LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); + } else { + LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); + } } - ctx.channel().close(); } From a0cfe07ca32a02738dad3acce2edc413be659bc6 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 11 Jan 2021 22:20:06 +0100 Subject: [PATCH 76/80] Readded packet --- .../WiredConditionMatchStatePosition.java | 23 +++- .../WiredConditionNotMatchStatePosition.java | 23 +++- .../wired/effects/WiredEffectMatchFurni.java | 24 +++- .../InteractionWiredMatchFurniSettings.java | 11 ++ .../com/eu/habbo/messages/PacketManager.java | 2 + .../eu/habbo/messages/incoming/Incoming.java | 1 + .../wired/WiredApplySetConditionsEvent.java | 103 ++++++++++++++++++ 7 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java 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 e489e781..76ece81c 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -18,7 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredConditionMatchStatePosition extends InteractionWiredCondition { +public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -205,6 +206,26 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } + static class JsonData { boolean state; boolean position; 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 11684c93..4c9cd092 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -18,7 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { +public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -196,6 +197,26 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.rotation; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } + static class JsonData { boolean state; boolean position; 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 fbd374d4..bb615d8d 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 @@ -2,9 +2,9 @@ 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.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -public class WiredEffectMatchFurni extends InteractionWiredEffect { +public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; @@ -241,6 +241,26 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { } } + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } + static class JsonData { boolean state; boolean direction; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java new file mode 100644 index 00000000..6db447f7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java @@ -0,0 +1,11 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; +import gnu.trove.set.hash.THashSet; + +public interface InteractionWiredMatchFurniSettings { + public THashSet getMatchFurniSettings(); + public boolean shouldMatchState(); + public boolean shouldMatchRotation(); + public boolean shouldMatchPosition(); +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 00cdb987..ee0c8965 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -64,6 +64,7 @@ import com.eu.habbo.messages.incoming.trading.*; import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; +import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; @@ -579,6 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); + this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() 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 621a4775..75223e4c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,6 +155,7 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; + public static final int WiredApplySetConditionsEvent = 3373; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java new file mode 100644 index 00000000..1d9266f3 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -0,0 +1,103 @@ +package com.eu.habbo.messages.incoming.wired; + +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.users.HabboItem; +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.rooms.items.FloorItemOnRollerComposer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class WiredApplySetConditionsEvent extends MessageHandler { + + @Override + public int getRatelimit() { + return 500; + } + + @Override + public void handle() throws Exception { + int itemId = this.packet.readInt(); + + // Executing Habbo has to be in a Room + 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) { + + // Executing Habbo should be able to edit wireds + if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) { + + List wireds = new ArrayList<>(); + wireds.addAll(room.getRoomSpecialTypes().getConditions()); + wireds.addAll(room.getRoomSpecialTypes().getEffects()); + + // Find the item with the given ID in the room + Optional item = wireds.stream() + .filter(wired -> wired.getId() == itemId) + .findFirst(); + + // If the item exists + if (item.isPresent()) { + HabboItem wiredItem = item.get(); + + // The item should have settings to match furni state, position and rotation + if (wiredItem instanceof InteractionWiredMatchFurniSettings) { + + InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; + + // Try to apply the set settings to each item + wired.getMatchFurniSettings().forEach(setting -> { + HabboItem matchItem = room.getHabboItem(setting.item_id); + + // Match state + if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { + if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { + matchItem.setExtradata(setting.state); + room.updateItemState(matchItem); + } + } + + RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); + double oldZ = matchItem.getZ(); + + // Match Position & Rotation + if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { + if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { + room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); + } + } + else if(wired.shouldMatchPosition()) { + boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; + RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); + int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); + + if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { + if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { + if(slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + } + } + } + } + }); + } + } + } + } + } +} From 3371308395222cc46d9172272be5f68b03093aaa Mon Sep 17 00:00:00 2001 From: Snaiker Date: Thu, 14 Jan 2021 02:56:01 +0000 Subject: [PATCH 77/80] Fix char ; is missing --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index 62e6d755..f87aa41e 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -124,5 +124,5 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombad INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge '); -- Making items.wired_data column bigger since wired data is saved as JSON now -ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000) +ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000); From 48cef2ed70a4dfccedd284c078559ccc637c28bd Mon Sep 17 00:00:00 2001 From: Dank074 Date: Sun, 17 Jan 2021 01:50:17 -0600 Subject: [PATCH 78/80] added plugin event for getting user ip --- .../habbohotel/commands/UserInfoCommand.java | 2 +- .../habbohotel/modtool/ModToolManager.java | 8 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 27 +++++- .../habbo/habbohotel/users/HabboManager.java | 2 +- .../incoming/handshake/SecureLoginEvent.java | 16 ++-- .../handshake/SecureLoginEvent_BACKUP.java | 89 ------------------- .../events/users/UserGetIPAddressEvent.java | 28 ++++++ .../plugin/events/users/UserLoginEvent.java | 5 +- 8 files changed, 68 insertions(+), 109 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/users/UserGetIPAddressEvent.java 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 fdd621c8..b4a3ca78 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java @@ -45,7 +45,7 @@ public class UserInfoCommand extends Command { Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" + ((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") + ((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") + - ((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") + + ((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") + (onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : "")); ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId()); 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 c891286e..9dbd405a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -505,6 +505,7 @@ public class ModToolManager { return ban; } + @Deprecated public boolean hasIPBan(Channel habbo) { if (habbo == null) return false; @@ -512,9 +513,13 @@ public class ModToolManager { if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null) return false; + return this.hasIPBan(((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress()); + } + + public boolean hasIPBan(String ipAddress) { 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")) { - statement.setString(1, ((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress()); + statement.setString(1, ipAddress); statement.setInt(2, Emulator.getIntUnixTimestamp()); try (ResultSet set = statement.executeQuery()) { @@ -525,7 +530,6 @@ public class ModToolManager { } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); } - return banned; } 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 923aeebe..dcc5a05e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -14,8 +14,10 @@ import com.eu.habbo.messages.outgoing.rooms.FloodCounterComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.*; +import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent; import com.eu.habbo.plugin.events.users.UserCreditsEvent; import com.eu.habbo.plugin.events.users.UserDisconnectEvent; +import com.eu.habbo.plugin.events.users.UserGetIPAddressEvent; import com.eu.habbo.plugin.events.users.UserPointsEvent; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; @@ -114,11 +116,31 @@ public class Habbo implements Runnable { } - public void connect() { + public boolean connect() { + String ip = ""; + if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { SocketAddress address = this.client.getChannel().remoteAddress(); + ip = ((InetSocketAddress) address).getAddress().getHostAddress(); + } - if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress()); + if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) { + UserGetIPAddressEvent event = Emulator.getPluginManager().fireEvent(new UserGetIPAddressEvent(this, ip)); + if (event.hasChangedIP()) { + ip = event.getUpdatedIp(); + } + } + + if (!ip.isEmpty()) { + this.habboInfo.setIpLogin(ip); + } + + if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) { + return false; + } + + if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.habboInfo.getIpLogin())) { + return false; } this.habboInfo.setMachineID(this.client.getMachineId()); @@ -128,6 +150,7 @@ public class Habbo implements Runnable { Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); + 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 8975b888..e8bf5f3a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -205,7 +205,7 @@ public class HabboManager { 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.setString(2, habbo.getHabboInfo().getIpLogin()); statement.setInt(3, habbo.getHabboInfo().getId()); statement.setInt(4, limit); 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 bd63c760..33cc6b5f 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 @@ -77,19 +77,13 @@ public class SecureLoginEvent extends MessageHandler { if (this.client.getHabbo() == null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso); 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())) { - Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - return; - } - try { habbo.setClient(this.client); this.client.setHabbo(habbo); - this.client.getHabbo().connect(); + if(!this.client.getHabbo().connect()) { + Emulator.getGameServer().getGameClientManager().disposeClient(this.client); + return; + } if (this.client.getHabbo().getHabboInfo() == null) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); @@ -191,7 +185,7 @@ public class SecureLoginEvent extends MessageHandler { } } - Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress())); + Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getHabbo().getHabboInfo().getIpLogin())); if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) { final Habbo finalHabbo = habbo; 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 deleted file mode 100644 index a74220f0..00000000 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent_BACKUP.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.eu.habbo.messages.incoming.handshake; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.friends.FriendsComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; -import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer; -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.modtool.ModToolComposer; -import com.eu.habbo.messages.outgoing.navigator.*; -import com.eu.habbo.messages.outgoing.users.*; -import com.eu.habbo.plugin.events.users.UserLoginEvent; - -import java.util.ArrayList; - -public class SecureLoginEvent_BACKUP extends MessageHandler { - - - @Override - public void handle() throws Exception { - - if (!Emulator.isReady) - return; - - String sso = this.packet.readString(); - - if (this.client.getHabbo() == null) { - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso); - if (habbo != null) { - habbo.setClient(this.client); - this.client.setHabbo(habbo); - this.client.getHabbo().connect(); - //this.client.sendResponse(new DebugConsoleComposer()); - Emulator.getThreading().run(habbo); - Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); - - 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()); - messages.add(new UserClubComposer(this.client.getHabbo()).compose()); - messages.add(new DebugConsoleComposer(Emulator.debugging).compose()); - messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose()); - messages.add(new NewUserIdentityComposer(habbo).compose()); - messages.add(new UserPerksComposer(habbo).compose()); - messages.add(new SessionRightsComposer().compose()); - messages.add(new FavoriteRoomsCountComposer(habbo).compose()); - //messages.add(new FriendsComposer(this.client.getHabbo()).compose()); - //messages.add(new NewUserIdentityComposer().compose()); - //messages.add(new UserDataComposer(this.client.getHabbo()).compose()); - //messages.add(new SessionRightsComposer().compose()); - //messages.add(new MinimailCountComposer().compose()); - //messages.add(new MessengerInitComposer(this.client.getHabbo()).compose()); - //messages.add(new FriendsComposer(this.client.getHabbo()).compose()); - - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { - messages.add(new ModToolComposer(this.client.getHabbo()).compose()); - } - - this.client.sendResponses(messages); - - //Hardcoded - this.client.sendResponse(new NewNavigatorMetaDataComposer()); - this.client.sendResponse(new NewNavigatorLiftedRoomsComposer()); - this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer()); - 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())); - //this.client.sendResponse(new UserEffectsListComposer()); - - - Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress())); - - } else { - this.client.sendResponse(new GenericAlertComposer("Can't connect *sadpanda*")); - - this.client.getChannel().close(); - } - } - } -} diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserGetIPAddressEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserGetIPAddressEvent.java new file mode 100644 index 00000000..c77b3639 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserGetIPAddressEvent.java @@ -0,0 +1,28 @@ +package com.eu.habbo.plugin.events.users; + +import com.eu.habbo.habbohotel.users.Habbo; + +public class UserGetIPAddressEvent extends UserEvent{ + public final String oldIp; + + private String updatedIp; + private boolean changedIP = false; + + public UserGetIPAddressEvent(Habbo habbo, String ip) { + super(habbo); + this.oldIp = ip; + } + + public void setUpdatedIp(String updatedIp) { + this.updatedIp = updatedIp; + this.changedIP = true; + } + + public boolean hasChangedIP() { + return changedIP; + } + + public String getUpdatedIp() { + return updatedIp; + } +} 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 15268bcb..d864a5fb 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 @@ -6,10 +6,9 @@ import java.net.SocketAddress; public class UserLoginEvent extends UserEvent { - public final SocketAddress ip; + public final String ip; - - public UserLoginEvent(Habbo habbo, SocketAddress ip) { + public UserLoginEvent(Habbo habbo, String ip) { super(habbo); this.ip = ip; From 4cf11336cfc9e9bee9c9a5612eb9a2923169ea07 Mon Sep 17 00:00:00 2001 From: Thijmen Date: Tue, 19 Jan 2021 06:12:51 -0500 Subject: [PATCH 79/80] Add Docker support --- Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a4cda773 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM maven:latest AS builder + +# Copy the Emulator sources to the container +COPY . . +# Package it +RUN mvn package && mv /target/Habbo*-with-dependencies.jar /target/Habbo.jar + +# Use Java 8 for running +FROM java:8 AS runner + +# Copy the generated source +COPY --from=builder /target/Habbo.jar / + +# Save the script to wait for the database, among running the Arcturus Emulator +RUN echo "#!/bin/bash \n java -jar /Habbo.jar" > /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Run the Emulator with Java +ENTRYPOINT ["/entrypoint.sh"] From a9b73d23d0a6ab5a3dac8142215dae300a2cf667 Mon Sep 17 00:00:00 2001 From: TheOleg Date: Wed, 20 Jan 2021 18:11:16 -0500 Subject: [PATCH 80/80] Update Dockerfile - run emulator in UTF-8 mode --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a4cda773..e045ce45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ FROM java:8 AS runner COPY --from=builder /target/Habbo.jar / # Save the script to wait for the database, among running the Arcturus Emulator -RUN echo "#!/bin/bash \n java -jar /Habbo.jar" > /entrypoint.sh +RUN echo "#!/bin/bash \n java -Dfile.encoding=UTF-8 -jar /Habbo.jar" > /entrypoint.sh RUN chmod +x /entrypoint.sh # Run the Emulator with Java